You've already forked json-iterator
mirror of
https://github.com/json-iterator/go.git
synced 2025-06-12 22:47:42 +02:00
#68 string to float32
This commit is contained in:
@ -57,3 +57,17 @@ func Test_large_float_to_int(t *testing.T) {
|
||||
var val int
|
||||
should.NotNil(jsoniter.UnmarshalFromString(`1234512345123451234512345.0`, &val))
|
||||
}
|
||||
|
||||
func Test_string_to_float32(t *testing.T) {
|
||||
should := require.New(t)
|
||||
var val float32
|
||||
should.Nil(jsoniter.UnmarshalFromString(`"100"`, &val))
|
||||
should.Equal(float32(100), val)
|
||||
}
|
||||
|
||||
func Test_float_to_float32(t *testing.T) {
|
||||
should := require.New(t)
|
||||
var val float32
|
||||
should.Nil(jsoniter.UnmarshalFromString(`1.23`, &val))
|
||||
should.Equal(float32(1.23), val)
|
||||
}
|
||||
|
Reference in New Issue
Block a user