Skip to content

No regression tests for array as function parameter [C standard test] #327

New issue

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

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

Already on GitHub? # to your account

Open
belous-dp opened this issue Jul 15, 2022 · 0 comments
Open
Labels
c-syntax Related to generation tests for C wrong generation Inadequate or empty test suite generated

Comments

@belous-dp
Copy link
Collaborator

Description
Regression tests weren't generated at all for lots of cases that contains array as a function parameter:

  1. array of fixed known size more than 10
  2. dynamic array (passed by pointer) of size more than 10
  3. 2d array of fixed known size more than 10
  4. dynamic array of fixed arrays of size more than 10
  5. dynamic array of dynamic arrays of size more than 10
    At the same time, some error tests were generated and most of them are passed without errors.

Source code

int sum_sign_1d_big(int a[12]) {
    int sum = 0;
    for (int i = 0; i < 12; i++) {
        sum += a[i];
        if (i % 2 == 0) {
            sum++;
        } else {
            sum--;
        }
    }
    if (sum == 0) {
        return 0;
    } else if (sum > 0) {
        return 1;
    } else {
        return -1;
    }
}

int sum_sign_1d_big_p(int *a) {
    int sum = 0;
    for (int i = 0; i < 12; i++) {
        sum += a[i];
        if (i % 2 == 0) {
            sum++;
        } else {
            sum--;
        }
    }
    if (sum == 0) {
        return 0;
    } else if (sum > 0) {
        return 1;
    } else {
        return -1;
    }
}

int sum_sign_9_11(int a[9][11]) {
    int sum = 0;
    for (int i = 0; i < 9; i++) {
        for (int j = 0; j < 11; j++) {
            sum += a[i][j];
        }
    }
    if (sum == 0) {
        return 0;
    } else if (sum > 0) {
        return 1;
    } else {
        return -1;
    }
}

int sum_sign_9_11_pp(int **a) {
    int sum = 0;
    for (int i = 0; i < 9; i++) {
        for (int j = 0; j < 11; j++) {
            sum += a[i][j];
        }
    }
    if (sum == 0) {
        return 0;
    } else if (sum > 0) {
        return 1;
    } else {
        return -1;
    }
}

int sum_sign_9_11_p(int (*a)[11]) {
    int sum = 0;
    for (int i = 0; i < 9; i++) {
        for (int j = 0; j < 11; j++) {
            sum += a[i][j];
        }
    }
    if (sum == 0) {
        return 0;
    } else if (sum > 0) {
        return 1;
    } else {
        return -1;
    }
}

Generated tests

TEST(error, sum_sign_1d_big_test_1) // weird but it PASSED
{
    int a[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    sum_sign_1d_big(a);
}

TEST(error, sum_sign_1d_big_p_test_1) // weird but it PASSED
{
    int a[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    sum_sign_1d_big_p(a);
}

TEST(error, sum_sign_9_11_test_1) // weird but it PASSED
{
    int a[2][11] = {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
    sum_sign_9_11(a);
}

TEST(error, sum_sign_9_11_pp_test_1) // actually ERROR, test is ok
{
    int _a[2][2] = {{0, 0}, {0, 0}};
    int ** a = (int **) calloc(3, sizeof(int *));
    for (int it_66_0 = 0; it_66_0 < 2; it_66_0 ++) {
        a[it_66_0] = _a[it_66_0];
    }
    a[2] = NULL;
    sum_sign_9_11_pp(a);
}

TEST(error, sum_sign_9_11_p_test_1) // weird but it PASSED
{
    int a[2][11] = {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
    sum_sign_9_11_p(a);
}

Environment
UTBotCpp version 2022.7.0.

@belous-dp belous-dp added the bug Something isn't working label Jul 15, 2022
@korifey korifey moved this to Todo in UTBot C/C++ Jul 15, 2022
@belous-dp belous-dp changed the title No regression tests for array as function parameter No regression tests for array as function parameter [C standard test] Jul 15, 2022
@ladisgin ladisgin added c-syntax Related to generation tests for C and removed bug Something isn't working labels Aug 29, 2022
@tyuldashev tyuldashev added the wrong generation Inadequate or empty test suite generated label Aug 31, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
c-syntax Related to generation tests for C wrong generation Inadequate or empty test suite generated
Projects
Status: Todo
Development

No branches or pull requests

3 participants