Files
strans/tests/vi_test.c
Hojun-Cho e860008d84 fix(telex): know the rimes Telex needs, and put the ưa tone on ư
The map is the syllable grammar: a key sequence stays pending only
while it is a prefix of some entry, so a rime the table lacked split
the syllable and a trailing tone key landed on the wrong letter (vowis
gave vơí, rooif rôì, thaays thâý), ua+tone was a valueless prefix that
committed the raw keys (cuar gave cuar, muaf muaf), uyê and ươ typed as
uwow took no coda (nguyễn, được), and ưa toned the a (cửa gave cưả).
Add âu ây êu ôi ơi eo ia ưi ưu uê ươu uây oeo uya uyu, the uyê, uwow,
uê and oe codas, and tone ưa on ư.
2026-08-16 20:30:21 +09:00

79 lines
1.6 KiB
C

#include "dat.h"
#include "fn.h"
#include "test.h"
static void
typevi(struct ct *t, char *keys, char *want)
{
Str out, raw;
raw = mkstr(keys);
transstr(&testvi, &raw, &out);
checkstr(t, keys, want, &out);
}
void
vietnamese_transitions(struct ct *t)
{
static const struct { char *keys, *want; } cases[] = {
{ "as", "á" },
{ "As", "Á" },
{ "ans", "án" },
{ "Ans", "Án" },
{ "aws", "" },
{ "asw", "" },
{ "aww", "aw" },
{ "ddd", "dd" },
{ "ddas", "đá" },
{ "dds", "đs" },
{ "quas", "quá" },
{ "quaf", "quà" },
{ "quar", "quả" },
{ "quax", "quã" },
{ "quaj", "quạ" },
{ "Quas", "Quá" },
{ "gias", "giá" },
{ "Gias", "Giá" },
{ "gif", "" },
{ "cuar", "của" },
{ "vowis", "với" },
{ "cuwar", "cửa" },
{ "nguyeenx", "nguyễn" },
{ "dduwowngf", "đường" },
{ "\\s", "s" },
{ "a\\s", "as" },
};
int i;
for(i = 0; i < nelem(cases); i++)
typevi(t, cases[i].keys, cases[i].want);
}
void
vietnamese_backspace(struct ct *t)
{
static const struct {
char *pre, *raw, *rawafter, *after;
} cases[] = {
{ "as", "as", "a", "a" },
{ "quá", "quas", "qua", "qua" },
{ "à", "asf", "as", "á" },
{ "a", "asz", "as", "á" },
{ "quà", "quasf", "quas", "quá" },
};
Im state;
Str shown;
int i;
for(i = 0; i < nelem(cases); i++){
memset(&state, 0, sizeof state);
state.l = &testvi;
state.pre = mkstr(cases[i].pre);
state.raw = mkstr(cases[i].raw);
backvi(&state);
checkstr(t, cases[i].raw, cases[i].rawafter, &state.raw);
impre(&state, &shown);
checkstr(t, cases[i].raw, cases[i].after, &shown);
}
}