fuzzy_decoder_test.go 485 B

12345678910111213141516171819202122232425
  1. package extra
  2. import (
  3. "testing"
  4. "github.com/json-iterator/go"
  5. "github.com/json-iterator/go/require"
  6. )
  7. func init() {
  8. RegisterFuzzyDecoders()
  9. }
  10. func Test_int_to_string(t *testing.T) {
  11. should := require.New(t)
  12. var val string
  13. should.Nil(jsoniter.UnmarshalFromString(`100`, &val))
  14. should.Equal("100", val)
  15. }
  16. func Test_float_to_string(t *testing.T) {
  17. should := require.New(t)
  18. var val string
  19. should.Nil(jsoniter.UnmarshalFromString(`12.0`, &val))
  20. should.Equal("12.0", val)
  21. }