@@ -99,6 +99,26 @@ namespace {
9999 }
100100 }
101101
102+ struct FileGenResult {
103+ FileTestGen testGen;
104+ Status status;
105+
106+ FileGenResult () = delete ;
107+
108+ FileGenResult (FileTestGen ttestGen, Status status) : testGen(std::move(ttestGen)),
109+ status (std::move(status)) {}
110+ };
111+
112+ FileGenResult performFeatureFileTestsRequest (const fs::path &filename) {
113+ auto projectRequest =
114+ createProjectRequest (projectName, suitePath, buildDirRelativePath, srcPaths);
115+ auto request = GrpcUtils::createFileRequest (std::move (projectRequest), filename);
116+ auto testGen = FileTestGen (*request, writer.get (), TESTMODE);
117+ testGen.setTargetForSource (filename);
118+ Status status = Server::TestsGenServiceImpl::ProcessBaseTestRequest (testGen, writer.get ());
119+ return FileGenResult (testGen, status);
120+ }
121+
102122 void checkAssertionFailures_C (BaseTestGen &testGen) {
103123 testUtils::checkTestCasePredicates (
104124 testGen.tests .at (assertion_failures_c).methods .begin ().value ().testCases ,
@@ -113,6 +133,8 @@ namespace {
113133 }
114134
115135 void checkBasicFunctions_C (BaseTestGen &testGen) {
136+ EXPECT_EQ (printer::TestsPrinter::needsMathHeader (testGen.tests .at (basic_functions_c)),
137+ false );
116138 for (const auto &[methodName, methodDescription] :
117139 testGen.tests .at (basic_functions_c).methods ) {
118140 if (methodName == " max_" ) {
@@ -467,6 +489,9 @@ namespace {
467489 }
468490 }
469491 void checkFloatingPointPlain_C (BaseTestGen &testGen) {
492+ EXPECT_EQ (
493+ printer::TestsPrinter::needsMathHeader (testGen.tests .at (floating_point_plain_c)),
494+ true );
470495 for (const auto &[methodName, methodDescription] :
471496 testGen.tests .at (floating_point_plain_c).methods ) {
472497 if (methodName == " plain_isnan" ) {
@@ -480,14 +505,6 @@ namespace {
480505 }
481506 }
482507
483- void checkMathInclude (BaseTestGen &testGen) {
484- EXPECT_EQ (
485- printer::TestsPrinter::needsMathHeader (testGen.tests .at (floating_point_plain_c)),
486- true );
487- EXPECT_EQ (printer::TestsPrinter::needsMathHeader (testGen.tests .at (basic_functions_c)),
488- false );
489- }
490-
491508 void checkLinkage (BaseTestGen &testGen) {
492509 const auto &methods = testGen.tests .at (linkage_c).methods ;
493510 EXPECT_EQ (methods.size (), 3 );
@@ -535,7 +552,7 @@ namespace {
535552
536553 void checkKeywords (BaseTestGen &testGen) {
537554 auto const &methods = testGen.tests .at (keywords_c).methods ;
538- testUtils::checkMinNumberOfTests (testGen.tests , 14 );
555+ testUtils::checkMinNumberOfTests (testGen.tests , 13 );
539556 for (const auto &[_, md] : methods) {
540557 if (md.name == " get_size_of_data" ) {
541558 checkTestCasePredicates (md.testCases ,
@@ -737,6 +754,110 @@ namespace {
737754 }
738755 }
739756
757+ TEST_F (Server_Test, Assertions_Failures) {
758+ auto [testGen, status] = performFeatureFileTestsRequest (assertion_failures_c);
759+ ASSERT_TRUE (status.ok ()) << status.error_message ();
760+ auto testFilePaths = CollectionUtils::getKeys (testGen.tests );
761+ EXPECT_TRUE (!testFilePaths.empty ()) << " Generated test files are missing." ;
762+ checkAssertionFailures_C (testGen);
763+ }
764+
765+ TEST_F (Server_Test, Dependent_Functions) {
766+ auto [testGen, status] = performFeatureFileTestsRequest (dependent_functions_c);
767+ ASSERT_TRUE (status.ok ()) << status.error_message ();
768+ auto testFilePaths = CollectionUtils::getKeys (testGen.tests );
769+ EXPECT_TRUE (!testFilePaths.empty ()) << " Generated test files are missing." ;
770+ checkDependentFunctions_C (testGen);
771+ }
772+
773+ TEST_F (Server_Test, Simple_Structs) {
774+ auto [testGen, status] = performFeatureFileTestsRequest (simple_structs_c);
775+ ASSERT_TRUE (status.ok ()) << status.error_message ();
776+ auto testFilePaths = CollectionUtils::getKeys (testGen.tests );
777+ EXPECT_TRUE (!testFilePaths.empty ()) << " Generated test files are missing." ;
778+ checkSimpleStructs_C (testGen);
779+ }
780+
781+ TEST_F (Server_Test, Simple_Unions) {
782+ auto [testGen, status] = performFeatureFileTestsRequest (simple_unions_c);
783+ ASSERT_TRUE (status.ok ()) << status.error_message ();
784+ auto testFilePaths = CollectionUtils::getKeys (testGen.tests );
785+ EXPECT_TRUE (!testFilePaths.empty ()) << " Generated test files are missing." ;
786+ checkSimpleUnions_C (testGen);
787+ }
788+
789+ TEST_F (Server_Test, Pointer_Parameters) {
790+ auto [testGen, status] = performFeatureFileTestsRequest (pointer_parameters_c);
791+ ASSERT_TRUE (status.ok ()) << status.error_message ();
792+ auto testFilePaths = CollectionUtils::getKeys (testGen.tests );
793+ EXPECT_TRUE (!testFilePaths.empty ()) << " Generated test files are missing." ;
794+ checkPointerParameters_C (testGen);
795+ }
796+
797+ TEST_F (Server_Test, Types) {
798+ auto [testGen, status] = performFeatureFileTestsRequest (types_c);
799+ ASSERT_TRUE (status.ok ()) << status.error_message ();
800+ auto testFilePaths = CollectionUtils::getKeys (testGen.tests );
801+ EXPECT_TRUE (!testFilePaths.empty ()) << " Generated test files are missing." ;
802+ checkTypes_C (testGen);
803+ }
804+
805+ TEST_F (Server_Test, Pointer_Return) {
806+ auto [testGen, status] = performFeatureFileTestsRequest (pointer_return_c);
807+ ASSERT_TRUE (status.ok ()) << status.error_message ();
808+ auto testFilePaths = CollectionUtils::getKeys (testGen.tests );
809+ EXPECT_TRUE (!testFilePaths.empty ()) << " Generated test files are missing." ;
810+ checkPointerReturn_C (testGen);
811+ }
812+
813+ TEST_F (Server_Test, Floating_Point) {
814+ auto [testGen, status] = performFeatureFileTestsRequest (floating_point_c);
815+ ASSERT_TRUE (status.ok ()) << status.error_message ();
816+ auto testFilePaths = CollectionUtils::getKeys (testGen.tests );
817+ EXPECT_TRUE (!testFilePaths.empty ()) << " Generated test files are missing." ;
818+ checkFloatingPoint_C (testGen);
819+ }
820+
821+ TEST_F (Server_Test, Floating_Point_plain) {
822+ auto [testGen, status] = performFeatureFileTestsRequest (floating_point_plain_c);
823+ ASSERT_TRUE (status.ok ()) << status.error_message ();
824+ auto testFilePaths = CollectionUtils::getKeys (testGen.tests );
825+ EXPECT_TRUE (!testFilePaths.empty ()) << " Generated test files are missing." ;
826+ checkFloatingPointPlain_C (testGen);
827+ }
828+
829+ TEST_F (Server_Test, Linkage) {
830+ auto [testGen, status] = performFeatureFileTestsRequest (linkage_c);
831+ ASSERT_TRUE (status.ok ()) << status.error_message ();
832+ auto testFilePaths = CollectionUtils::getKeys (testGen.tests );
833+ EXPECT_TRUE (!testFilePaths.empty ()) << " Generated test files are missing." ;
834+ checkLinkage (testGen);
835+ }
836+
837+ TEST_F (Server_Test, Globals) {
838+ auto [testGen, status] = performFeatureFileTestsRequest (globals_c);
839+ ASSERT_TRUE (status.ok ()) << status.error_message ();
840+ auto testFilePaths = CollectionUtils::getKeys (testGen.tests );
841+ EXPECT_TRUE (!testFilePaths.empty ()) << " Generated test files are missing." ;
842+ checkGlobals (testGen);
843+ }
844+
845+ TEST_F (Server_Test, Keywords) {
846+ auto [testGen, status] = performFeatureFileTestsRequest (keywords_c);
847+ ASSERT_TRUE (status.ok ()) << status.error_message ();
848+ auto testFilePaths = CollectionUtils::getKeys (testGen.tests );
849+ EXPECT_TRUE (!testFilePaths.empty ()) << " Generated test files are missing." ;
850+ checkKeywords (testGen);
851+ }
852+
853+
854+ TEST_F (Server_Test, Alignment) {
855+ auto [testGen, status] = performFeatureFileTestsRequest (alignment_c);
856+ ASSERT_TRUE (status.ok ()) << status.error_message ();
857+ auto testFilePaths = CollectionUtils::getKeys (testGen.tests );
858+ EXPECT_TRUE (!testFilePaths.empty ()) << " Generated test files are missing." ;
859+ checkAlignment (testGen);
860+ }
740861
741862 class Parameterized_Server_Test : public Server_Test ,
742863 public testing::WithParamInterface<std::tuple<CompilerName>> {
@@ -781,6 +902,9 @@ namespace {
781902 }
782903
783904 TEST_P (Parameterized_Server_Test, Project_Test) {
905+ std::string suite = " small-project" ;
906+ setSuite (suite);
907+ srcPaths = {suitePath, suitePath / " lib" , suitePath / " src" };
784908 auto request = createProjectRequest (projectName, suitePath, buildDirRelativePath, srcPaths);
785909 auto testGen = ProjectTestGen (*request, writer.get (), TESTMODE);
786910 testGen.setTargetForSource (testGen.testingMethodsSourcePaths [0 ]);
@@ -791,22 +915,11 @@ namespace {
791915 auto testFilePaths = CollectionUtils::getKeys (testGen.tests );
792916 EXPECT_TRUE (!testFilePaths.empty ()) << " Generated test files are missing." ;
793917
794- checkAssertionFailures_C (testGen);
795- checkBasicFunctions_C (testGen);
796- checkDependentFunctions_C (testGen);
797- checkInnerBasicFunctions_C (testGen);
798- checkSimpleStructs_C (testGen);
799- checkSimpleUnions_C (testGen);
800- checkPointerParameters_C (testGen);
801- checkTypes_C (testGen);
802- checkPointerReturn_C (testGen);
803- checkFloatingPoint_C (testGen);
804- checkFloatingPointPlain_C (testGen);
805- checkMathInclude (testGen);
806- checkLinkage (testGen);
807- checkGlobals (testGen);
808- checkKeywords (testGen);
809- checkAlignment (testGen);
918+ for (const auto &test : testGen.tests ) {
919+ for (const auto &[methodName, methodDescription] : test.second .methods ) {
920+ testUtils::checkMinNumberOfTests (methodDescription.testCases , 2 );
921+ }
922+ }
810923 }
811924
812925 TEST_P (Parameterized_Server_Test, File_Test) {
0 commit comments