-
Notifications
You must be signed in to change notification settings - Fork 30
Closed
Labels
bugSomething isn't workingSomething isn't workingc-syntaxRelated to generation tests for CRelated to generation tests for CverifiedBug fix is verifiedBug fix is verifiedwrong generationInadequate or empty test suite generatedInadequate or empty test suite generated
Description
To Reproduce
Generate tests for following code sample:
struct WithAnonymous {
union {
int i, j;
};
int m;
};
int count_equal_members(struct WithAnonymous st) {
if (st.i == st.m) {
return 2;
}
return 1;
}
Resulting tests are:
TEST(regression, count_equal_members_test_1)
{
int actual = count_equal_members(from_bytes<WithAnonymous>({0, 0, 0, 0, 0, 0, 0, 0}));
EXPECT_EQ(2, actual);
}
TEST(regression, count_equal_members_test_2)
{
int actual = count_equal_members(from_bytes<WithAnonymous>({2, 0, 0, 0, 0, 0, 0, 0}));
EXPECT_EQ(1, actual);
}
Note that parameter initialized using from_bytes
function which doesn't look user friendly.
Expected that it would be initialized with explicit values
Similar to what is generated in case when union has identificator.
struct WithAnonymous {
union {
int i, j;
} io;
int m;
};
For sample above more readable tests are generated, where is from_bytes
is not used.
TEST(regression, count_equal_members_test_1)
{
int actual = count_equal_members({
.io = {
.i = 0
// .j = 0
},
.m = 0
});
EXPECT_EQ(2, actual);
}
TEST(regression, count_equal_members_test_2)
{
int actual = count_equal_members({
.io = {
.i = 2
// .j = 2
},
.m = 0
});
EXPECT_EQ(1, actual);
}
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingc-syntaxRelated to generation tests for CRelated to generation tests for CverifiedBug fix is verifiedBug fix is verifiedwrong generationInadequate or empty test suite generatedInadequate or empty test suite generated
Type
Projects
Status
Done