fix: harden small core containers

This commit is contained in:
2026-08-12 15:54:16 +09:00
parent cec62cc40f
commit 103f2ec448
11 changed files with 136 additions and 18 deletions

View File

@@ -34,6 +34,29 @@ cleanup:
trieclose(trie);
}
void
trie_optional_outputs_and_invalid_lengths(struct ct *t)
{
char *v;
Trie *trie;
int n;
trie = trieopen("data/trie.map");
CT_CHECK(t, trieget(trie, "a", 1, nil) != nil);
v = nil;
CT_CHECK(t, trielookup(trie, "a", 1, &v, nil));
CT_CHECK(t, v != nil);
n = -1;
CT_CHECK(t, trielookup(trie, "a", 1, nil, &n));
CT_EQ_INT(t, 5, n);
CT_CHECK(t, trielookup(trie, "dupli", 5, nil, nil));
CT_EQ_PTR(t, nil, trieget(trie, nil, 1, &n));
CT_EQ_PTR(t, nil, trieget(trie, "a", -1, &n));
CT_CHECK(t, !trielookup(trie, nil, 1, &v, &n));
CT_CHECK(t, !trielookup(trie, "a", -1, &v, &n));
trieclose(trie);
}
void
production_maps_load(struct ct *t)
{