jsoniter_any_int_test.go 475 B

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