diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2022-10-28 20:59:23 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2022-10-29 11:24:19 -0400 |
commit | b8a09ae02ddb97e854d82112dd8fcb6947c3c54a (patch) | |
tree | ff257d993a4fb295a19204c5a0968e750025e44e /tests/trie.c | |
parent | dd13a1deee5bda50e76046baa7290b4e0991feea (diff) | |
download | bfs-b8a09ae02ddb97e854d82112dd8fcb6947c3c54a.tar.xz |
trie: Make leaves into a linked list
Diffstat (limited to 'tests/trie.c')
-rw-r--r-- | tests/trie.c | 15 |
1 files changed, 15 insertions, 0 deletions
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); |