@@ -155,14 +155,14 @@ namespace {
155
155
simpleCheckerForPair (std::vector<std::string>(variables.begin () + 4 , variables.end ()), isInt, diffVars);
156
156
}
157
157
158
- void commonDifferentVariablesChecker (BaseTestGen &testGen, bool diffVars ){
158
+ void checkDifferentVariablesTrue_C (BaseTestGen &testGen){
159
159
for (const auto &[methodName, methodDescription] :
160
160
testGen.tests .at (different_variables_c).methods ) {
161
- if (methodName == " swap_two_int " ) {
161
+ if (methodName == " swap_two_int_pointers " ) {
162
162
checkTestCasePredicates (
163
163
methodDescription.testCases ,
164
164
std::vector<TestCasePredicate>(
165
- { [diffVars ](tests::Tests::MethodTestCase const &testCase) {
165
+ { [](tests::Tests::MethodTestCase const &testCase) {
166
166
return commonSimpleChecker ({testCase.paramValues [0 ]
167
167
.view ->getEntryValue (nullptr ),
168
168
testCase.paramPostValues [0 ]
@@ -171,39 +171,55 @@ namespace {
171
171
.view ->getEntryValue (nullptr ),
172
172
testCase.paramPostValues [1 ]
173
173
.view ->getEntryValue (nullptr )},
174
- true , diffVars ) &&
174
+ true , true ) &&
175
175
testCase.stdinValue == std::nullopt;
176
176
} }),
177
177
methodName);
178
- } else if (methodName == " swap_four_int " ) {
178
+ } else if (methodName == " max_of_two_float " ) {
179
179
checkTestCasePredicates (
180
180
methodDescription.testCases ,
181
181
std::vector<TestCasePredicate>(
182
- { [diffVars](tests::Tests::MethodTestCase const &testCase) {
183
- return commonSimpleChecker ({testCase.paramValues [0 ]
184
- .view ->getEntryValue (nullptr ),
185
- testCase.paramPostValues [0 ]
186
- .view ->getEntryValue (nullptr ),
187
- testCase.paramValues [1 ]
188
- .view ->getEntryValue (nullptr ),
189
- testCase.paramPostValues [1 ]
190
- .view ->getEntryValue (nullptr ),
191
- testCase.paramValues [2 ]
192
- .view ->getEntryValue (nullptr ),
193
- testCase.paramPostValues [2 ]
194
- .view ->getEntryValue (nullptr ),
195
- testCase.paramValues [3 ]
196
- .view ->getEntryValue (nullptr ),
197
- testCase.paramPostValues [3 ]
198
- .view ->getEntryValue (nullptr )},
199
- true , diffVars) &&
200
- testCase.stdinValue == std::nullopt;} }),
182
+ { [](tests::Tests::MethodTestCase const &testCase) {
183
+ return stod (testCase.paramValues [0 ].view ->getEntryValue (nullptr )) !=
184
+ stod (testCase.paramValues [1 ].view ->getEntryValue (nullptr )) &&
185
+ stod (testCase.returnValue .view ->getEntryValue (nullptr )) ==
186
+ std::max (stod (testCase.paramValues [0 ].view ->getEntryValue (nullptr )),
187
+ stod (testCase.paramValues [1 ].view ->getEntryValue (nullptr ))) &&
188
+ testCase.stdinValue == std::nullopt;
189
+ },
190
+ [](tests::Tests::MethodTestCase const &testCase) {
191
+ return stod (testCase.paramValues [0 ].view ->getEntryValue (nullptr )) !=
192
+ stod (testCase.paramValues [1 ].view ->getEntryValue (nullptr )) &&
193
+ stod (testCase.returnValue .view ->getEntryValue (nullptr )) ==
194
+ std::max (stod (testCase.paramValues [0 ].view ->getEntryValue (nullptr )),
195
+ stod (testCase.paramValues [1 ].view ->getEntryValue (nullptr ))) &&
196
+ testCase.stdinValue == std::nullopt;
197
+ } }),
201
198
methodName);
202
- } else if (methodName == " swap_two_float " ) {
199
+ } else if (methodName == " struct_test " ) {
203
200
checkTestCasePredicates (
204
201
methodDescription.testCases ,
205
202
std::vector<TestCasePredicate>(
206
- { [diffVars](tests::Tests::MethodTestCase const &testCase) {
203
+ {
204
+ [](tests::Tests::MethodTestCase const &testCase) {
205
+ return testCase.returnValue .view ->getEntryValue (nullptr ) == " -1" ;
206
+ },
207
+ [](tests::Tests::MethodTestCase const &testCase) {
208
+ return testCase.returnValue .view ->getEntryValue (nullptr ) == " 1" ;
209
+ } }),
210
+ methodName);
211
+ }
212
+ }
213
+ }
214
+
215
+ void checkDifferentVariablesFalse_C (BaseTestGen &testGen){
216
+ for (const auto &[methodName, methodDescription] :
217
+ testGen.tests .at (different_variables_c).methods ) {
218
+ if (methodName == " swap_two_int_pointers" ) {
219
+ checkTestCasePredicates (
220
+ methodDescription.testCases ,
221
+ std::vector<TestCasePredicate>(
222
+ { [](tests::Tests::MethodTestCase const &testCase) {
207
223
return commonSimpleChecker ({testCase.paramValues [0 ]
208
224
.view ->getEntryValue (nullptr ),
209
225
testCase.paramPostValues [0 ]
@@ -212,70 +228,47 @@ namespace {
212
228
.view ->getEntryValue (nullptr ),
213
229
testCase.paramPostValues [1 ]
214
230
.view ->getEntryValue (nullptr )},
215
- false , diffVars ) &&
231
+ true , false ) &&
216
232
testCase.stdinValue == std::nullopt;
217
233
} }),
218
234
methodName);
219
- } else if (methodName == " swap_four_float " ) {
235
+ } else if (methodName == " max_of_two_float " ) {
220
236
checkTestCasePredicates (
221
237
methodDescription.testCases ,
222
238
std::vector<TestCasePredicate>(
223
- { [diffVars](tests::Tests::MethodTestCase const &testCase) {
224
- return commonSimpleChecker ({testCase.paramValues [0 ]
225
- .view ->getEntryValue (nullptr ),
226
- testCase.paramPostValues [0 ]
227
- .view ->getEntryValue (nullptr ),
228
- testCase.paramValues [1 ]
229
- .view ->getEntryValue (nullptr ),
230
- testCase.paramPostValues [1 ]
231
- .view ->getEntryValue (nullptr ),
232
- testCase.paramValues [2 ]
233
- .view ->getEntryValue (nullptr ),
234
- testCase.paramPostValues [2 ]
235
- .view ->getEntryValue (nullptr ),
236
- testCase.paramValues [3 ]
237
- .view ->getEntryValue (nullptr ),
238
- testCase.paramPostValues [3 ]
239
- .view ->getEntryValue (nullptr )},
240
- false , diffVars) &&
241
- testCase.stdinValue == std::nullopt;} }),
239
+ { [](tests::Tests::MethodTestCase const &testCase) {
240
+ return stod (testCase.paramValues [0 ].view ->getEntryValue (nullptr )) !=
241
+ stod (testCase.paramValues [1 ].view ->getEntryValue (nullptr )) &&
242
+ stod (testCase.returnValue .view ->getEntryValue (nullptr )) ==
243
+ std::max (stod (testCase.paramValues [0 ].view ->getEntryValue (nullptr )),
244
+ stod (testCase.paramValues [1 ].view ->getEntryValue (nullptr ))) &&
245
+ testCase.stdinValue == std::nullopt;
246
+ },
247
+ [](tests::Tests::MethodTestCase const &testCase) {
248
+ return stod (testCase.paramValues [0 ].view ->getEntryValue (nullptr )) ==
249
+ stod (testCase.paramValues [1 ].view ->getEntryValue (nullptr )) &&
250
+ stod (testCase.returnValue .view ->getEntryValue (nullptr )) ==
251
+ std::max (stod (testCase.paramValues [0 ].view ->getEntryValue (nullptr )),
252
+ stod (testCase.paramValues [1 ].view ->getEntryValue (nullptr ))) &&
253
+ testCase.stdinValue == std::nullopt;
254
+ } }),
242
255
methodName);
243
- } else if (methodName == " swap_two_int_two_float " ) {
256
+ } else if (methodName == " struct_test " ) {
244
257
checkTestCasePredicates (
245
258
methodDescription.testCases ,
246
259
std::vector<TestCasePredicate>(
247
- { [diffVars](tests::Tests::MethodTestCase const &testCase) {
248
- return commonSimpleChecker ({testCase.paramValues [0 ]
249
- .view ->getEntryValue (nullptr ),
250
- testCase.paramPostValues [0 ]
251
- .view ->getEntryValue (nullptr ),
252
- testCase.paramValues [1 ]
253
- .view ->getEntryValue (nullptr ),
254
- testCase.paramPostValues [1 ]
255
- .view ->getEntryValue (nullptr )},
256
- true , diffVars) &&
257
- commonSimpleChecker ({testCase.paramValues [2 ]
258
- .view ->getEntryValue (nullptr ),
259
- testCase.paramPostValues [2 ]
260
- .view ->getEntryValue (nullptr ),
261
- testCase.paramValues [3 ]
262
- .view ->getEntryValue (nullptr ),
263
- testCase.paramPostValues [3 ]
264
- .view ->getEntryValue (nullptr )},
265
- false , diffVars) &&
266
- testCase.stdinValue == std::nullopt;} }),
260
+ {
261
+ [](tests::Tests::MethodTestCase const &testCase) {
262
+ return testCase.returnValue .view ->getEntryValue (nullptr ) == " -1" ;
263
+ },
264
+ [](tests::Tests::MethodTestCase const &testCase) {
265
+ return testCase.returnValue .view ->getEntryValue (nullptr ) == " 1" ;
266
+ } }),
267
267
methodName);
268
268
}
269
269
}
270
270
}
271
271
272
- void checkDifferentVariablesTrue_C (BaseTestGen &testGen){
273
- commonDifferentVariablesChecker (testGen, true );
274
- }
275
-
276
- void checkDifferentVariablesFalse_C (BaseTestGen &testGen){
277
- commonDifferentVariablesChecker (testGen, false );
278
- }
279
272
280
273
void checkBasicFunctions_C (BaseTestGen &testGen) {
281
274
EXPECT_EQ (printer::TestsPrinter::needsMathHeader (testGen.tests .at (basic_functions_c)),
0 commit comments