diff --git a/decode_array_test.go b/decode_array_test.go index 597b322..09ee052 100644 --- a/decode_array_test.go +++ b/decode_array_test.go @@ -7,11 +7,11 @@ import ( "github.com/stretchr/testify/assert" ) -type testSliceInts []int +type testSliceInts []int64 func (t *testSliceInts) UnmarshalJSONArray(dec *Decoder) error { - i := 0 - if err := dec.AddInt(&i); err != nil { + var i int64 + if err := dec.AddInt64(&i); err != nil { return err } *t = append(*t, i) diff --git a/decode_number_int_test.go b/decode_number_int_test.go index 909aef6..2383843 100644 --- a/decode_number_int_test.go +++ b/decode_number_int_test.go @@ -2,6 +2,7 @@ package gojay import ( "fmt" + "math" "reflect" "strings" "testing" @@ -67,8 +68,8 @@ func TestDecoderInt(t *testing.T) { }, { name: "basic-big", - json: "9223372036854775807", - expectedResult: 9223372036854775807, + json: fmt.Sprintf("%d", math.MaxInt), + expectedResult: math.MaxInt, }, { name: "basic-big-overflow", @@ -135,8 +136,8 @@ func TestDecoderInt(t *testing.T) { }, { name: "basic-exponent-positive-positive-exp2", - json: "5.01e+10", - expectedResult: 50100000000, + json: "5.01e+08", + expectedResult: 501000000, }, { name: "basic-exponent-positive-positive-exp3", @@ -369,8 +370,8 @@ func TestDecoderIntNull(t *testing.T) { }, { name: "basic-big", - json: "9223372036854775807", - expectedResult: 9223372036854775807, + json: fmt.Sprintf("%d", math.MaxInt), + expectedResult: math.MaxInt, }, { name: "basic-big-overflow", @@ -437,8 +438,8 @@ func TestDecoderIntNull(t *testing.T) { }, { name: "basic-exponent-positive-positive-exp2", - json: "5.01e+10", - expectedResult: 50100000000, + json: "5.01e+08", + expectedResult: 501000000, }, { name: "basic-exponent-positive-positive-exp3", @@ -652,7 +653,7 @@ func TestDecoderInt64(t *testing.T) { { name: "basic-big", json: "9223372036854775807", - expectedResult: 9223372036854775807, + expectedResult: math.MaxInt64, }, { name: "basic-big-overflow", @@ -981,7 +982,7 @@ func TestDecoderInt64Null(t *testing.T) { { name: "basic-big", json: "9223372036854775807", - expectedResult: 9223372036854775807, + expectedResult: math.MaxInt64, }, { name: "basic-big-overflow", diff --git a/encode_number_test.go b/encode_number_test.go index 4c81a79..46c1731 100644 --- a/encode_number_test.go +++ b/encode_number_test.go @@ -29,7 +29,7 @@ func TestEncoderNumberEncodeAPI(t *testing.T) { assert.Nil(t, err, "Error should be nil") assert.Equal( t, - fmt.Sprintf("%d", math.MaxInt64), + fmt.Sprintf("%d", int64(math.MaxInt64)), builder.String(), "Result of marshalling is different as the one expected") })