gojay

high performance JSON encoder/decoder with stream API for Golang
git clone git://git.lair.cx/gojay
Log | Files | Refs | README | LICENSE

decode_number_test.go (676B)


      1 package gojay
      2 
      3 import (
      4 	"strings"
      5 	"testing"
      6 
      7 	"github.com/stretchr/testify/assert"
      8 )
      9 
     10 func TestDecodeNumberExra(t *testing.T) {
     11 	t.Run("skip-number-err", func(t *testing.T) {
     12 		dec := NewDecoder(strings.NewReader("123456afzfz343"))
     13 		_, err := dec.skipNumber()
     14 		assert.NotNil(t, err, "err should not be nil")
     15 		assert.IsType(t, InvalidJSONError(""), err, "err should be of type InvalidJSONError")
     16 	})
     17 	t.Run("get-exponent-err", func(t *testing.T) {
     18 		v := 0
     19 		dec := NewDecoder(strings.NewReader("1.2Ea"))
     20 		err := dec.Decode(&v)
     21 		assert.NotNil(t, err, "err should not be nil")
     22 		assert.IsType(t, InvalidJSONError(""), err, "err should be of type InvalidJSONError")
     23 	})
     24 }