From: Sebastian Harl Date: Tue, 8 Jul 2014 18:40:33 +0000 (+0200) Subject: avltree_test: Test duplicate detection and clear() as well. X-Git-Tag: sysdb-0.3.0~75 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=fd2791b86c34873d0891d74da492a18bed75b461;p=sysdb.git avltree_test: Test duplicate detection and clear() as well. --- diff --git a/t/unit/utils/avltree_test.c b/t/unit/utils/avltree_test.c index d978eff..3ca8054 100644 --- a/t/unit/utils/avltree_test.c +++ b/t/unit/utils/avltree_test.c @@ -127,6 +127,21 @@ START_TEST(test_insert) "sdb_avltree_size() = %d; expected: %zu", check, i + 1); } + + /* and again ... now reporting errors because of duplicates */ + for (i = 0; i < SDB_STATIC_ARRAY_LEN(test_data); ++i) { + int check; + + check = sdb_avltree_insert(tree, &test_data[i]); + fail_unless(check < 0, + "sdb_avltree_insert(, <%s>) = %d (redo); expected: <0", + test_data[i].name, check); + + check = (int)sdb_avltree_size(tree); + fail_unless(check == SDB_STATIC_ARRAY_LEN(test_data), + "sdb_avltree_size() = %d; expected: %zu", + check, SDB_STATIC_ARRAY_LEN(test_data)); + } } END_TEST @@ -171,6 +186,12 @@ START_TEST(test_iter) "sdb_avltree_iter_get_next() = ; expected: NULL"); sdb_avltree_iter_destroy(iter); + + sdb_avltree_clear(tree); + check = sdb_avltree_size(tree); + fail_unless(check == 0, + "sdb_avltree_clear() left %zu nodes in the tree; " + "expected: 0", check); } END_TEST