jsoniter_adapter_test.go 420 B

12345678910111213141516171819
  1. package jsoniter
  2. import (
  3. "testing"
  4. "github.com/json-iterator/go/require"
  5. "encoding/json"
  6. "bytes"
  7. )
  8. func Test_new_decoder(t *testing.T) {
  9. should := require.New(t)
  10. decoder1 := json.NewDecoder(bytes.NewBufferString(`[1]`))
  11. decoder2 := NewDecoder(bytes.NewBufferString(`[1]`))
  12. arr1 := []int{}
  13. should.Nil(decoder1.Decode(&arr1))
  14. should.Equal([]int{1}, arr1)
  15. arr2 := []int{}
  16. should.Nil(decoder2.Decode(&arr2))
  17. }