summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2022-10-28 20:59:23 -0400
committerTavian Barnes <tavianator@tavianator.com>2022-10-29 11:24:19 -0400
commitb8a09ae02ddb97e854d82112dd8fcb6947c3c54a (patch)
treeff257d993a4fb295a19204c5a0968e750025e44e /tests
parentdd13a1deee5bda50e76046baa7290b4e0991feea (diff)
downloadbfs-b8a09ae02ddb97e854d82112dd8fcb6947c3c54a.tar.xz
trie: Make leaves into a linked list
Diffstat (limited to 'tests')
-rw-r--r--tests/trie.c15
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);