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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user