Debian Codegraph @

test/system/test_interactions/parsing_challenges.yml

raw symbols SCIP
1 ---
2 :cmock:
3 :plugins:
4 - # no plugins
5 :treat_as_void:
6 - VOID_TYPE_CRAZINESS_CFG
7 :treat_as:
8 TypeDefInt: HEX8
9 VOID_TYPE_CRAZINESS_CFG*: PTR
10
11 :systest:
12 :types: |
13 typedef unsigned short U16;
14 typedef struct _POINT_T
15 {
16 int x;
17 int y;
18 } POINT_T;
19 typedef void VOID_TYPE_CRAZINESS_CFG;
20 typedef int TypeDefInt;
21
22 :mockable: |
23 /* Make sure we ignore the following
24 #include "NonExistantFile.h
25 */
26 //#include "AndIgnoreThisToo.h"
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 #define SHOULD_IGNORE_NEXT_FUNC_DEF_AS_PART_OF_MACRO \
31 void IgnoredFunction(NotAValidType ToMakeItFailIfWeActuallyMockedThis);
32
33 // typedef edge case; must be in mockable.h for test to compile
34 // not ANSI C but it has been done and will break cmock if not handled
35 typedef void VOID_TYPE_CRAZINESS_LCL;
36
37 VOID_TYPE_CRAZINESS_LCL void_type_craziness1(int * a, int *b, int* c);
38 void void_type_craziness2(VOID_TYPE_CRAZINESS_CFG);
39 void void_type_craziness3(VOID_TYPE_CRAZINESS_CFG* a);
40
41 // pointer parsing exercise
42 U16 *ptr_return1(int a);
43 U16* ptr_return2(int a);
44 U16 * ptr_return3(int a);
45
46 unsigned int** ptr_ptr_return1(unsigned int** a);
47 unsigned int* *ptr_ptr_return2(unsigned int* *a);
48 unsigned int **ptr_ptr_return3(unsigned int **a);
49 unsigned int ** ptr_ptr_return4(unsigned int ** a);
50
51 // variable argument lists
52 void var_args1(int a, ...);
53 void var_args2(int a, int b, ...);
54
55 // parsing "stress tests"
56 char
57 crazy_multiline(
58 int a,
59 unsigned int b);
60
61 unsigned long int incredible_descriptors(register const unsigned short a);
62
63 TypeDefInt uses_typedef_like_names(TypeDefInt typedefvar);
64
65 void oh_brackets1(int fudge[5]);
66 void oh_brackets2(int caramel[]);
67 void oh_brackets3(int toffee[(32)]);
68 void oh_brackets4(int taffy[ (64) ]);
69 #ifdef __cplusplus
70 }
71 #endif
72
73 :source:
74 :header: |
75 U16* exercise_return_pointers(int a);
76 void exercise_var_args(int a, int b);
77 void exercise_arglist_pointers(void);
78 char exercise_multiline_declarations(int a, unsigned int b);
79 void exercise_double_pointers(unsigned int** a);
80 int exercise_many_descriptors(int a);
81 void exercise_type_craziness3(VOID_TYPE_CRAZINESS_CFG* a);
82 TypeDefInt exercise_typedef_like_names(TypeDefInt a);
83
84 :code: |
85 int A, B, C;
86 unsigned int *pA, *pB, *pC;
87
88 U16* exercise_return_pointers(int a)
89 {
90 ptr_return1(a);
91 ptr_return2(a);
92 return ptr_return3(a);
93 }
94
95 void exercise_var_args(int a, int b)
96 {
97 var_args1(a, 3);
98 var_args2(a, b, 'c');
99 }
100
101 void exercise_arglist_pointers(void)
102 {
103 void_type_craziness1(&A, &B, &C);
104 void_type_craziness2();
105 }
106
107 char exercise_multiline_declarations(int a, unsigned int b)
108 {
109 return crazy_multiline(a, b);
110 }
111
112 void exercise_double_pointers(unsigned int** a)
113 {
114 ptr_ptr_return1((unsigned int**)a);
115 ptr_ptr_return2((unsigned int**)a);
116 ptr_ptr_return3((unsigned int**)a);
117 ptr_ptr_return4((unsigned int**)a);
118 }
119
120 int exercise_many_descriptors(int a)
121 {
122 return (int)incredible_descriptors((unsigned short)a);
123 }
124
125 void exercise_type_craziness3(VOID_TYPE_CRAZINESS_CFG* a)
126 {
127 void_type_craziness3(a);
128 }
129
130 TypeDefInt exercise_typedef_like_names(TypeDefInt a)
131 {
132 return uses_typedef_like_names(a);
133 }
134
135 :tests:
136 :common: |
137 extern int A, B, C;
138 extern unsigned int *pA, *pB, *pC;
139
140 void setUp(void)
141 {
142 A = 100;
143 B = 200;
144 C = 300;
145 pA = (unsigned int*)(&A);
146 pB = (unsigned int*)(&B);
147 pC = (unsigned int*)(&C);
148 }
149 void tearDown(void) {}
150 :units:
151 - :pass: TRUE
152 :should: 'execute simple pointer return value check'
153 :code: |
154 test()
155 {
156 U16 retval;
157 ptr_return1_ExpectAndReturn(2, NULL);
158 ptr_return2_ExpectAndReturn(2, NULL);
159 ptr_return3_ExpectAndReturn(2, &retval);
160 TEST_ASSERT_EQUAL_PTR(&retval, exercise_return_pointers(2));
161 }
162
163 - :pass: TRUE
164 :should: 'ignore var args in expect prototype generation'
165 :code: |
166 test()
167 {
168 var_args1_Expect(2);
169 var_args2_Expect(2, 3);
170 exercise_var_args(2, 3);
171 }
172
173 - :pass: TRUE
174 :should: "not process a typedef'd void as anything other than void"
175 :code: |
176 test()
177 {
178 void_type_craziness1_Expect(&A, &B, &C);
179 void_type_craziness2_Expect();
180 exercise_arglist_pointers();
181 }
182
183 - :pass: TRUE
184 :should: 'successfully mock crazy multline function prototypes'
185 :code: |
186 test()
187 {
188 crazy_multiline_ExpectAndReturn(-10, 11, 'z');
189 TEST_ASSERT_EQUAL('z', exercise_multiline_declarations(-10, 11));
190 }
191
192 - :pass: TRUE
193 :should: 'mock double pointers just fine'
194 :code: |
195 test()
196 {
197 ptr_ptr_return1_ExpectAndReturn(&pA, &pB);
198 ptr_ptr_return2_ExpectAndReturn(&pA, &pB);
199 ptr_ptr_return3_ExpectAndReturn(&pA, &pB);
200 ptr_ptr_return4_ExpectAndReturn(&pA, &pB);
201 exercise_double_pointers((unsigned int**)(&pA));
202 }
203
204 - :pass: TRUE
205 :should: 'mock prototypes with long lists of return and parameter type descriptors'
206 :code: |
207 test()
208 {
209 incredible_descriptors_ExpectAndReturn(888, 777);
210 TEST_ASSERT_EQUAL(777, exercise_many_descriptors(888));
211 }
212
213 - :pass: TRUE
214 :should: 'handle words like typdef as PART of a variable or type'
215 :code: |
216 test()
217 {
218 uses_typedef_like_names_ExpectAndReturn((TypeDefInt)54, (TypeDefInt)53);
219 TEST_ASSERT_EQUAL(53, exercise_typedef_like_names((TypeDefInt)54));
220 }
221
222 - :pass: FALSE
223 :should: 'handle words like typdef as PART of a variable or type during failing tests'
224 :code: |
225 test()
226 {
227 uses_typedef_like_names_ExpectAndReturn((TypeDefInt)52, (TypeDefInt)53);
228 TEST_ASSERT_EQUAL(53, exercise_typedef_like_names((TypeDefInt)54));
229 }
230
231 - :pass: TRUE
232 :should: 'handle typedef of void used as a void pointer'
233 :code: |
234 test()
235 {
236 char blah[5] = "blah";
237 void_type_craziness3_Expect(blah);
238 exercise_type_craziness3(blah);
239 }
240
241
242 ...