1
0
mirror of https://github.com/json-iterator/go.git synced 2025-06-15 22:50:24 +02:00

#34 add decoder adapter

This commit is contained in:
Tao Wen
2017-06-02 15:38:20 +08:00
parent 5310d4aa9a
commit 4cc44e7380
2 changed files with 33 additions and 0 deletions

19
jsoniter_adapter_test.go Normal file
View File

@ -0,0 +1,19 @@
package jsoniter
import (
"testing"
"github.com/json-iterator/go/require"
"encoding/json"
"bytes"
)
func Test_new_decoder(t *testing.T) {
should := require.New(t)
decoder1 := json.NewDecoder(bytes.NewBufferString(`[1]`))
decoder2 := NewDecoder(bytes.NewBufferString(`[1]`))
arr1 := []int{}
should.Nil(decoder1.Decode(&arr1))
should.Equal([]int{1}, arr1)
arr2 := []int{}
should.Nil(decoder2.Decode(&arr2))
}