1
0
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:
Tao Wen
2017-06-20 16:17:00 +08:00
parent 417011b497
commit 2ea4d48e1f
2 changed files with 62 additions and 22 deletions

View File

@ -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)
}