mirror of
https://github.com/json-iterator/go.git
synced 2025-01-29 19:14:05 +02:00
26 lines
547 B
Go
26 lines
547 B
Go
package jsoniter
|
|
|
|
import (
|
|
"github.com/json-iterator/go/require"
|
|
"testing"
|
|
)
|
|
|
|
func Test_read_string_as_any(t *testing.T) {
|
|
should := require.New(t)
|
|
any := Get([]byte(`"hello"`))
|
|
should.Equal("hello", any.ToString())
|
|
should.True(any.ToBool())
|
|
any = Get([]byte(`" "`))
|
|
should.False(any.ToBool())
|
|
any = Get([]byte(`"false"`))
|
|
should.False(any.ToBool())
|
|
any = Get([]byte(`"123"`))
|
|
should.Equal(123, any.ToInt())
|
|
}
|
|
|
|
func Test_wrap_string(t *testing.T) {
|
|
should := require.New(t)
|
|
any := WrapString("123")
|
|
should.Equal(123, any.ToInt())
|
|
}
|