From d220f961e78461d2360c8c737d58b50bb769a80e Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Wed, 10 Sep 2008 19:58:36 +0200 Subject: [PATCH] Lookup tests. Signed-off-by: Florent Bruneau --- common/tst-trie.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/common/tst-trie.c b/common/tst-trie.c index 20ca5e3..e5113b0 100644 --- a/common/tst-trie.c +++ b/common/tst-trie.c @@ -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; } -- 2.20.1