From 229339ecd55154c1d3a0a637a95d178268ba2d36 Mon Sep 17 00:00:00 2001 From: KimHyeonwoo Date: Mon, 18 Jul 2022 22:03:42 +0900 Subject: [PATCH] add more test --- decode_test.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/decode_test.go b/decode_test.go index 8c8561b..194c822 100644 --- a/decode_test.go +++ b/decode_test.go @@ -3986,17 +3986,22 @@ func TestIssue372(t *testing.T) { } } -type issue384 string +type issue384 struct{} func (t *issue384) UnmarshalJSON(b []byte) error { return nil } func TestIssue384(t *testing.T) { - in := "{\"data\":{\"text\": \"" + strings.Repeat("-", 492) + "\\\"\"}}\n" - dec := json.NewDecoder(strings.NewReader(in)) - var v issue384 - if err := dec.Decode(&v); err != nil { - t.Errorf("unexpected error: %v", err) + testcases := []string{ + "{\"data\":{\"text\": \"" + strings.Repeat("-", 492) + "\\\"\"}}\n", + "[\"" + strings.Repeat("-", 508) + "\\\"\"]", + } + for _, tc := range testcases { + dec := json.NewDecoder(strings.NewReader(tc)) + var v issue384 + if err := dec.Decode(&v); err != nil { + t.Errorf("unexpected error: %v", err) + } } }