aboutsummaryrefslogtreecommitdiff
path: root/src/tests/ktests/hashtbl2
diff options
context:
space:
mode:
authorAlex Auvolat <alex.auvolat@ens.fr>2015-02-14 19:15:43 +0100
committerAlex Auvolat <alex.auvolat@ens.fr>2015-02-14 19:15:43 +0100
commit1ca147f9e08202dfbc78692e204adac280f8238b (patch)
tree70cf40c14aae874bae814a9dcddbfdf5aba52079 /src/tests/ktests/hashtbl2
parent74ea640f40285220dfa93492a143a35426b867d1 (diff)
downloadkogata-1ca147f9e08202dfbc78692e204adac280f8238b.tar.gz
kogata-1ca147f9e08202dfbc78692e204adac280f8238b.zip
Rearrange testing architecture : just type 'make run_tests'
Diffstat (limited to 'src/tests/ktests/hashtbl2')
l---------src/tests/ktests/hashtbl2/Makefile1
-rw-r--r--src/tests/ktests/hashtbl2/test.c42
2 files changed, 43 insertions, 0 deletions
diff --git a/src/tests/ktests/hashtbl2/Makefile b/src/tests/ktests/hashtbl2/Makefile
new file mode 120000
index 0000000..4630a7c
--- /dev/null
+++ b/src/tests/ktests/hashtbl2/Makefile
@@ -0,0 +1 @@
+../rules.make \ No newline at end of file
diff --git a/src/tests/ktests/hashtbl2/test.c b/src/tests/ktests/hashtbl2/test.c
new file mode 100644
index 0000000..2441e79
--- /dev/null
+++ b/src/tests/ktests/hashtbl2/test.c
@@ -0,0 +1,42 @@
+#include <hashtbl.h>
+
+void test_hashtbl_2() {
+ BEGIN_TEST("test-hashtbl-2");
+
+ hashtbl_t *ht = create_hashtbl(id_key_eq_fun, id_hash_fun, 0);
+ ASSERT(ht != 0);
+
+ ASSERT(hashtbl_add(ht, (void*)12, "TESTSTR12"));
+ ASSERT(hashtbl_add(ht, (void*)777, "TESTSTR777"));
+
+ ASSERT(hashtbl_find(ht, (void*)12) != 0 &&
+ strcmp(hashtbl_find(ht, (void*)12), "TESTSTR12") == 0);
+ ASSERT(hashtbl_find(ht, (void*)777) != 0 &&
+ strcmp(hashtbl_find(ht, (void*)777), "TESTSTR777") == 0);
+ ASSERT(hashtbl_find(ht, (void*)144) == 0);
+
+ ASSERT(hashtbl_add(ht, (void*)144, "Forever alone"));
+
+ ASSERT(hashtbl_find(ht, (void*)12) != 0 &&
+ strcmp(hashtbl_find(ht, (void*)12), "TESTSTR12") == 0);
+ ASSERT(hashtbl_find(ht, (void*)144) != 0 &&
+ strcmp(hashtbl_find(ht, (void*)144), "Forever alone") == 0);
+ ASSERT(hashtbl_find(ht, (void*)777) != 0 &&
+ strcmp(hashtbl_find(ht, (void*)777), "TESTSTR777") == 0);
+
+ hashtbl_remove(ht, (void*)12);
+ ASSERT(hashtbl_find(ht, (void*)12) == 0);
+ ASSERT(hashtbl_find(ht, (void*)144) != 0 &&
+ strcmp(hashtbl_find(ht, (void*)144), "Forever alone") == 0);
+ ASSERT(hashtbl_find(ht, (void*)777) != 0 &&
+ strcmp(hashtbl_find(ht, (void*)777), "TESTSTR777") == 0);
+
+ delete_hashtbl(ht);
+
+ TEST_OK;
+}
+
+#undef TEST_PLACEHOLDER_AFTER_TASKING
+#define TEST_PLACEHOLDER_AFTER_TASKING { test_hashtbl_2(); }
+
+/* vim: set ts=4 sw=4 tw=0 noet :*/