You've already forked json-iterator
mirror of
https://github.com/json-iterator/go.git
synced 2025-06-18 22:57:33 +02:00
string any
This commit is contained in:
@ -59,12 +59,26 @@ func Test_read_exotic_string(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func Test_read_string_via_read(t *testing.T) {
|
||||
func Test_read_string_as_interface(t *testing.T) {
|
||||
should := require.New(t)
|
||||
iter := ParseString(`"hello"`)
|
||||
should.Equal("hello", iter.Read())
|
||||
}
|
||||
|
||||
func Test_read_string_as_any(t *testing.T) {
|
||||
should := require.New(t)
|
||||
any, err := UnmarshalAnyFromString(`"hello"`)
|
||||
should.Nil(err)
|
||||
should.Equal("hello", any.ToString())
|
||||
should.True(any.ToBool())
|
||||
any, err = UnmarshalAnyFromString(`" "`)
|
||||
should.False(any.ToBool())
|
||||
any, err = UnmarshalAnyFromString(`"false"`)
|
||||
should.False(any.ToBool())
|
||||
any, err = UnmarshalAnyFromString(`"123"`)
|
||||
should.Equal(123, any.ToInt())
|
||||
}
|
||||
|
||||
func Test_write_string(t *testing.T) {
|
||||
should := require.New(t)
|
||||
str, err := MarshalToString("hello")
|
||||
|
Reference in New Issue
Block a user