test uc_htable_clear. Add comments, fix uc_htable_next
This commit is contained in:
@@ -64,6 +64,8 @@ START_TEST (test_htable1)
|
||||
fail_if(my_find(&table, "Four", hash_str("Four")) != &str[3]);
|
||||
fail_if(my_find(&table, "Five", hash_str("Five")) != &str[4]);
|
||||
|
||||
uc_htable_destroy(&table);
|
||||
|
||||
END_TEST
|
||||
|
||||
START_TEST (test_htable_hash_collision)
|
||||
@@ -92,6 +94,8 @@ START_TEST (test_htable_hash_collision)
|
||||
fail_if(my_find(&table, "..", bad_hash("..")) != &str[3]);
|
||||
fail_if(my_find(&table, "...", bad_hash("...")) != &str[0]);
|
||||
|
||||
uc_htable_destroy(&table);
|
||||
|
||||
END_TEST
|
||||
|
||||
START_TEST (test_htable_resize)
|
||||
@@ -125,6 +129,7 @@ START_TEST (test_htable_resize)
|
||||
fail_if(my_find(&table, "Four", hash_str("Four")) != &str[3]);
|
||||
fail_if(my_find(&table, "Five", hash_str("Five")) != &str[4]);
|
||||
|
||||
uc_htable_destroy(&table);
|
||||
|
||||
END_TEST
|
||||
|
||||
@@ -140,6 +145,8 @@ START_TEST (test_htable_fail_init_resize)
|
||||
rc = uc_htable_resize(&table, 0);
|
||||
ck_assert_int_ne(rc, 0);
|
||||
|
||||
uc_htable_destroy(&table);
|
||||
|
||||
END_TEST
|
||||
|
||||
START_TEST (test_htable_has_node)
|
||||
@@ -161,6 +168,8 @@ START_TEST (test_htable_has_node)
|
||||
rc = uc_htable_has_node(&table, &str2.node);
|
||||
ck_assert_int_eq(rc, 0);
|
||||
|
||||
uc_htable_destroy(&table);
|
||||
|
||||
END_TEST
|
||||
|
||||
START_TEST (test_htable_remove)
|
||||
@@ -204,6 +213,30 @@ START_TEST (test_htable_remove)
|
||||
//this one should still be here
|
||||
fail_if(my_find(&table, "Other", hash_str("Other")) != &str3);
|
||||
|
||||
uc_htable_destroy(&table);
|
||||
|
||||
END_TEST
|
||||
|
||||
START_TEST (test_htable_clear)
|
||||
struct MyString str1 = {"One", {0,NULL}};
|
||||
|
||||
struct UHTable table;
|
||||
int rc;
|
||||
|
||||
rc = uc_htable_init(&table, 100);
|
||||
ck_assert_int_eq(rc, 0);
|
||||
|
||||
uc_htable_insert(&table, &str1.node, hash_str(str1.str));
|
||||
ck_assert_int_eq(uc_htable_count(&table), 1);
|
||||
|
||||
fail_if(my_find(&table, "One", hash_str("One")) != &str1);
|
||||
|
||||
uc_htable_clear(&table);
|
||||
ck_assert_int_eq(uc_htable_count(&table), 0);
|
||||
fail_if(my_find(&table, "One", hash_str("One")) != NULL);
|
||||
|
||||
uc_htable_destroy(&table);
|
||||
|
||||
END_TEST
|
||||
|
||||
Suite *htable_suite(void)
|
||||
@@ -217,6 +250,7 @@ Suite *htable_suite(void)
|
||||
tcase_add_test(tc, test_htable_fail_init_resize);
|
||||
tcase_add_test(tc, test_htable_has_node);
|
||||
tcase_add_test(tc, test_htable_remove);
|
||||
tcase_add_test(tc, test_htable_clear);
|
||||
|
||||
|
||||
suite_add_tcase(s, tc);
|
||||
|
||||
Reference in New Issue
Block a user