Add test case for stream decoder

This commit is contained in:
Masaaki Goshima 2021-06-02 19:01:41 +09:00
parent c128c8c915
commit 14c828aad7
1 changed files with 11 additions and 0 deletions

View File

@ -3608,4 +3608,15 @@ func TestDecodeEscapedCharField(t *testing.T) {
t.Fatal("failed to decode unicode char")
}
})
t.Run("stream", func(t *testing.T) {
v := struct {
Msg string `json:"消息"`
}{}
if err := json.NewDecoder(bytes.NewBuffer(b)).Decode(&v); err != nil {
t.Fatal(err)
}
if !bytes.Equal([]byte(v.Msg), []byte("消息")) {
t.Fatal("failed to decode unicode char")
}
})
}