File: decode_number_test.go

package info (click to toggle)
golang-github-francoispqt-gojay 1.2.13-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid, trixie
  • size: 1,456 kB
  • sloc: makefile: 86
file content (24 lines) | stat: -rw-r--r-- 676 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package gojay

import (
	"strings"
	"testing"

	"github.com/stretchr/testify/assert"
)

func TestDecodeNumberExra(t *testing.T) {
	t.Run("skip-number-err", func(t *testing.T) {
		dec := NewDecoder(strings.NewReader("123456afzfz343"))
		_, err := dec.skipNumber()
		assert.NotNil(t, err, "err should not be nil")
		assert.IsType(t, InvalidJSONError(""), err, "err should be of type InvalidJSONError")
	})
	t.Run("get-exponent-err", func(t *testing.T) {
		v := 0
		dec := NewDecoder(strings.NewReader("1.2Ea"))
		err := dec.Decode(&v)
		assert.NotNil(t, err, "err should not be nil")
		assert.IsType(t, InvalidJSONError(""), err, "err should be of type InvalidJSONError")
	})
}