From: Florent Bruneau Date: Wed, 10 Sep 2008 17:58:36 +0000 (+0200) Subject: Lookup tests. X-Git-Url: http://git.madism.org/?a=commitdiff_plain;h=d220f961e78461d2360c8c737d58b50bb769a80e;p=apps%2Fpfixtools.git Lookup tests. Signed-off-by: Florent Bruneau --- 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; }