From 14c828aad77095f5eb13ce04f4feee6f3bd3bda1 Mon Sep 17 00:00:00 2001 From: Masaaki Goshima Date: Wed, 2 Jun 2021 19:01:41 +0900 Subject: [PATCH] Add test case for stream decoder --- decode_test.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/decode_test.go b/decode_test.go index 8298a1f..f3c2622 100644 --- a/decode_test.go +++ b/decode_test.go @@ -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") + } + }) }