diff options
Diffstat (limited to 'src/encoding/json/stream_test.go')
| -rw-r--r-- | src/encoding/json/stream_test.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/encoding/json/stream_test.go b/src/encoding/json/stream_test.go index 0e937cfaa1..ba3bc4002b 100644 --- a/src/encoding/json/stream_test.go +++ b/src/encoding/json/stream_test.go @@ -459,6 +459,9 @@ func TestDecodeInStream(t *testing.T) { {CaseName: Name(""), json: ` \a`, expTokens: []any{ &SyntaxError{"invalid character '\\\\' looking for beginning of value", 1}, }}, + {CaseName: Name(""), json: `,`, expTokens: []any{ + &SyntaxError{"invalid character ',' looking for beginning of value", 0}, + }}, } for _, tt := range tests { t.Run(tt.Name, func(t *testing.T) { @@ -467,6 +470,15 @@ func TestDecodeInStream(t *testing.T) { var got any var err error + wantMore := true + switch want { + case Delim(']'), Delim('}'): + wantMore = false + } + if got := dec.More(); got != wantMore { + t.Fatalf("%s:\n\tinput: %s\n\tdec.More() = %v, want %v (next token: %T(%v))", tt.Where, tt.json, got, wantMore, want, want) + } + if dt, ok := want.(decodeThis); ok { want = dt.v err = dec.Decode(&got) |
