1
0
mirror of https://github.com/json-iterator/go.git synced 2025-06-15 22:50:24 +02:00

Any Get will never return nil

This commit is contained in:
Tao Wen
2017-01-26 16:24:01 +08:00
parent 9abc2f52b0
commit 85edb698c8
12 changed files with 106 additions and 13 deletions

View File

@ -147,6 +147,14 @@ func Test_object_lazy_any_get(t *testing.T) {
should.Equal("d", any.Get("a", "b", "c").ToString())
}
func Test_object_lazy_any_get_invalid(t *testing.T) {
should := require.New(t)
any, err := UnmarshalAnyFromString(`{}`)
should.Nil(err)
should.Equal(Invalid, any.Get("a", "b", "c").ValueType())
should.Equal(Invalid, any.Get(1).ValueType())
}
func Test_object_lazy_any_set(t *testing.T) {
should := require.New(t)
any, err := UnmarshalAnyFromString(`{"a":{"b":{"c":"d"}}}`)