1
0
mirror of https://github.com/json-iterator/go.git synced 2025-06-15 22:50:24 +02:00

support big float and int

This commit is contained in:
Tao Wen
2017-05-31 12:40:50 +08:00
parent 707ed3b091
commit 377b892102
2 changed files with 61 additions and 22 deletions

View File

@ -9,6 +9,22 @@ import (
"strconv"
)
func Test_read_big_float(t *testing.T) {
should := require.New(t)
iter := ParseString(`12.3`)
val := iter.ReadBigFloat()
val64, _ := val.Float64()
should.Equal(12.3, val64)
}
func Test_read_big_int(t *testing.T) {
should := require.New(t)
iter := ParseString(`92233720368547758079223372036854775807`)
val := iter.ReadBigInt()
should.NotNil(val)
should.Equal(`92233720368547758079223372036854775807`, val.String())
}
func Test_read_float(t *testing.T) {
inputs := []string{`1.1`, `1000`, `9223372036854775807`, `12.3`, `-12.3`, `720368.54775807`, `720368.547758075`}
for _, input := range inputs {