-
Notifications
You must be signed in to change notification settings - Fork 30
Closed
Labels
Description
Description
With looking identical initialization UTBot test gives different result of the test
To Reproduce
- Run test generation on following example
// extracted from integration-tests/c-example/lib/structures/simple_unions.c
union MainUnion {
union InnerUnion {
char c;
short s;
} inner;
int x;
long long y;
};
signed char operate_with_inner_unions(union MainUnion st) {
if (st.x == 5 || st.y == 5 || st.inner.c == '5' ||
st.inner.s == 5 ) {
return '5';
}
if (st.x == 5 || st.y == 102 || st.inner.s == 15) {
return st.inner.c;
}
return 'o';
}
- One of resulting tests looks like:
TEST(regression, operate_with_inner_unions_test_3)
{
signed char actual = operate_with_inner_unions({
// .inner = {
// .c = '\x0f'
// .s = 15
// }
// .x = 15
.y = 15LL
});
EXPECT_EQ('\x0f', actual);
}
- Comment initialization through
.y
and uncomment initialization with.s
, so test becomes
TEST(regression, operate_with_inner_unions_test_3)
{
signed char actual = operate_with_inner_unions({
.inner = {
// .c = '\x0f'
.s = 15
}
// .x = 15
// .y = 15LL
});
EXPECT_EQ('\x0f', actual);
}
- Run the test - it still green as expected.
- Comment line with
.s
and uncomment with.c
, so test becomes
TEST(regression, operate_with_inner_unions_test_3)
{
signed char actual = operate_with_inner_unions({
.inner = {
.c = '\x0f'
// .s = 15
}
// .x = 15
// .y = 15LL
});
EXPECT_EQ('\x0f', actual);
}
- Run the test again, now it fails with error:
Expected equality of these values:
'\x0f'
Which is: '\xF' (15)
actual
Which is: 'o' (111, 0x6F)
Expected that test still passes
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Done