From: Sebastian Harl Date: Fri, 23 Aug 2013 19:03:25 +0000 (+0200) Subject: t/utils/llist_test: Added tests for clone and destroy. X-Git-Tag: sysdb-0.1.0~370 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=cc26ea7dbae4179b8e3f7728b4d3bb1525bedc48;p=sysdb.git t/utils/llist_test: Added tests for clone and destroy. --- diff --git a/t/utils/llist_test.c b/t/utils/llist_test.c index 82162c5..70b7cd3 100644 --- a/t/utils/llist_test.c +++ b/t/utils/llist_test.c @@ -78,6 +78,41 @@ populate(void) } } /* populate */ +START_TEST(test_clone) +{ + sdb_llist_t *clone; + int i; + + populate(); + + clone = sdb_llist_clone(list); + fail_unless(clone != NULL, + "sdb_llist_clone() = NULL; expected: !NULL"); + + for (i = 0; i < SDB_STATIC_ARRAY_LEN(golden_data); ++i) { + fail_unless(golden_data[i].ref_cnt == 3, + "sdb_llist_clone() did not take ownership"); + } + + sdb_llist_destroy(clone); +} +END_TEST + +START_TEST(test_destroy) +{ + int i; + populate(); + sdb_llist_destroy(list); + list = NULL; + + for (i = 0; i < SDB_STATIC_ARRAY_LEN(golden_data); ++i) { + fail_unless(golden_data[i].ref_cnt == 1, + "sdb_llist_destroy() did not deref element %s", + golden_data[i].name); + } +} +END_TEST + START_TEST(test_append) { int i; @@ -200,16 +235,19 @@ Suite * util_llist_suite(void) { Suite *s = suite_create("utils::llist"); + TCase *tc; - TCase *tc_core = tcase_create("core"); - tcase_add_checked_fixture(tc_core, setup, teardown); - tcase_add_test(tc_core, test_append); - tcase_add_test(tc_core, test_insert); - tcase_add_test(tc_core, test_insert_invalid); - tcase_add_test(tc_core, test_search); - tcase_add_test(tc_core, test_shift); - tcase_add_test(tc_core, test_iter); - suite_add_tcase(s, tc_core); + tc = tcase_create("core"); + tcase_add_checked_fixture(tc, setup, teardown); + tcase_add_test(tc, test_clone); + tcase_add_test(tc, test_destroy); + tcase_add_test(tc, test_append); + tcase_add_test(tc, test_insert); + tcase_add_test(tc, test_insert_invalid); + tcase_add_test(tc, test_search); + tcase_add_test(tc, test_shift); + tcase_add_test(tc, test_iter); + suite_add_tcase(s, tc); return s; } /* util_llist_suite */