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

#21 #22 marshal float precisely by default

This commit is contained in:
Tao Wen
2017-05-24 09:08:15 +08:00
parent fc44cb2d91
commit 5fbe4e387d
3 changed files with 34 additions and 4 deletions

View File

@ -56,6 +56,15 @@ func Test_customize_byte_array_encoder(t *testing.T) {
should.Equal(`"abc"`, str)
}
func Test_customize_float_marshal(t *testing.T) {
should := require.New(t)
EnableLossyFloatMarshalling()
defer CleanEncoders()
str, err := MarshalToString(float32(1.23456789))
should.Nil(err)
should.Equal("1.234568", str)
}
type Tom struct {
field1 string
}