strengthen core unit tests

Add table-driven dictionary miss and language-switch state coverage, regress stale candidates after backspace, and clear them before dictionary refresh. Keep IPC and runtime-created file checks outside the unit runner.
This commit is contained in:
2026-08-11 21:12:23 +09:00
parent 9b3f2c46f0
commit 82276bf37f
10 changed files with 149 additions and 464 deletions

View File

@@ -1,37 +1,5 @@
#include "test.h"
static void
checkcrlf(struct ct *t)
{
static char data[] = "crlf\tvalue\r\n";
char path[80], *v;
Trie *trie;
int fd, n;
snprint(path, sizeof path, "/tmp/strans-crlf-%d.map", getpid());
remove(path);
fd = create(path, OWRITE, 0600);
if(fd < 0){
CT_ERRORF(t, "cannot create CRLF fixture");
return;
}
if(write(fd, data, sizeof data - 1) != (long)(sizeof data - 1)){
CT_ERRORF(t, "cannot write CRLF fixture");
close(fd);
remove(path);
return;
}
close(fd);
trie = trieopen(path);
remove(path);
v = trieget(trie, "crlf", 4, &n);
if(CT_CHECK(t, v != nil)){
CT_EQ_INT(t, 5, n);
CT_EQ_MEM(t, "value", v, n);
}
trieclose(trie);
}
void
trie_exact_prefix_and_duplicate(struct ct *t)
{
@@ -64,7 +32,6 @@ trie_exact_prefix_and_duplicate(struct ct *t)
CT_EQ_PTR(t, nil, trieget(trie, "missing", 7, &n));
cleanup:
trieclose(trie);
checkcrlf(t);
}
void