From b8a09ae02ddb97e854d82112dd8fcb6947c3c54a Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Fri, 28 Oct 2022 20:59:23 -0400 Subject: trie: Make leaves into a linked list --- tests/trie.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests/trie.c') diff --git a/tests/trie.c b/tests/trie.c index 0158fd8..6bc7549 100644 --- a/tests/trie.c +++ b/tests/trie.c @@ -82,6 +82,17 @@ int main(void) { assert(leaf->length == strlen(keys[i]) + 1); } + { + size_t i = 0; + TRIE_FOR_EACH(&trie, leaf) { + assert(leaf == trie_find_str(&trie, keys[i])); + assert(!leaf->prev || leaf->prev->next == leaf); + assert(!leaf->next || leaf->next->prev == leaf); + ++i; + } + assert(i == nkeys); + } + for (size_t i = 0; i < nkeys; ++i) { struct trie_leaf *leaf = trie_find_str(&trie, keys[i]); assert(leaf); @@ -110,6 +121,10 @@ int main(void) { } } + TRIE_FOR_EACH(&trie, leaf) { + assert(false); + } + // This tests the "jump" node handling on 32-bit platforms size_t longsize = 1 << 20; char *longstr = malloc(longsize); -- cgit v1.2.3