You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
structFParray {
float data[2];
};
structFParrayfp_array(int a) {
if (a < 0) {
structFParray res = {{1.23, 3.21}};
return res;
}
structFParray res = {{12.3, 32.1}};
return res;
}
Expected behavior
Tests are supposed to contain gtest assertions like EXPECT_, ASSERT_. For example, with the above source code I want to get tests like that:
TEST(regression, fp_array_test_1)
{
structFParray actual = fp_array(0);
structFParray expected = {
.data = {1.230000e+01, 3.210000e+01}};
EXPECT_EQ(sizeof(expected.data), sizeof(actual.data));
size_t n = 0;
if (sizeof(expected.data) > 0) {
EXPECT_EQ(sizeof(expected.data) / sizeof(expected.data[0]), sizeof(actual.data) / sizeof(actual.data[0]));
n = sizeof(expected.data) / sizeof(expected.data[0]);
}
for (int i = 0; i < n; i ++) {
EXPECT_NEAR(expected.data[i], actual.data[i], utbot_abs_error);
}
}
TEST(regression, fp_array_test_2) { ... }
Actual behavior
Instead, the generated tests do not contain any checks:
union MainUnion {
union InnerUnion {
union InInnerUnion {
unsignedint u;
longlong l;
};
char c;
union InInnerUnion ininner;
short s;
} inner;
int x;
// union InnerUnion inner;longlong y;
};
union MainUnion union_as_return_type(int a) {
if (a == 0) {
union MainUnion res = {{.c='0'}};
return res;
}
if (a == 1) {
union MainUnion res = {{.ininner={.l=1}}};
return res;
}
union MainUnion res = {.x=2};
return res;
}
Generated tests ("verbose formatting off):
TEST(regression, union_as_return_type_test_1)
{
union MainUnion actual = union_as_return_type(4);
union MainUnion expected = from_bytes<MainUnion>({2, 0, 0, 0, 0, 0, 0, 0});
}
TEST(regression, union_as_return_type_test_2)
{
union MainUnion actual = union_as_return_type(1);
union MainUnion expected = from_bytes<MainUnion>({1, 0, 0, 0, 0, 0, 0, 0});
}
TEST(regression, union_as_return_type_test_3)
{
union MainUnion actual = union_as_return_type(0);
union MainUnion expected = from_bytes<MainUnion>({48, 0, 0, 0, 0, 0, 0, 0});
}
belous-dp
changed the title
Tests without the assertions
Tests without the assertions [C standard test]
Jul 15, 2022
belous-dp
changed the title
Tests without the assertions [C standard test]
Tests without the assertions in short formatting [C standard test]
Jul 18, 2022
Lana243
changed the title
Tests without the assertions in short formatting [C standard test]
Tests without any checks [C standard test]
Jul 18, 2022
Description
Tests generated for functions with struct as return value don't contain assertions (
EXPECT_
,ASSERT_
).That happens only with "verbose formatting" disabled.
To Reproduce
Steps to reproduce the behavior:
fp_array
:Expected behavior
Tests are supposed to contain gtest assertions like
EXPECT_
,ASSERT_
. For example, with the above source code I want to get tests like that:Actual behavior
Instead, the generated tests do not contain any checks:
Behaviour with "verbose formatting" on
Generated tests:
Comments
The same thing happens with any function with a struct as a return value. Examples: simple_structs.c, complex_structs.c.
The same with unions:
Source code:
Generated tests ("verbose formatting off):
Maybe unions can be compared via memcmp.
Environment
UTBotCpp version 2022.7.0, tested locally using Docker+CLion+VSCode and tested online using utbot.
The text was updated successfully, but these errors were encountered: