Debian Codegraph @

test/system/test_interactions/all_plugins_coexist.yml

raw symbols SCIP
1 ---
2 :cmock:
3 :enforce_strict_ordering: 1
4 :plugins:
5 - :array
6 - :cexception
7 - :ignore
8 - :callback
9 - :return_thru_ptr
10 - :ignore_arg
11 - :expect_any_args
12 :callback_after_arg_check: true
13 :callback_include_count: false
14 :treat_externs: :include
15 :treat_inlines: :include
16
17 :systest:
18 :types: |
19 typedef struct _POINT_T {
20 int x;
21 int y;
22 } POINT_T;
23
24 :mockable: |
25 #include "CException.h"
26 extern void foo(POINT_T* a);
27 POINT_T* bar(void);
28 void fooa(POINT_T a[]);
29 void foos(const char * a);
30 const char * bars(void);
31 void no_pointers(int a, const char* b);
32 int mixed(int a, int* b, int c);
33 void no_args(void);
34
35 :source:
36 :header: |
37 #include "CException.h"
38 void function_a(void);
39 void function_b(void);
40 void function_c(void);
41 int function_d(void);
42 void function_e(void);
43 int function_f(void);
44
45 :code: |
46 void function_a(void)
47 {
48 foo(bar());
49 }
50
51 void function_b(void) {
52 fooa(bar());
53 }
54
55 void function_c(void) {
56 CEXCEPTION_T e;
57 Try {
58 foos(bars());
59 } Catch(e) { foos("err"); }
60 }
61
62 int function_d(void) {
63 int test_list[] = { 1, 2, 3, 4, 5 };
64 no_pointers(1, "silly");
65 return mixed(6, test_list, 7);
66 }
67
68 void function_e(void) {
69 foos("Hello");
70 foos("Tuna");
71 foos("Oranges");
72 }
73
74 int function_f(void) {
75 int a = 1;
76 int b = 2;
77 int c;
78 POINT_T* pt = bar();
79 c = pt->x;
80 c = mixed(a, &b, c);
81 return b + c;
82 }
83
84 :tests:
85 :common: |
86 #include "CException.h"
87 void setUp(void) {}
88 void tearDown(void) {}
89 void my_foo_callback(POINT_T* a) { TEST_ASSERT_EQUAL_INT(2, a->x); }
90 int my_mixed_callback(int a, int* b, int c) { return a + *b + c; }
91
92 :units:
93 - :pass: TRUE
94 :should: 'handle the situation where we pass nulls to pointers'
95 :code: |
96 test()
97 {
98 bar_ExpectAndReturn(NULL);
99 foo_Expect(NULL);
100
101 function_a();
102 }
103
104 - :pass: FALSE
105 :should: 'handle the situation where we expected nulls to pointers but did not get that'
106 :code: |
107 test()
108 {
109 POINT_T pt = {1, 2};
110 bar_ExpectAndReturn(&pt);
111 foo_Expect(NULL);
112
113 function_a();
114 }
115
116 - :pass: FALSE
117 :should: 'handle the situation where we did not expect nulls to pointers but got null'
118 :code: |
119 test()
120 {
121 POINT_T ex = {1, 2};
122 bar_ExpectAndReturn(NULL);
123 foo_Expect(&ex);
124
125 function_a();
126 }
127
128 - :pass: FALSE
129 :should: 'handle the situation where we pass single object with expect and it is wrong'
130 :code: |
131 test()
132 {
133 POINT_T pt = {1, 2};
134 POINT_T ex = {1, 3};
135 bar_ExpectAndReturn(&pt);
136 foo_Expect(&ex);
137
138 function_a();
139 }
140
141 - :pass: TRUE
142 :should: 'handle the situation where we pass single object with expect and use array handler'
143 :code: |
144 test()
145 {
146 POINT_T pt = {1, 2};
147 POINT_T ex = {1, 2};
148 bar_ExpectAndReturn(&pt);
149 foo_ExpectWithArray(&ex, 1);
150
151 function_a();
152 }
153
154 - :pass: FALSE
155 :should: 'handle the situation where we pass single object with expect and use array handler and it is wrong'
156 :code: |
157 test()
158 {
159 POINT_T pt = {1, 2};
160 POINT_T ex = {1, 3};
161 bar_ExpectAndReturn(&pt);
162 foo_ExpectWithArray(&ex, 1);
163
164 function_a();
165 }
166
167 - :pass: TRUE
168 :should: 'handle the situation where we pass multiple objects with expect and use array handler'
169 :code: |
170 test()
171 {
172 POINT_T pt[] = {{1, 2}, {3, 4}, {5, 6}};
173 POINT_T ex[] = {{1, 2}, {3, 4}, {5, 6}};
174 bar_ExpectAndReturn(pt);
175 foo_ExpectWithArray(ex, 3);
176
177 function_a();
178 }
179
180 - :pass: FALSE
181 :should: 'handle the situation where we pass multiple objects with expect and use array handler and it is wrong at end'
182 :code: |
183 test()
184 {
185 POINT_T pt[] = {{1, 2}, {3, 4}, {5, 6}};
186 POINT_T ex[] = {{1, 2}, {3, 4}, {5, 9}};
187 bar_ExpectAndReturn(pt);
188 foo_ExpectWithArray(ex, 3);
189
190 function_a();
191 }
192
193 - :pass: TRUE
194 :should: 'handle the situation where we pass single array element with expect'
195 :code: |
196 test()
197 {
198 POINT_T pt = {1, 2};
199 POINT_T ex = {1, 2};
200 bar_ExpectAndReturn(&pt);
201 fooa_Expect(&ex);
202
203 function_b();
204 }
205
206 - :pass: TRUE
207 :should: 'handle standard c string as null terminated and not do crappy memory compares of a byte, passing'
208 :code: |
209 test()
210 {
211 const char* retval = "This is a\0 silly string";
212 bars_ExpectAndReturn((char*)retval);
213 foos_Expect("This is a\0 wacky string");
214
215 function_c();
216 }
217
218 - :pass: FALSE
219 :should: 'handle standard c string as null terminated and not do crappy memory compares of a byte, finding failures'
220 :code: |
221 test()
222 {
223 const char* retval = "This is a silly string";
224 bars_ExpectAndReturn((char*)retval);
225 foos_Expect("This is a wacky string");
226
227 function_c();
228 }
229
230 - :pass: TRUE
231 :should: 'handle creating array expects when we have mixed arguments for single object'
232 :code: |
233 test()
234 {
235 int expect_list[] = { 1, 9 };
236 no_pointers_Expect(1, "silly");
237 mixed_ExpectAndReturn(6, expect_list, 7, 13);
238
239 TEST_ASSERT_EQUAL(13, function_d());
240 }
241
242 - :pass: FALSE
243 :should: 'handle creating array expects when we have mixed arguments and handle failures for single object'
244 :code: |
245 test()
246 {
247 int expect_list[] = { 9, 1 };
248 no_pointers_Expect(1, "silly");
249 mixed_ExpectAndReturn(6, expect_list, 7, 13);
250
251 TEST_ASSERT_EQUAL(13, function_d());
252 }
253
254 - :pass: TRUE
255 :should: 'handle creating array expects when we have mixed arguments for multiple objects'
256 :code: |
257 test()
258 {
259 int expect_list[] = { 1, 2, 3, 4, 6 };
260 no_pointers_Expect(1, "silly");
261 mixed_ExpectWithArrayAndReturn(6, expect_list, 4, 7, 13);
262
263 TEST_ASSERT_EQUAL(13, function_d());
264 }
265
266 - :pass: FALSE
267 :should: 'handle creating array expects when we have mixed arguments and handle failures for multiple objects'
268 :code: |
269 test()
270 {
271 int expect_list[] = { 1, 2, 3, 4, 6 };
272 no_pointers_Expect(1, "silly");
273 mixed_ExpectWithArrayAndReturn(6, expect_list, 5, 7, 13);
274
275 TEST_ASSERT_EQUAL(13, function_d());
276 }
277
278 - :pass: TRUE
279 :should: 'handle an exception being caught'
280 :code: |
281 test()
282 {
283 const char* retval = "This is a\0 silly string";
284 bars_ExpectAndReturn((char*)retval);
285 foos_ExpectAndThrow("This is a\0 wacky string", 55);
286 foos_Expect("err");
287
288 function_c();
289 }
290
291 - :pass: FALSE
292 :should: 'handle an exception being caught but still catch following errors'
293 :code: |
294 test()
295 {
296 const char* retval = "This is a\0 silly string";
297 bars_ExpectAndReturn((char*)retval);
298 foos_ExpectAndThrow("This is a\0 wacky string", 55);
299 foos_Expect("wrong error");
300
301 function_c();
302 }
303
304 - :pass: FALSE
305 :should: 'fail strict ordering problems even though we would otherwise have passed'
306 :code: |
307 test()
308 {
309 int expect_list[] = { 1, 2, 3, 4, 6 };
310 mixed_ExpectWithArrayAndReturn(6, expect_list, 4, 7, 13);
311 no_pointers_Expect(1, "silly");
312
313 TEST_ASSERT_EQUAL(13, function_d());
314 }
315
316 - :pass: TRUE
317 :should: 'that we can properly ignore last function but the other will work properly'
318 :code: |
319 test()
320 {
321 int expect_list[] = { 1, 2, 3, 4, 6 };
322 mixed_ExpectWithArrayAndReturn(6, expect_list, 4, 7, 13);
323 no_pointers_Ignore();
324
325 TEST_ASSERT_EQUAL(13, function_d());
326 }
327
328 - :pass: TRUE
329 :should: 'that we can properly ignore first function but the other will work properly'
330 :code: |
331 test()
332 {
333 mixed_IgnoreAndReturn(13);
334 no_pointers_Expect(1, "silly");
335
336 TEST_ASSERT_EQUAL(13, function_d());
337 }
338
339 - :pass: TRUE
340 :should: 'that we just have to ignore a call once because we are not counting calls'
341 :code: |
342 test()
343 {
344 foos_Ignore();
345
346 function_e();
347 }
348
349 - :pass: TRUE
350 :should: 'that we can use a callback and an expect'
351 :code: |
352 test()
353 {
354 POINT_T pt1 = {2, 3};
355 POINT_T pt2 = {2, 3};
356 bar_ExpectAndReturn(&pt1);
357 foo_Expect(&pt2);
358 foo_StubWithCallback((CMOCK_foo_CALLBACK)my_foo_callback);
359
360 function_a();
361 }
362
363 - :pass: FALSE
364 :should: 'that we can fail even when using a callback if we want to expect call but did not and we are checking that'
365 :code: |
366 test()
367 {
368 POINT_T pt = {2, 3};
369 bar_ExpectAndReturn(&pt);
370 foo_StubWithCallback((CMOCK_foo_CALLBACK)my_foo_callback);
371
372 function_a();
373 }
374
375 - :pass: FALSE
376 :should: 'that we can fail even when using a callback if args are wrong and we are checking those'
377 :code: |
378 test()
379 {
380 POINT_T pt1 = {2, 3};
381 POINT_T pt2 = {1, 3};
382 bar_ExpectAndReturn(&pt1);
383 foo_Expect(&pt2);
384 foo_StubWithCallback((CMOCK_foo_CALLBACK)my_foo_callback);
385
386 function_a();
387 }
388
389 - :pass: FALSE
390 :should: 'that we can fail from the callback itself'
391 :code: |
392 test()
393 {
394 POINT_T pt = {3, 3};
395 bar_ExpectAndReturn(&pt);
396 foo_Expect(&pt);
397 foo_StubWithCallback((CMOCK_foo_CALLBACK)my_foo_callback);
398
399 function_a();
400 }
401
402 - :pass: TRUE
403 :should: 'that a callback return value overrides the one from ExpectAndReturn'
404 :code: |
405 test()
406 {
407 int b = 2;
408 POINT_T pt1 = {3, 4};
409 bar_ExpectAndReturn(&pt1);
410 mixed_StubWithCallback((CMOCK_mixed_CALLBACK)my_mixed_callback);
411 mixed_ExpectAndReturn(1,&b,3,100);
412
413 TEST_ASSERT_EQUAL(8, function_f());
414 }
415
416 - :pass: TRUE
417 :should: 'that a callback return value overrides the one from ExpectAndReturn AND ReturnThruPtr still works'
418 :code: |
419 test()
420 {
421 int b_in = 2;
422 int b_out = 3;
423 POINT_T pt1 = {3, 4};
424 bar_ExpectAndReturn(&pt1);
425 mixed_StubWithCallback((CMOCK_mixed_CALLBACK)my_mixed_callback);
426 mixed_ExpectAndReturn(1,&b_in,3,100);
427 mixed_ReturnThruPtr_b(&b_out);
428
429 TEST_ASSERT_EQUAL(9, function_f()); // (a=1, bin=2, c=pt.x=3, bout=3, sum=9)
430 }
431
432 - :pass: TRUE
433 :should: 'that a callback return value overrides the one from ExpectAnyArgs'
434 :code: |
435 test()
436 {
437 POINT_T pt1 = {5, 4};
438 bar_ExpectAndReturn(&pt1);
439 mixed_StubWithCallback((CMOCK_mixed_CALLBACK)my_mixed_callback);
440 mixed_ExpectAnyArgsAndReturn(100);
441
442 TEST_ASSERT_EQUAL(10, function_f()); // (a=1, bin=2, c=pt.x=5, bout=2, sum=10)
443 }
444
445 - :pass: TRUE
446 :should: 'that a callback return value overrides the one from ExpectAnyArgs AND ReturnThruPtr still works'
447 :code: |
448 test()
449 {
450 int b_out = 3;
451 POINT_T pt1 = {5, 4};
452 bar_ExpectAndReturn(&pt1);
453 mixed_StubWithCallback((CMOCK_mixed_CALLBACK)my_mixed_callback);
454 mixed_ExpectAnyArgsAndReturn(100);
455 mixed_ReturnThruPtr_b(&b_out);
456
457 TEST_ASSERT_EQUAL(11, function_f()); // (a=1, bin=2, c=pt.x=5, bout=3, sum=11)
458 }
459
460 ...