Test a declared datatype over a column read, repeats counting as written, null alone on stdin, one leading slash, and the CLI's lone reference against the grammar

This commit is contained in:
2026-10-07 22:51:44 +02:00
committed by Lillem4n
parent 43c56b20b9
commit 1a022dbd79
11 changed files with 146 additions and 71 deletions
+10 -10
View File
@@ -175,22 +175,22 @@ func TestIsTemplate(t *testing.T) {
"{//sv_SE.person}": true,
"{/misc.currency[US Dollar (Next day)]}": true,
"/sv_SE.person": false,
"//sv_SE.person": false,
} {
if got, err := IsTemplate(arg); err != nil || got != want {
t.Errorf("IsTemplate(%q) = %v, %v; want %v", arg, got, err, want)
}
}
for arg, want := range map[string]string{
"[abc]": `starts with "["`,
"[abc].field": `starts with "["`,
"x[1]y": `"]"`,
"x[[1]]": `"["`,
"x[]": "empty",
"a]b": `holds a "]"`,
"a}b": `holds a "}"`,
`"abc`: `holds a "\""`,
`"a]b`: `holds a "\""`, // the opener the reader typed, not the bracket behind it
"[abc]": `starts with "["`,
"[abc].field": `starts with "["`,
"x[1]y": `"]"`,
"x[[1]]": `"["`,
"x[]": "empty",
"//sv_SE.person": "write /sv_SE.person",
"a]b": `holds a "]"`,
"a}b": `holds a "}"`,
`"abc`: `holds a "\""`,
`"a]b`: `holds a "\""`, // the opener the reader typed, not the bracket behind it
} {
if _, err := IsTemplate(arg); err == nil || !strings.Contains(err.Error(), want) {
t.Errorf("IsTemplate(%q) = %v; want it rejected naming %s", arg, err, want)