1
0
mirror of https://github.com/json-iterator/go.git synced 2025-06-24 23:16:47 +02:00

#53 extract out config

This commit is contained in:
Tao Wen
2017-06-13 16:58:53 +08:00
parent 788918b85d
commit acddcf5bbf
33 changed files with 328 additions and 300 deletions

View File

@ -2,18 +2,18 @@ package jsoniter
import (
"bytes"
"encoding/json"
"github.com/json-iterator/go/require"
"testing"
"encoding/json"
)
func Test_read_null(t *testing.T) {
should := require.New(t)
iter := ParseString(`null`)
iter := ParseString(DEFAULT_CONFIG, `null`)
should.True(iter.ReadNil())
iter = ParseString(`null`)
iter = ParseString(DEFAULT_CONFIG, `null`)
should.Nil(iter.Read())
iter = ParseString(`null`)
iter = ParseString(DEFAULT_CONFIG, `null`)
any, err := UnmarshalAnyFromString(`null`)
should.Nil(err)
should.Equal(0, any.ToInt())
@ -25,7 +25,7 @@ func Test_read_null(t *testing.T) {
func Test_write_null(t *testing.T) {
should := require.New(t)
buf := &bytes.Buffer{}
stream := NewStream(buf, 4096)
stream := NewStream(DEFAULT_CONFIG, buf, 4096)
stream.WriteNil()
stream.Flush()
should.Nil(stream.Error)
@ -41,7 +41,7 @@ func Test_encode_null(t *testing.T) {
func Test_decode_null_object(t *testing.T) {
should := require.New(t)
iter := ParseString(`[null,"a"]`)
iter := ParseString(DEFAULT_CONFIG, `[null,"a"]`)
iter.ReadArray()
if iter.ReadObject() != "" {
t.FailNow()
@ -59,7 +59,7 @@ func Test_decode_null_object(t *testing.T) {
}
func Test_decode_null_array(t *testing.T) {
iter := ParseString(`[null,"a"]`)
iter := ParseString(DEFAULT_CONFIG, `[null,"a"]`)
iter.ReadArray()
if iter.ReadArray() != false {
t.FailNow()
@ -72,7 +72,7 @@ func Test_decode_null_array(t *testing.T) {
func Test_decode_null_string(t *testing.T) {
should := require.New(t)
iter := ParseString(`[null,"a"]`)
iter := ParseString(DEFAULT_CONFIG, `[null,"a"]`)
should.True(iter.ReadArray())
should.Equal("", iter.ReadString())
should.True(iter.ReadArray())
@ -80,7 +80,7 @@ func Test_decode_null_string(t *testing.T) {
}
func Test_decode_null_skip(t *testing.T) {
iter := ParseString(`[null,"a"]`)
iter := ParseString(DEFAULT_CONFIG, `[null,"a"]`)
iter.ReadArray()
iter.Skip()
iter.ReadArray()