Files
strans/tests/ko_test.c
Hojun-Cho 795f11be22 test: one engine pump and one preedit check for the white-box suites
server_test, ibus_test and xim_adapter_test each ran their own copy of
the same alt loop that stands in for imthread, and two of them had
private checkstr/checkenginepreedit variants. test_util.c now provides
Pump (trace, optional hold on a chosen op, stop) in its own proc so a
test may block in socket I/O while the engine runs, and test.h declares
the engine hooks once; every .c includes dat.h and fn.h itself as the
rest of the tree does. server_test's three copies of fixture setup and
teardown became serverbegin/serverend.
2026-08-16 16:30:32 +09:00

104 lines
2.4 KiB
C

#include "dat.h"
#include "fn.h"
#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);
}
}