Test that the help's examples read no data and list the exit codes, a data path that is no directory says so in one shape, a choice suggests a record of one, a JSON syntax error names its line and column, and FakeStruct says no data is loaded

This commit is contained in:
2026-10-11 23:27:33 +02:00
committed by Lillem4n
parent 780586ad68
commit 1a7656d076
6 changed files with 44 additions and 12 deletions
+15
View File
@@ -0,0 +1,15 @@
package jsonvalue
import "testing"
func TestDecodeNamesTheLineAndColumnOfASyntaxError(t *testing.T) {
for in, want := range map[string]string{
"{\"a\": 1,}": "line 1, column 9: invalid character '}' looking for beginning of object key string",
"{\n \"a\": 1\n \"b\": 2\n}": "line 3, column 3: invalid character '\"' after object key:value pair",
"": "line 1, column 1: unexpected end of JSON input",
} {
if _, err := Decode([]byte(in)); err == nil || err.Error() != want {
t.Errorf("Decode(%q) = %v, want %q", in, err, want)
}
}
}