gojay

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

commit b713369e35b2a561e334dedee6c5830afec499fc
parent b8dc210cd231638e2cdf5b330e4050ceab664d0f
Author: francoispqt <francois@parquet.ninja>
Date:   Tue, 29 May 2018 11:48:24 +0800

add test for 1 decimal float and fix bug introducedn in previous patch

Diffstat:
Mdecode_number_float.go | 4++--
Mdecode_number_float_test.go | 10++++++++++
2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/decode_number_float.go b/decode_number_float.go @@ -109,7 +109,7 @@ func (dec *Decoder) getFloat() (float64, error) { dec.cursor = i break } - if end >= dec.length || end <= start { + if end >= dec.length || end < start { return 0, dec.raiseInvalidJSONErr(dec.cursor) } // then we add both integers @@ -258,7 +258,7 @@ func (dec *Decoder) getFloat32() (float32, error) { dec.cursor = i break } - if end >= dec.length || end <= start { + if end >= dec.length || end < start { return 0, dec.raiseInvalidJSONErr(dec.cursor) } // then we add both integers diff --git a/decode_number_float_test.go b/decode_number_float_test.go @@ -20,6 +20,11 @@ func TestDecoderFloat64(t *testing.T) { errType interface{} }{ { + name: "basic-float", + json: "1.1", + expectedResult: 1.1, + }, + { name: "basic-exponent-positive-positive-exp", json: "1e2", expectedResult: 100, @@ -324,6 +329,11 @@ func TestDecoderFloat32(t *testing.T) { errType interface{} }{ { + name: "basic-float", + json: "1.1", + expectedResult: 1.1, + }, + { name: "basic-exponent-positive-positive-exp", json: "1e2", expectedResult: 100,