test: drive Korean and Vietnamese through the engine's own transstr

ko_test and vi_test replayed keys with private copies of transstr's
loop, and test_util reimplemented the shown preedit; the engine exports
impre(Im*, Str*) and transstr() instead, so a change to composition
rules is one edit.
This commit is contained in:
2026-08-16 16:25:40 +09:00
parent 849bf1278b
commit 826da31486
7 changed files with 32 additions and 78 deletions

View File

@@ -5,7 +5,6 @@ extern Lang testvi;
Str mkstr(char*);
int checkstr(struct ct*, char*, char*, Str*);
Str shownpre(Im*);
static int typekeys(struct ct*, char*, Str*);
static int draindraw(Drawcmd*);
@@ -43,7 +42,7 @@ testengineowner(void)
void
testenginepreedit(Str *preedit)
{
impre(preedit);
impre(&im, preedit);
}
void
@@ -116,7 +115,7 @@ engine_backspace_clears_candidates(struct ct *t)
sclear(&com);
CT_CHECK(t, keystroke('n', 0, &com));
CT_CHECK(t, keystroke('a', 0, &com));
shown = shownpre(&im);
impre(&im, &shown);
checkstr(t, "before backspace", "", &shown);
im.kouho[0] = mkstr("stale-candidate");
im.nkouho = 1;
@@ -124,7 +123,7 @@ engine_backspace_clears_candidates(struct ct *t)
CT_CHECK(t, keystroke(Kback, 0, &com));
checkstr(t, "backspace commit", "", &com);
checkstr(t, "pending romaji after backspace", "n", &im.raw);
shown = shownpre(&im);
impre(&im, &shown);
checkstr(t, "shown preedit after backspace", "", &shown);
CT_EQ_INT(t, 0, im.nkouho);
CT_EQ_INT(t, -1, im.sel);
@@ -238,7 +237,7 @@ engine_active_owner_lifecycle(struct ct *t)
CT_EQ_PTR(t, &b, activeowner);
res = ownerrequest(&a, Keyreset, 0, 0);
CT_EQ_INT(t, 0, res.preedit.n);
shown = shownpre(&im);
impre(&im, &shown);
checkstr(t, "stale reset preserves owner", "", &shown);
CT_EQ_PTR(t, &b, activeowner);
@@ -246,7 +245,7 @@ engine_active_owner_lifecycle(struct ct *t)
res = ownerrequest(&b, Keypress, 'a', 0);
checkstr(t, "current owner continues", "にゃ", &res.preedit);
ownerrequest(&a, Keyrelease, 0, 0);
shown = shownpre(&im);
impre(&im, &shown);
checkstr(t, "stale release preserves owner", "にゃ", &shown);
CT_EQ_PTR(t, &b, activeowner);
@@ -1074,7 +1073,7 @@ engine_japanese_readings(struct ct *t)
if(!typekeys(t, cases[i].keys, &com))
continue;
checkstr(t, cases[i].keys, "", &com);
shown = shownpre(&im);
impre(&im, &shown);
checkstr(t, cases[i].keys, cases[i].want, &shown);
CT_CHECK(t, keystroke(Kret, 0, &com));
checkstr(t, "committed reading", cases[i].want, &com);
@@ -1102,7 +1101,7 @@ engine_japanese_candidates(struct ct *t)
sclear(&com);
if(!typekeys(t, "kanji", &com))
goto cleanup;
shown = shownpre(&im);
impre(&im, &shown);
checkstr(t, "complete Japanese reading", "かんじ", &shown);
if(!CT_EQ_INT(t, 2, im.nkouho))
goto cleanup;
@@ -1138,13 +1137,13 @@ engine_japanese_backspace_and_boundaries(struct ct *t)
sclear(&com);
if(typekeys(t, "kanji", &com)){
CT_CHECK(t, keystroke(Kback, 0, &com));
shown = shownpre(&im);
impre(&im, &shown);
checkstr(t, "backspace pending i", "かんj", &shown);
CT_CHECK(t, keystroke(Kback, 0, &com));
shown = shownpre(&im);
impre(&im, &shown);
checkstr(t, "backspace pending j", "かん", &shown);
CT_CHECK(t, keystroke(Kback, 0, &com));
shown = shownpre(&im);
impre(&im, &shown);
checkstr(t, "backspace accumulated kana", "", &shown);
}
@@ -1198,7 +1197,7 @@ engine_katakana_sequences(struct ct *t)
if(!typekeys(t, cases[i].keys, &com))
continue;
checkstr(t, cases[i].keys, "", &com);
shown = shownpre(&im);
impre(&im, &shown);
checkstr(t, cases[i].keys, cases[i].want, &shown);
CT_EQ_INT(t, 0, im.nkouho);
CT_CHECK(t, keystroke(Kret, 0, &com));
@@ -1492,7 +1491,7 @@ engine_emoji_preedit_languages(struct ct *t)
sclear(&com);
if(typekeys(t, "ka", &com)){
CT_CHECK(t, !keystroke(Kmodfirst+2, 0, &com));
shown = shownpre(&im);
impre(&im, &shown);
checkstr(t, "modifier preserves Japanese", "", &shown);
CT_CHECK(t, keystroke('E', Mctrl|Mshift, &com));
checkstr(t, "committed Japanese preedit", "", &com);
@@ -1513,7 +1512,7 @@ engine_emoji_preedit_languages(struct ct *t)
CT_CHECK(t, !search.lang);
sclear(&com);
if(typekeys(t, "na", &com)){
shown = shownpre(&im);
impre(&im, &shown);
checkstr(t, "Japanese resumed", "", &shown);
}
}
@@ -1544,7 +1543,7 @@ engine_emoji_preedit_languages(struct ct *t)
CT_EQ_PTR(t, &testvi, im.l);
sclear(&com);
if(typekeys(t, "as", &com)){
shown = shownpre(&im);
impre(&im, &shown);
checkstr(t, "Telex resumed", "á", &shown);
checkstr(t, "Telex raw resumed", "as", &im.raw);
}