From 10de43128b876381c790f45bdcc20bb1c1d0b447 Mon Sep 17 00:00:00 2001 From: Nao Yonashiro Date: Fri, 12 Feb 2021 18:12:40 +0900 Subject: [PATCH] test: add test case of decode escaped string to empty interface --- decode_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/decode_test.go b/decode_test.go index eb60c60..e8f9322 100644 --- a/decode_test.go +++ b/decode_test.go @@ -197,6 +197,12 @@ func Test_Decoder(t *testing.T) { assertEq(t, "interface.kind", "string", reflect.TypeOf(v).Kind().String()) assertEq(t, "interface", `hello`, fmt.Sprint(v)) }) + t.Run("escaped string", func(t *testing.T) { + var v interface{} + assertErr(t, json.Unmarshal([]byte(`"he\"llo"`), &v)) + assertEq(t, "interface.kind", "string", reflect.TypeOf(v).Kind().String()) + assertEq(t, "interface", `he"llo`, fmt.Sprint(v)) + }) t.Run("bool", func(t *testing.T) { var v interface{} assertErr(t, json.Unmarshal([]byte(`true`), &v))