jsoniter_invalid_test.go 696 B

12345678910111213141516171819202122232425262728
  1. package jsoniter
  2. import (
  3. "testing"
  4. "github.com/json-iterator/go/require"
  5. )
  6. func Test_invalid(t *testing.T) {
  7. should := require.New(t)
  8. any := Get([]byte("[]"))
  9. should.Equal(Invalid, any.Get(0.3).ValueType())
  10. // is nil correct ?
  11. should.Equal(nil, any.Get(0.3).GetInterface())
  12. any = any.Get(0.3)
  13. should.Equal(false, any.ToBool())
  14. should.Equal(int(0), any.ToInt())
  15. should.Equal(int32(0), any.ToInt32())
  16. should.Equal(int64(0), any.ToInt64())
  17. should.Equal(uint(0), any.ToUint())
  18. should.Equal(uint32(0), any.ToUint32())
  19. should.Equal(uint64(0), any.ToUint64())
  20. should.Equal(float32(0), any.ToFloat32())
  21. should.Equal(float64(0), any.ToFloat64())
  22. should.Equal("", any.ToString())
  23. }