You've already forked json-iterator
mirror of
https://github.com/json-iterator/go.git
synced 2025-06-15 22:50:24 +02:00
float any
This commit is contained in:
@ -45,12 +45,21 @@ func Test_read_float(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func Test_read_float_via_read(t *testing.T) {
|
||||
func Test_read_float_as_interface(t *testing.T) {
|
||||
should := require.New(t)
|
||||
iter := ParseString(`12.3`)
|
||||
should.Equal(float64(12.3), iter.Read())
|
||||
}
|
||||
|
||||
func Test_read_float_as_any(t *testing.T) {
|
||||
should := require.New(t)
|
||||
any, err := UnmarshalAnyFromString("12.3")
|
||||
should.Nil(err)
|
||||
should.Equal(float64(12.3), any.ToFloat64())
|
||||
should.Equal("12.3", any.ToString())
|
||||
should.True(any.ToBool())
|
||||
}
|
||||
|
||||
func Test_write_float32(t *testing.T) {
|
||||
vals := []float32{0, 1, -1, 99, 0xff, 0xfff, 0xffff, 0xfffff, 0xffffff, 0x4ffffff, 0xfffffff,
|
||||
-0x4ffffff, -0xfffffff, 1.2345, 1.23456, 1.234567, 1.001}
|
||||
|
Reference in New Issue
Block a user