UTBotCpp icon indicating copy to clipboard operation
UTBotCpp copied to clipboard

Support incomplete types

Open Lana243 opened this issue 3 years ago • 2 comments

Steps to reproduce

  1. Open and configure project coreutils
  2. Choose target libcoreutils.a
  3. Generate tests for function di_set_free from gnulib/lib/di-set.c
  4. See generated tests.

Current result

Currently tests generated by UTBotCpp looks like the following:

TEST(error, di_set_free_test_1)
{
    struct di_set dis = {(struct hash_table *) 0xffffffc0, (struct ino_map *) 0xffffffff, (struct di_ent *) 0xffffffff};
    di_set_free(&dis);
    struct di_set expected_dis = {NULL, NULL, NULL};
}

TEST(error, di_set_free_test_2)
{
    struct di_set dis = {NULL, NULL, NULL};
    di_set_free(&dis);
    struct di_set expected_dis = {NULL, NULL, NULL};
}

Expected result

We would like UTBotCpp to generate tests that creates hash_table, ino_map and di_ent and passes pointers to them to di_set dis which is then used as an argument for di_set_free.

The main problem is that hash_table structure is declared in "hash.h" file but defined in "hash.c".

Lana243 avatar Apr 27 '22 15:04 Lana243

To learn more about the issue see: https://github.com/UnitTestBot/UTBotCpp/issues/154

Lana243 avatar Apr 27 '22 15:04 Lana243

Instead of coreutils you can reproduce this case using UTBotCpp unit tests.

Steps to reproduce

  1. Open and configure project server/test/suites/regression
  2. Generate tests for sum_double_pairs function from file PR-200/PR-200.cpp
  3. See generated tests

Current result

TEST(regression, sum_double_pairs_test_1)
{
    struct double_pair p = {NULL, NULL};
    int actual = sum_double_pairs(&p);
    EXPECT_EQ(0, actual);
    struct double_pair expected_p = {NULL, NULL};
}

TEST(error, sum_double_pairs_test_2)
{
    struct double_pair p = {(struct pair *) 0xff, NULL};
    sum_double_pairs(&p);
    struct double_pair expected_p = {NULL, NULL};
}

Expected result

We would like UTBotCpp to generate tests that creates two structs pair and passes pointers to them to double_pair which is then used as an argument for sum_double_pairs.

The main problem is that pair structure is declared in "pair.h" file but defined in "pair.c".

Lana243 avatar Apr 27 '22 15:04 Lana243