test: add test case of decode escaped string to empty interface

This commit is contained in:
Nao Yonashiro 2021-02-12 18:12:40 +09:00
parent c108435bc1
commit 10de43128b
1 changed files with 6 additions and 0 deletions

View File

@ -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))