mirror of
https://github.com/json-iterator/go.git
synced 2025-05-16 21:45:43 +02:00
#135 verify 1e1 and 1.0e1 is handled same as std
This commit is contained in:
parent
18d6ae2668
commit
e066e54964
@ -60,9 +60,10 @@ func Test_read_float(t *testing.T) {
|
|||||||
t.Run(fmt.Sprintf("%v", input), func(t *testing.T) {
|
t.Run(fmt.Sprintf("%v", input), func(t *testing.T) {
|
||||||
should := require.New(t)
|
should := require.New(t)
|
||||||
iter := Parse(ConfigDefault, bytes.NewBufferString(input+","), 2)
|
iter := Parse(ConfigDefault, bytes.NewBufferString(input+","), 2)
|
||||||
expected, err := strconv.ParseFloat(input, 64)
|
val := float64(0)
|
||||||
|
err := json.Unmarshal([]byte(input), &val)
|
||||||
should.Nil(err)
|
should.Nil(err)
|
||||||
should.Equal(expected, iter.ReadFloat64())
|
should.Equal(val, iter.ReadFloat64())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,6 +81,15 @@ func Test_read_interface(t *testing.T) {
|
|||||||
err := UnmarshalFromString(`"hello"`, &val)
|
err := UnmarshalFromString(`"hello"`, &val)
|
||||||
should.Nil(err)
|
should.Nil(err)
|
||||||
should.Equal("hello", val)
|
should.Equal("hello", val)
|
||||||
|
err = UnmarshalFromString(`1e1`, &val)
|
||||||
|
should.Nil(err)
|
||||||
|
should.Equal(float64(10), val)
|
||||||
|
err = UnmarshalFromString(`1.0e1`, &val)
|
||||||
|
should.Nil(err)
|
||||||
|
should.Equal(float64(10), val)
|
||||||
|
err = json.Unmarshal([]byte(`1.0e1`), &val)
|
||||||
|
should.Nil(err)
|
||||||
|
should.Equal(float64(10), val)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_read_custom_interface(t *testing.T) {
|
func Test_read_custom_interface(t *testing.T) {
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package jsoniter
|
package jsoniter
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
"testing"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
"io"
|
"io"
|
||||||
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_missing_object_end(t *testing.T) {
|
func Test_missing_object_end(t *testing.T) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user