summaryrefslogtreecommitdiffstats
path: root/test/test_btree.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_btree.c')
-rw-r--r--test/test_btree.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/test_btree.c b/test/test_btree.c
index dd665c7..a87e26e 100644
--- a/test/test_btree.c
+++ b/test/test_btree.c
@@ -101,6 +101,23 @@ destroy(void* const ptr, const void* const user_data)
}
static void
+test_empty(void)
+{
+ ZixBTree* const t = zix_btree_new(NULL, int_cmp, NULL);
+ assert(t);
+
+ // Check that reading functions work properly with an empty (rootless) tree
+ const int e = 42;
+ ZixBTreeIter ti = zix_btree_end(t);
+ zix_btree_clear(t, NULL, NULL);
+ assert(!zix_btree_size(t));
+ assert(zix_btree_find(t, &e, &ti) == ZIX_STATUS_NOT_FOUND);
+ assert(!zix_btree_lower_bound(t, int_cmp, NULL, &e, &ti));
+
+ zix_btree_free(t, destroy, NULL);
+}
+
+static void
test_clear(void)
{
ZixBTree* t = zix_btree_new(NULL, int_cmp, NULL);
@@ -576,6 +593,7 @@ main(int argc, char** argv)
return EXIT_FAILURE;
}
+ test_empty();
test_clear();
test_free();
test_iter_comparison();