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

@@ -51,3 +51,38 @@ cleanup:
hmapfree(lang->dict);
lang->dict = saved;
}
void
dictionary_misses_clear_result(struct ct *t)
{
static const struct {
char *name;
char *key;
char *pre;
} cases[] = {
{ "empty key", "", "empty-preedit" },
{ "missing key", "missing", "missing-preedit" },
};
Dictreq req;
Dictres res;
Hmap *saved;
Lang *lang;
int i;
lang = getlang(LangJP);
saved = lang->dict;
lang->dict = hmapalloc(1);
for(i = 0; i < nelem(cases); i++){
memset(&res, 0xa5, sizeof res);
req.key = mkstr(cases[i].key);
req.pre = mkstr(cases[i].pre);
req.lang = LangJP;
dictlookup(&req, &res);
if(res.nkouho != 0)
CT_ERRORF(t, "%s: want 0 candidates, got %d",
cases[i].name, res.nkouho);
checkstr(t, cases[i].name, cases[i].pre, &res.key);
}
hmapfree(lang->dict);
lang->dict = saved;
}