Lookup tests.
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Wed, 10 Sep 2008 17:58:36 +0000 (19:58 +0200)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Wed, 10 Sep 2008 17:58:36 +0000 (19:58 +0200)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
common/tst-trie.c

index 20ca5e3..e5113b0 100644 (file)
@@ -46,6 +46,26 @@ int main(void)
     trie_insert(trie, "coucou");
     trie_insert(trie, "coucou chez vous");
     trie_inspect(trie);
+
+#define ASSERT_TRUE(str)                            \
+    if (!trie_lookup(trie, str)) {                  \
+        printf("\"%s\" not found in trie\n", str);  \
+        return 1;                                   \
+    }
+#define ASSERT_FALSE(str)                           \
+    if (trie_lookup(trie, str)) {                   \
+        printf("\"%s\" found in trie\n", str);      \
+        return 1;                                   \
+    }
+
+    ASSERT_FALSE("");
+    ASSERT_FALSE("coucou ");
+    ASSERT_FALSE("abcde123");
+    ASSERT_FALSE("abcde");
+    ASSERT_TRUE("abcdefghi");
+    ASSERT_TRUE("coucou");
+    ASSERT_FALSE("coucou chez vous tous");
+
     trie_delete(&trie);
     return 0;
 }