You've already forked json-iterator
mirror of
https://github.com/json-iterator/go.git
synced 2025-11-29 22:47:28 +02:00
#34 implement NewEncoder
This commit is contained in:
@@ -31,4 +31,16 @@ func Test_new_decoder(t *testing.T) {
|
||||
should.Nil(decoder2.Decode(&arr2))
|
||||
should.Equal([]int{2}, arr2)
|
||||
should.False(decoder2.More())
|
||||
}
|
||||
|
||||
func Test_new_encoder(t *testing.T) {
|
||||
should := require.New(t)
|
||||
buf1 := &bytes.Buffer{}
|
||||
encoder1 := json.NewEncoder(buf1)
|
||||
encoder1.Encode([]int{1})
|
||||
should.Equal("[1]\n", buf1.String())
|
||||
buf2 := &bytes.Buffer{}
|
||||
encoder2 := NewEncoder(buf2)
|
||||
encoder2.Encode([]int{1})
|
||||
should.Equal("[1]", buf2.String())
|
||||
}
|
||||
Reference in New Issue
Block a user