aboutsummaryrefslogtreecommitdiff
path: root/src/tests/ktests/btree1
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/ktests/btree1')
l---------src/tests/ktests/btree1/Makefile1
-rw-r--r--src/tests/ktests/btree1/test.c41
2 files changed, 42 insertions, 0 deletions
diff --git a/src/tests/ktests/btree1/Makefile b/src/tests/ktests/btree1/Makefile
new file mode 120000
index 0000000..4630a7c
--- /dev/null
+++ b/src/tests/ktests/btree1/Makefile
@@ -0,0 +1 @@
+../rules.make \ No newline at end of file
diff --git a/src/tests/ktests/btree1/test.c b/src/tests/ktests/btree1/test.c
new file mode 100644
index 0000000..1207a28
--- /dev/null
+++ b/src/tests/ktests/btree1/test.c
@@ -0,0 +1,41 @@
+#include <btree.h>
+
+void test_btree_1() {
+ BEGIN_TEST("test-btree-1");
+
+ // hashtable test
+ btree_t *ht = create_btree(str_key_cmp_fun, 0);
+ ASSERT(ht != 0);
+
+ ASSERT(btree_add(ht, "test1", "STRTEST1"));
+ ASSERT(btree_add(ht, "test2", "STRTEST2"));
+ ASSERT(btree_find(ht, "test1") != 0 &&
+ strcmp(btree_find(ht, "test1"), "STRTEST1") == 0);
+ ASSERT(btree_find(ht, "test2") != 0 &&
+ strcmp(btree_find(ht, "test2"), "STRTEST2") == 0);
+ ASSERT(btree_find(ht, "test") == 0);
+
+ ASSERT(btree_add(ht, "test", "Forever alone"));
+ ASSERT(btree_find(ht, "test1") != 0 &&
+ strcmp(btree_find(ht, "test1"), "STRTEST1") == 0);
+ ASSERT(btree_find(ht, "test2") != 0 &&
+ strcmp(btree_find(ht, "test2"), "STRTEST2") == 0);
+ ASSERT(btree_find(ht, "test") != 0 &&
+ strcmp(btree_find(ht, "test"), "Forever alone") == 0);
+
+ btree_remove(ht, "test1");
+ ASSERT(btree_find(ht, "test1") == 0);
+ ASSERT(btree_find(ht, "test2") != 0 &&
+ strcmp(btree_find(ht, "test2"), "STRTEST2") == 0);
+ ASSERT(btree_find(ht, "test") != 0 &&
+ strcmp(btree_find(ht, "test"), "Forever alone") == 0);
+
+ delete_btree(ht);
+
+ TEST_OK;
+}
+
+#undef TEST_PLACEHOLDER_AFTER_TASKING
+#define TEST_PLACEHOLDER_AFTER_TASKING { test_btree_1(); }
+
+/* vim: set ts=4 sw=4 tw=0 noet :*/