1
0
mirror of https://github.com/json-iterator/go.git synced 2025-06-24 23:16:47 +02:00

fix write float compatibility

This commit is contained in:
Tao Wen
2017-07-02 15:11:36 +08:00
parent c4f54740f7
commit c009421781
3 changed files with 28 additions and 6 deletions

View File

@ -85,7 +85,9 @@ func Test_write_float32(t *testing.T) {
stream.WriteFloat32Lossy(val)
stream.Flush()
should.Nil(stream.Error)
should.Equal(strconv.FormatFloat(float64(val), 'f', -1, 32), buf.String())
output, err := json.Marshal(val)
should.Nil(err)
should.Equal(string(output), buf.String())
})
t.Run(fmt.Sprintf("%v", val), func(t *testing.T) {
should := require.New(t)
@ -94,7 +96,9 @@ func Test_write_float32(t *testing.T) {
stream.WriteVal(val)
stream.Flush()
should.Nil(stream.Error)
should.Equal(strconv.FormatFloat(float64(val), 'f', -1, 32), buf.String())
output, err := json.Marshal(val)
should.Nil(err)
should.Equal(string(output), buf.String())
})
}
should := require.New(t)