Files
strans/tests/ko_test.c
Hojun-Cho 826da31486 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.
2026-08-16 16:25:40 +09:00

102 lines
2.3 KiB
C

#include "test.h"
static Str
kotrans(char *keys)
{
Str out, raw;
raw = mkstr(keys);
transstr(getlang(LangKO), &raw, &out);
return out;
}
void
korean_sequences(struct ct *t)
{
static const struct { char *keys, *want; } cases[] = {
{ "r", "" },
{ "rk", "" },
{ "rkr", "" },
{ "rkrk", "가가" },
{ "rkrtk", "각사" },
{ "rhk", "" },
{ "rr", "ㄱㄱ" },
{ "Rk", "" },
{ "rk1", "가1" },
};
Str out;
int i;
for(i = 0; i < nelem(cases); i++){
out = kotrans(cases[i].keys);
checkstr(t, cases[i].keys, cases[i].want, &out);
}
}
void
korean_compound_vowels(struct ct *t)
{
static const struct { char *keys, *want; } cases[] = {
{ "hk", "" }, { "ho", "" }, { "hl", "" },
{ "nj", "" }, { "np", "" }, { "nl", "" },
{ "ml", "" },
};
Str out;
int i;
for(i = 0; i < nelem(cases); i++){
out = kotrans(cases[i].keys);
checkstr(t, cases[i].keys, cases[i].want, &out);
}
}
void
korean_compound_finals(struct ct *t)
{
static const struct { char *keys, *want, *split; } cases[] = {
{ "rkrt", "", "각사" }, { "rksw", "", "간자" },
{ "rksg", "", "간하" }, { "rkfr", "", "갈가" },
{ "rkfa", "", "갈마" }, { "rkfq", "", "갈바" },
{ "rkft", "", "갈사" }, { "rkfx", "", "갈타" },
{ "rkfv", "", "갈파" }, { "rkfg", "", "갈하" },
{ "rkqt", "", "갑사" },
};
char keys[16];
Str out;
int i;
for(i = 0; i < nelem(cases); i++){
out = kotrans(cases[i].keys);
checkstr(t, cases[i].keys, cases[i].want, &out);
snprint(keys, sizeof keys, "%sk", cases[i].keys);
out = kotrans(keys);
checkstr(t, keys, cases[i].split, &out);
}
}
void
korean_backspace(struct ct *t)
{
static const struct { char *before, *after; } cases[] = {
{ "", "" },
{ "", "" },
{ "", "" }, { "", "" }, { "", "" },
{ "", "" }, { "", "" }, { "", "" },
{ "", "" },
{ "", "" },
{ "", "" }, { "", "" }, { "", "" },
{ "", "" }, { "", "" }, { "", "" },
{ "", "" }, { "", "" }, { "", "" },
{ "", "" }, { "", "" },
};
Im state;
int i;
memset(&state, 0, sizeof state);
for(i = 0; i < nelem(cases); i++){
state.pre = mkstr(cases[i].before);
backko(&state);
checkstr(t, cases[i].before, cases[i].after, &state.pre);
}
}