Debian Codegraph @

test/system/test_interactions/expect_any_args.yml

raw symbols SCIP
1 ---
2 :cmock:
3 :plugins:
4 - 'expect_any_args'
5
6 :systest:
7 :types: |
8
9 :mockable: |
10 int foo(int a);
11 void bar(int b);
12
13 :source:
14 :header: |
15 int function(int a, int b, int c);
16 void func_b(int a);
17 :code: |
18 int function(int a, int b, int c)
19 {
20 bar(b);
21 return foo(a) + foo(b) + foo(c);
22 }
23 void func_b(int a)
24 {
25 bar(a);
26 }
27
28 :tests:
29 :common: |
30 void setUp(void) {}
31 void tearDown(void) {}
32 :units:
33 - :pass: TRUE
34 :should: 'successfully exercise simple ExpectAndReturn mock calls'
35 :code: |
36 test()
37 {
38 bar_Expect(2);
39 foo_ExpectAndReturn(1, 10);
40 foo_ExpectAndReturn(2, 20);
41 foo_ExpectAndReturn(3, 30);
42 TEST_ASSERT_EQUAL(60, function(1, 2, 3));
43 }
44
45 - :pass: TRUE
46 :should: 'ignore foo() call details'
47 :code: |
48 test()
49 {
50 bar_Expect(4);
51 foo_ExpectAnyArgsAndReturn(10);
52 foo_ExpectAnyArgsAndReturn(40);
53 foo_ExpectAnyArgsAndReturn(80);
54 TEST_ASSERT_EQUAL(130, function(3, 4, 3));
55 }
56
57 - :pass: FALSE
58 :should: 'ignore foo() call details and notice if we called foo() more times than expected'
59 :code: |
60 test()
61 {
62 bar_Expect(4);
63 foo_ExpectAnyArgsAndReturn(20);
64 foo_ExpectAnyArgsAndReturn(30);
65 TEST_ASSERT_EQUAL(50, function(3, 4, 9));
66 }
67
68 - :pass: FALSE
69 :should: 'ignore foo() call details and notice if we called foo() fewer times than expected'
70 :code: |
71 test()
72 {
73 bar_Expect(4);
74 foo_ExpectAnyArgsAndReturn(20);
75 foo_ExpectAnyArgsAndReturn(10);
76 foo_ExpectAnyArgsAndReturn(50);
77 foo_ExpectAnyArgsAndReturn(60);
78 TEST_ASSERT_EQUAL(70, function(3, 4, 9));
79 }
80
81 - :pass: TRUE
82 :should: 'ignore bar() and foo() call details'
83 :code: |
84 test()
85 {
86 bar_ExpectAnyArgs();
87 foo_ExpectAnyArgsAndReturn(50);
88 foo_ExpectAnyArgsAndReturn(50);
89 foo_ExpectAnyArgsAndReturn(50);
90 TEST_ASSERT_EQUAL(150, function(0, 0, 0));
91 }
92
93 - :pass: TRUE
94 :should: 'be able to handle an expect after ignore calls since we are ignoring args only'
95 :code: |
96 test()
97 {
98 bar_ExpectAnyArgs();
99 foo_ExpectAnyArgsAndReturn(50);
100 foo_ExpectAnyArgsAndReturn(50);
101 foo_ExpectAndReturn(3, 50);
102 TEST_ASSERT_EQUAL(150, function(1, 2, 3));
103 }
104
105 - :pass: TRUE
106 :should: 'be able to handle an ignore after an expect call since we are ignoring args only'
107 :code: |
108 test()
109 {
110 bar_ExpectAnyArgs();
111 foo_ExpectAndReturn(1, 50);
112 foo_ExpectAnyArgsAndReturn(50);
113 foo_ExpectAnyArgsAndReturn(50);
114 TEST_ASSERT_EQUAL(150, function(1, 2, 3));
115 }
116
117 - :pass: TRUE
118 :should: 'be able to handle an ignore within expect calls since we are ignoring args only'
119 :code: |
120 test()
121 {
122 bar_ExpectAnyArgs();
123 foo_ExpectAndReturn(1, 50);
124 foo_ExpectAnyArgsAndReturn(50);
125 foo_ExpectAndReturn(3, 50);
126 TEST_ASSERT_EQUAL(150, function(1, 2, 3));
127 }
128
129 - :pass: FALSE
130 :should: 'be able to detect problems with an expect even when using ignores'
131 :code: |
132 test()
133 {
134 bar_ExpectAnyArgs();
135 foo_ExpectAndReturn(1, 50);
136 foo_ExpectAnyArgsAndReturn(50);
137 foo_ExpectAndReturn(4, 50);
138 TEST_ASSERT_EQUAL(150, function(1, 2, 3));
139 }
140
141 - :pass: TRUE
142 :should: 'be able to handle a lone ExpectAnyArg call'
143 :code: |
144 test()
145 {
146 bar_ExpectAnyArgs();
147 func_b(1);
148 }
149
150 - :pass: FALSE
151 :should: 'be able to handle a lone ExpectAnyArg call that does not get called'
152 :code: |
153 test()
154 {
155 bar_ExpectAnyArgs();
156 }
157
158 - :pass: FALSE
159 :should: 'be able to handle a missing ExpectAnyArg call'
160 :code: |
161 test()
162 {
163 func_b(1);
164 }
165
166 - :pass: TRUE
167 :should: 'ignore foo() calls over multiple mock calls'
168 :code: |
169 test()
170 {
171 bar_ExpectAnyArgs();
172 foo_ExpectAnyArgsAndReturn(50);
173 foo_ExpectAnyArgsAndReturn(60);
174 foo_ExpectAnyArgsAndReturn(70);
175 TEST_ASSERT_EQUAL(180, function(0, 0, 0));
176
177 bar_ExpectAnyArgs();
178 foo_ExpectAnyArgsAndReturn(30);
179 foo_ExpectAnyArgsAndReturn(80);
180 foo_ExpectAnyArgsAndReturn(10);
181 TEST_ASSERT_EQUAL(120, function(0, 0, 0));
182
183 bar_ExpectAnyArgs();
184 foo_ExpectAnyArgsAndReturn(70);
185 foo_ExpectAnyArgsAndReturn(20);
186 foo_ExpectAnyArgsAndReturn(20);
187 TEST_ASSERT_EQUAL(110, function(0, 0, 0));
188 }
189
190 - :pass: TRUE
191 :should: 'have multiple cycles of expects still pass when this plugin enabled'
192 :code: |
193 test()
194 {
195 bar_Expect(2);
196 foo_ExpectAndReturn(1, 50);
197 foo_ExpectAndReturn(2, 60);
198 foo_ExpectAndReturn(3, 70);
199 TEST_ASSERT_EQUAL(180, function(1, 2, 3));
200
201 bar_Expect(5);
202 foo_ExpectAndReturn(4, 30);
203 foo_ExpectAndReturn(5, 80);
204 foo_ExpectAndReturn(6, 10);
205 TEST_ASSERT_EQUAL(120, function(4, 5, 6));
206
207 bar_Expect(8);
208 foo_ExpectAndReturn(7, 70);
209 foo_ExpectAndReturn(8, 20);
210 foo_ExpectAndReturn(9, 20);
211 TEST_ASSERT_EQUAL(110, function(7, 8, 9));
212 }
213
214 - :pass: FALSE
215 :should: 'have multiple cycles of expects still fail when this plugin enabled'
216 :code: |
217 test()
218 {
219 bar_Expect(2);
220 foo_ExpectAndReturn(1, 50);
221 foo_ExpectAndReturn(2, 60);
222 foo_ExpectAndReturn(3, 70);
223 TEST_ASSERT_EQUAL(180, function(1, 2, 3));
224
225 bar_Expect(5);
226 foo_ExpectAndReturn(4, 30);
227 foo_ExpectAndReturn(5, 80);
228 foo_ExpectAndReturn(6, 10);
229 TEST_ASSERT_EQUAL(120, function(4, 5, 6));
230
231 bar_Expect(8);
232 foo_ExpectAndReturn(7, 70);
233 foo_ExpectAndReturn(8, 20);
234 foo_ExpectAndReturn(9, 20);
235 TEST_ASSERT_EQUAL(110, function(0, 8, 9));
236 }
237
238 ...