jsoniter_any_int_test.go 541 B

123456789101112131415161718192021222324
  1. package jsoniter
  2. import (
  3. "testing"
  4. "github.com/json-iterator/go/require"
  5. "io"
  6. )
  7. func Test_read_int64_as_any(t *testing.T) {
  8. should := require.New(t)
  9. any, err := UnmarshalAnyFromString("1234")
  10. should.Nil(err)
  11. should.Equal(1234, any.ToInt())
  12. should.Equal(io.EOF, any.LastError())
  13. should.Equal("1234", any.ToString())
  14. should.True(any.ToBool())
  15. }
  16. func Test_int_lazy_any_get(t *testing.T) {
  17. should := require.New(t)
  18. any, err := UnmarshalAnyFromString("1234")
  19. should.Nil(err)
  20. should.Equal(Invalid, any.Get(1, "2").ValueType())
  21. }