aboutsummaryrefslogtreecommitdiff
path: root/src/tests/ktests/btree1/test.c
diff options
context:
space:
mode:
authorAlex Auvolat <alex.auvolat@ens.fr>2015-02-14 19:34:49 +0100
committerAlex Auvolat <alex.auvolat@ens.fr>2015-02-14 19:34:49 +0100
commit8336422c8ad72b98e3af9c038468b62a9eafac3c (patch)
treeb35e74136b0263e6efbba41de8d1b118c2239b9b /src/tests/ktests/btree1/test.c
parent1ca147f9e08202dfbc78692e204adac280f8238b (diff)
downloadkogata-8336422c8ad72b98e3af9c038468b62a9eafac3c.tar.gz
kogata-8336422c8ad72b98e3af9c038468b62a9eafac3c.zip
Add first btree test ; fix first btree test.
Diffstat (limited to 'src/tests/ktests/btree1/test.c')
-rw-r--r--src/tests/ktests/btree1/test.c41
1 files changed, 41 insertions, 0 deletions
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 :*/