UTBotCpp
UTBotCpp copied to clipboard
`write_to_file` should be part of 'Construct input' section
Description In verbose mode lines which create test input files should be part of 'Construct input' section instead of being outside of any section.
To Reproduce Steps to reproduce the behavior:
- Enable UTBot Verbose Formatting mode
- Generate tests for code which are using files, for instance use following code (extraction from
c-examples/file.c):
int file_fgets(FILE *fA) {
char a[8];
fgets(a, 6, fA);
if (a[0] == 'u' && a[1] == 't' && a[2] == 'b' && a[3] == 'o' && a[4] == 't') {
return 1;
}
return 0;
}
Actual behavior Generated tests start with following code:
TEST(regression, file_fgets_test_1)
{
write_to_file("../../../tests/src/A", "ut\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n");
write_to_file("../../../tests/src/B", "\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0");
write_to_file("../../../tests/src/C", "\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0");
struct _IO_FILE * fA = (UTBot::FILE *) fopen("../../../tests/src/A", "r");
// Construct input
// Expected output
int expected = 0;
...
Expected behavior
File preparation is right below // Construct input comment, so it looks like:
TEST(regression, file_fgets_test_1)
{
// Construct input
write_to_file("../../../tests/src/A", "ut\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n""\n");
write_to_file("../../../tests/src/B", "\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0");
write_to_file("../../../tests/src/C", "\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0");
struct _IO_FILE * fA = (UTBot::FILE *) fopen("../../../tests/src/A", "r");
// Expected output
int expected = 0;
...