5
5
#include " Paths.h"
6
6
#include " exceptions/NoSuchTypeException.h"
7
7
#include " exceptions/UnImplementedException.h"
8
+ #include " testgens/BaseTestGen.h"
8
9
#include " utils/CollectionUtils.h"
9
10
#include " utils/FileSystemUtils.h"
10
11
#include " utils/KleeUtils.h"
@@ -29,8 +30,9 @@ static const std::string CALLOC_DECLARATION = "extern\n"
29
30
30
31
printer::KleePrinter::KleePrinter (const types::TypesHandler *typesHandler,
31
32
std::shared_ptr<BuildDatabase> buildDatabase,
32
- utbot::Language srcLanguage)
33
- : Printer(srcLanguage), typesHandler(typesHandler), buildDatabase(std::move(buildDatabase)) {
33
+ utbot::Language srcLanguage,
34
+ const BaseTestGen *testGen)
35
+ : Printer(srcLanguage), typesHandler(typesHandler), buildDatabase(std::move(buildDatabase)), testGen(testGen) {
34
36
}
35
37
36
38
void KleePrinter::writePosixWrapper (const Tests &tests,
@@ -376,7 +378,11 @@ void KleePrinter::genParamsDeclarations(
376
378
.str ();
377
379
ss << constraintsBlock;
378
380
}
381
+ std::unordered_map<std::string , std::vector<std::string>>typesToNames;
379
382
for (const auto ¶m : testMethod.params ) {
383
+ if (testGen->settingsContext .differentVariablesOfTheSameType ){
384
+ typesToNames[param.type .typeName ()].push_back (param.name );
385
+ }
380
386
if (!filter (param)) {
381
387
continue ;
382
388
}
@@ -388,7 +394,9 @@ void KleePrinter::genParamsDeclarations(
388
394
auto paramType =
389
395
kleeParam.type .maybeJustPointer () ? kleeParam.type .baseTypeObj () : kleeParam.type ;
390
396
strKleeMakeSymbolic (paramType, kleeParam.name , param.name , !isArray);
391
- genConstraints (kleeParam, testMethod.name );
397
+ if (testGen->settingsContext .differentVariablesOfTheSameType && typesToNames[param.type .typeName ()].size () <= 10 ){
398
+ genConstraints (kleeParam, testMethod.name , typesToNames[param.type .typeName ()]);}
399
+ else {genConstraints (kleeParam, testMethod.name );}
392
400
genTwoDimPointers (param, true );
393
401
commentBlockSeparator ();
394
402
}
@@ -479,10 +487,10 @@ void KleePrinter::genParamsKleeAssumes(
479
487
}
480
488
}
481
489
482
- void KleePrinter::genConstraints (const Tests::MethodParam ¶m, const std::string &methodName) {
490
+ void KleePrinter::genConstraints (const Tests::MethodParam ¶m, const std::string &methodName, const std::vector<std::string>& names ) {
483
491
KleeConstraintsPrinter constraintsPrinter (typesHandler, srcLanguage);
484
492
constraintsPrinter.setTabsDepth (tabsDepth);
485
- const auto constraintsBlock = constraintsPrinter.genConstraints (param).str ();
493
+ const auto constraintsBlock = constraintsPrinter.genConstraints (param, names ).str ();
486
494
ss << constraintsBlock;
487
495
}
488
496
0 commit comments