Initial commit

This commit is contained in:
Ria Bhatia
2017-12-04 13:32:57 -06:00
committed by Erik St. Martin
commit 0075e5b0f3
9056 changed files with 2523100 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
package test
type typeForTest struct{}
var inputs = []string{
`{}`, // valid
`{"hello":"world"}`, // valid
`{hello:"world"}`, // invalid
`{"hello:"world"}`, // invalid
`{"hello","world"}`, // invalid
`{"hello":{}`, // invalid
`{"hello":{}}`, // valid
`{"hello":{}}}`, // invalid
`{"hello": { "hello": 1}}`, // valid
`{abc}`, // invalid
}

View File

@@ -0,0 +1,34 @@
package test
import (
"encoding/json"
"errors"
"github.com/json-iterator/go"
"github.com/stretchr/testify/require"
"io"
"testing"
)
func Test_skip(t *testing.T) {
for _, input := range inputs {
t.Run(input, func(t *testing.T) {
should := require.New(t)
var dst typeForTest
stdErr := json.Unmarshal([]byte(input), &dst)
iter := jsoniter.ParseString(jsoniter.ConfigDefault, input)
iter.Skip()
iter.ReadNil() // trigger looking forward
err := iter.Error
if err == io.EOF {
err = nil
} else {
err = errors.New("remaining bytes")
}
if stdErr == nil {
should.Nil(err)
} else {
should.NotNil(err)
}
})
}
}