engine: reject stale dictionary results
This commit is contained in:
@@ -22,10 +22,12 @@ dictionary_candidates(struct ct *t)
|
||||
req.key = key;
|
||||
req.pre = mkstr("preedit-one");
|
||||
req.lang = LangJP;
|
||||
req.seq = 17;
|
||||
dictlookup(&req, &res);
|
||||
if(!CT_EQ_INT(t, 2, res.nkouho))
|
||||
goto cleanup;
|
||||
CT_EQ_INT(t, LangJP, res.lang);
|
||||
CT_EQ_UINT(t, 17, res.seq);
|
||||
CT_EQ_INT(t, 0, scmp(&req.pre, &res.key));
|
||||
checkstr(t, "candidate 1", "候補1", &res.kouho[0]);
|
||||
checkstr(t, "candidate 2", "候補2", &res.kouho[1]);
|
||||
@@ -42,10 +44,12 @@ dictionary_candidates(struct ct *t)
|
||||
hmapset(&lang->dict, &key, many, strlen(many));
|
||||
req.key = key;
|
||||
req.pre = mkstr("preedit-two");
|
||||
req.seq = 29;
|
||||
dictlookup(&req, &res);
|
||||
if(!CT_EQ_INT(t, Maxkouho, res.nkouho))
|
||||
goto cleanup;
|
||||
CT_EQ_INT(t, LangJP, res.lang);
|
||||
CT_EQ_UINT(t, 29, res.seq);
|
||||
CT_EQ_INT(t, 0, scmp(&req.pre, &res.key));
|
||||
checkstr(t, "first capped candidate", "c00", &res.kouho[0]);
|
||||
checkstr(t, "last capped candidate", "c31", &res.kouho[31]);
|
||||
@@ -79,11 +83,13 @@ dictionary_misses_clear_result(struct ct *t)
|
||||
req.key = mkstr(cases[i].key);
|
||||
req.pre = mkstr(cases[i].pre);
|
||||
req.lang = LangJP;
|
||||
req.seq = 0xf00d0000U + i;
|
||||
dictlookup(&req, &res);
|
||||
if(res.nkouho != 0)
|
||||
CT_ERRORF(t, "%s: want 0 candidates, got %d",
|
||||
cases[i].name, res.nkouho);
|
||||
CT_EQ_INT(t, LangJP, res.lang);
|
||||
CT_EQ_UINT(t, 0xf00d0000U + i, res.seq);
|
||||
checkstr(t, cases[i].name, cases[i].pre, &res.key);
|
||||
}
|
||||
hmapfree(lang->dict);
|
||||
@@ -108,6 +114,7 @@ dictionary_emoji_identity(struct ct *t)
|
||||
req.key = key;
|
||||
req.pre = key;
|
||||
req.lang = LangEMOJI;
|
||||
req.seq = 0;
|
||||
dictlookup(&req, &res);
|
||||
if(CT_EQ_INT(t, 1, res.nkouho))
|
||||
checkstr(t, "emoji identity candidate", "é", &res.kouho[0]);
|
||||
|
||||
Reference in New Issue
Block a user