...

Source file src/github.com/json-iterator/go/skip_tests/skip_test.go

Documentation: github.com/json-iterator/go/skip_tests

     1  package skip_tests
     2  
     3  import (
     4  	"encoding/json"
     5  	"errors"
     6  	"github.com/json-iterator/go"
     7  	"github.com/stretchr/testify/require"
     8  	"io"
     9  	"reflect"
    10  	"testing"
    11  )
    12  
    13  type testCase struct {
    14  	ptr    interface{}
    15  	inputs []string
    16  }
    17  
    18  var testCases []testCase
    19  
    20  func Test_skip(t *testing.T) {
    21  	for _, testCase := range testCases {
    22  		valType := reflect.TypeOf(testCase.ptr).Elem()
    23  		for _, input := range testCase.inputs {
    24  			t.Run(input, func(t *testing.T) {
    25  				should := require.New(t)
    26  				ptrVal := reflect.New(valType)
    27  				stdErr := json.Unmarshal([]byte(input), ptrVal.Interface())
    28  				iter := jsoniter.ParseString(jsoniter.ConfigDefault, input)
    29  				iter.Skip()
    30  				iter.ReadNil() // trigger looking forward
    31  				err := iter.Error
    32  				if err == io.EOF {
    33  					err = nil
    34  				} else {
    35  					err = errors.New("remaining bytes")
    36  				}
    37  				if stdErr == nil {
    38  					should.Nil(err)
    39  				} else {
    40  					should.NotNil(err)
    41  				}
    42  			})
    43  		}
    44  	}
    45  }
    46  

View as plain text