UTBotCpp icon indicating copy to clipboard operation
UTBotCpp copied to clipboard

Support `scanf` function

Open tyuldashev opened this issue 3 years ago • 0 comments

Description In case code reads user input with scanf UTBot generates wrong regression tests which fails during execution

To Reproduce Generate tests for following function

int read_with_scanf() {
   int i;

   printf( "Enter a value :");
   scanf("%d", &i);

   return i;
}

Expected behavior Proper regression tests are generated, which could be successfully executed.

Actual behavior Generated test fails during execution

TEST(regression, read_with_scanf_test_1)
{
...
    // Expected output
    int expected = -1414812757;

    // Trigger the function
    int actual = read_with_scanf();

    // Check results
    EXPECT_EQ(expected, actual);
}

Additional info UTBot already supports getchar and getc so expectation is that similar approach could be applied to scanf.

tyuldashev avatar Oct 26 '22 14:10 tyuldashev