Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"pointer to pointer to function" weird behaviour [C standard test] #331

Open
belous-dp opened this issue Jul 19, 2022 · 1 comment
Open
Labels
bug Something isn't working

Comments

@belous-dp
Copy link
Collaborator

Description
Genereted regression test for function with pointer to pointer to function as a parameter fails.

To Reproduce
Steps to reproduce the behavior:

  1. Open the 'c-example/lib/pointers/function_pointers.c" file
  2. Generate tests for the 'pointerToPointer' function:
char pointerToPointer(int (**f)(int), char x) {
    if (f[0](5) == 4) {
        return x;
    } else {
        return 'z';
    }
}

Generated tests

TEST(regression, pointerToPointer_test_1)
{
    // Construct input
    pointerToPointer_f_arg f[10];
    for (int i = 0; i < 10; i ++) {
        f[i] = *_pointerToPointer_f_stub;
    }
    char x = 'c';



    // Expected output
    char expected = 'z';

    // Trigger the function
    char actual = pointerToPointer(f, x);

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

TEST(regression, pointerToPointer_test_2)
{
    // Construct input
    pointerToPointer_f_arg f[10];
    for (int i = 0; i < 10; i ++) {
        f[i] = *_pointerToPointer_f_stub;
    }
    char x = 'b';



    // Expected output
    char expected = 'b';

    // Trigger the function
    char actual = pointerToPointer(f, x);

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

The second regression test fails:

Expected equality of these values:
  expected
    Which is: 'b' (98, 0x62)
  actual
    Which is: 'z' (122, 0x7A)

Comments
Also creating array of 10 identical items and accessing only first of them looks strange and superfluously.

Environment
UTBotCpp version 2022.7.0.

@belous-dp belous-dp added the bug Something isn't working label Jul 19, 2022
@korifey korifey moved this to Todo in UTBot C/C++ Jul 19, 2022
@tyuldashev
Copy link
Collaborator

Another sample is array-sort.c. UTBot generates number of tests, but two from regression suite fail during execution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Todo
Development

No branches or pull requests

2 participants