Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
IDKWNTCMF committed Aug 17, 2023
1 parent dd1d04b commit c2c2cdd
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 32 deletions.
34 changes: 2 additions & 32 deletions server/test/framework/Server_Tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,35 +456,6 @@ namespace {
}
}

void checkStructWithUnion_C(BaseTestGen &testGen) {
for (const auto &[methodName, methodDescription] :
testGen.tests.at(struct_with_union_c).methods) {
if (methodName == "struct_with_union_of_unnamed_type_as_return_type") {
checkTestCasePredicates(
methodDescription.testCases,
std::vector<TestCasePredicate>(
{[] (const tests::Tests::MethodTestCase& testCase) {
return stoi(testCase.paramValues[0].view->getEntryValue(nullptr)) <
stoi(testCase.paramValues[1].view->getEntryValue(nullptr)) &&
testCase.returnValue.view->getEntryValue(nullptr) == "{{{'\\x99', -2.530171e-98}}}";
},
[] (const tests::Tests::MethodTestCase& testCase) {
return stoi(testCase.paramValues[0].view->getEntryValue(nullptr)) ==
stoi(testCase.paramValues[1].view->getEntryValue(nullptr)) &&
StringUtils::startsWith(testCase.returnValue.view->getEntryValue(nullptr),
"{from_bytes<StructWithUnionOfUnnamedType_un>({");
},
[] (const tests::Tests::MethodTestCase& testCase) {
return stoi(testCase.paramValues[0].view->getEntryValue(nullptr)) >
stoi(testCase.paramValues[1].view->getEntryValue(nullptr)) &&
testCase.returnValue.view->getEntryValue(nullptr) == "{{{'\\0', -2.530171e-98}}}";
}
}),
methodName);
}
}
}

void checkInnerBasicFunctions_C(BaseTestGen &testGen) {
for (const auto &[methodName, methodDescription] :
testGen.tests.at(inner_basic_functions_c).methods) {
Expand Down Expand Up @@ -2187,8 +2158,7 @@ namespace {
auto testGen = FileTestGen(*request, writer.get(), TESTMODE);
Status status = Server::TestsGenServiceImpl::ProcessBaseTestRequest(testGen, writer.get());
ASSERT_TRUE(status.ok()) << status.error_message();
EXPECT_GE(testUtils::getNumberOfTests(testGen.tests), 3);
checkStructWithUnion_C(testGen);
EXPECT_GE(testUtils::getNumberOfTests(testGen.tests), 6);

fs::path testsDirPath = getTestFilePath("tests");

Expand Down Expand Up @@ -2252,7 +2222,7 @@ namespace {
auto resultsMap = coverageGenerator.getTestResultMap();
auto tests = coverageGenerator.getTestsToLaunch();

StatusCountMap expectedStatusCountMap{ { testsgen::TEST_PASSED, 3 } };
StatusCountMap expectedStatusCountMap{ { testsgen::TEST_PASSED, 6 } };
testUtils::checkStatuses(resultsMap, tests);
}

Expand Down
13 changes: 13 additions & 0 deletions server/test/suites/server/struct_with_union.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,17 @@ struct StructWithUnionOfUnnamedType struct_with_union_of_unnamed_type_as_return_
ans.un.ds.d = 1.0101;
}
return ans;
}

struct StructWithAnonymousUnion struct_with_anonymous_union_as_return_type(int a, int b) {
struct StructWithAnonymousUnion ans;
if (a > b) {
ans.ptr = 0;
} else if (a < b) {
ans.x = 153;
} else {
ans.c = 'k';
ans.d = 1.0101;
}
return ans;
}
13 changes: 13 additions & 0 deletions server/test/suites/server/struct_with_union.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,19 @@ struct StructWithUnionOfUnnamedType {
} un;
};

struct StructWithAnonymousUnion {
union {
int x;
struct {
char c;
double d;
};
long long *ptr;
};
};

struct StructWithUnionOfUnnamedType struct_with_union_of_unnamed_type_as_return_type(int a, int b);

struct StructWithAnonymousUnion struct_with_anonymous_union_as_return_type(int a, int b);

#endif // SIMPLE_TEST_PROJECT_STRUCT_WITH_UNION_H

0 comments on commit c2c2cdd

Please sign in to comment.