mirror of https://github.com/goccy/go-json.git
2390 lines
50 KiB
Go
2390 lines
50 KiB
Go
package json_test
|
|
|
|
import (
|
|
"bytes"
|
|
"testing"
|
|
|
|
"github.com/goccy/go-json"
|
|
)
|
|
|
|
func TestCoverString(t *testing.T) {
|
|
type structString struct {
|
|
A string `json:"a"`
|
|
}
|
|
type structStringOmitEmpty struct {
|
|
A string `json:"a,omitempty"`
|
|
}
|
|
type structStringString struct {
|
|
A string `json:"a,string"`
|
|
}
|
|
type structStringStringOmitEmpty struct {
|
|
A string `json:"a,string,omitempty"`
|
|
}
|
|
|
|
type structStringPtr struct {
|
|
A *string `json:"a"`
|
|
}
|
|
type structStringPtrOmitEmpty struct {
|
|
A *string `json:"a,omitempty"`
|
|
}
|
|
type structStringPtrString struct {
|
|
A *string `json:"a,string"`
|
|
}
|
|
type structStringPtrStringOmitEmpty struct {
|
|
A *string `json:"a,string,omitempty"`
|
|
}
|
|
|
|
tests := []struct {
|
|
name string
|
|
data interface{}
|
|
}{
|
|
{
|
|
name: "PtrHeadStringComplicated",
|
|
data: &struct {
|
|
X *struct {
|
|
A string
|
|
B []string
|
|
}
|
|
}{X: &struct {
|
|
A string
|
|
B []string
|
|
}{A: "hello", B: []string{"a", "b"}}},
|
|
},
|
|
{
|
|
name: "String",
|
|
data: string("a"),
|
|
},
|
|
{
|
|
name: "StringPtr",
|
|
data: stringptr("a"),
|
|
},
|
|
{
|
|
name: "StringPtr3",
|
|
data: stringptr3("a"),
|
|
},
|
|
{
|
|
name: "StringPtrNil",
|
|
data: (*string)(nil),
|
|
},
|
|
{
|
|
name: "StringPtr3Nil",
|
|
data: (***string)(nil),
|
|
},
|
|
|
|
// HeadStringZero
|
|
{
|
|
name: "HeadStringZero",
|
|
data: struct {
|
|
A string `json:"a"`
|
|
}{},
|
|
},
|
|
{
|
|
name: "HeadStringZeroOmitEmpty",
|
|
data: struct {
|
|
A string `json:"a,omitempty"`
|
|
}{},
|
|
},
|
|
{
|
|
name: "HeadStringZeroString",
|
|
data: struct {
|
|
A string `json:"a,string"`
|
|
}{},
|
|
},
|
|
{
|
|
name: "HeadStringZeroStringOmitEmpty",
|
|
data: struct {
|
|
A string `json:"a,string,omitempty"`
|
|
}{},
|
|
},
|
|
|
|
// HeadString
|
|
{
|
|
name: "HeadString",
|
|
data: struct {
|
|
A string `json:"a"`
|
|
}{A: "foo"},
|
|
},
|
|
{
|
|
name: "HeadStringOmitEmpty",
|
|
data: struct {
|
|
A string `json:"a,omitempty"`
|
|
}{A: "foo"},
|
|
},
|
|
{
|
|
name: "HeadStringString",
|
|
data: struct {
|
|
A string `json:"a,string"`
|
|
}{A: "foo"},
|
|
},
|
|
{
|
|
name: "HeadStringStringOmitEmpty",
|
|
data: struct {
|
|
A string `json:"a,string,omitempty"`
|
|
}{A: "foo"},
|
|
},
|
|
|
|
// HeadStringPtr
|
|
{
|
|
name: "HeadStringPtr",
|
|
data: struct {
|
|
A *string `json:"a"`
|
|
}{A: stringptr("foo")},
|
|
},
|
|
{
|
|
name: "HeadStringPtrOmitEmpty",
|
|
data: struct {
|
|
A *string `json:"a,omitempty"`
|
|
}{A: stringptr("foo")},
|
|
},
|
|
{
|
|
name: "HeadStringPtrString",
|
|
data: struct {
|
|
A *string `json:"a,string"`
|
|
}{A: stringptr("foo")},
|
|
},
|
|
{
|
|
name: "HeadStringPtrStringOmitEmpty",
|
|
data: struct {
|
|
A *string `json:"a,string,omitempty"`
|
|
}{A: stringptr("foo")},
|
|
},
|
|
|
|
// HeadStringPtrNil
|
|
{
|
|
name: "HeadStringPtrNil",
|
|
data: struct {
|
|
A *string `json:"a"`
|
|
}{A: nil},
|
|
},
|
|
{
|
|
name: "HeadStringPtrNilOmitEmpty",
|
|
data: struct {
|
|
A *string `json:"a,omitempty"`
|
|
}{A: nil},
|
|
},
|
|
{
|
|
name: "HeadStringPtrNilString",
|
|
data: struct {
|
|
A *string `json:"a,string"`
|
|
}{A: nil},
|
|
},
|
|
{
|
|
name: "HeadStringPtrNilStringOmitEmpty",
|
|
data: struct {
|
|
A *string `json:"a,string,omitempty"`
|
|
}{A: nil},
|
|
},
|
|
|
|
// PtrHeadStringZero
|
|
{
|
|
name: "PtrHeadStringZero",
|
|
data: &struct {
|
|
A string `json:"a"`
|
|
}{},
|
|
},
|
|
{
|
|
name: "PtrHeadStringZeroOmitEmpty",
|
|
data: &struct {
|
|
A string `json:"a,omitempty"`
|
|
}{},
|
|
},
|
|
{
|
|
name: "PtrHeadStringZeroString",
|
|
data: &struct {
|
|
A string `json:"a,string"`
|
|
}{},
|
|
},
|
|
{
|
|
name: "PtrHeadStringZeroStringOmitEmpty",
|
|
data: &struct {
|
|
A string `json:"a,string,omitempty"`
|
|
}{},
|
|
},
|
|
|
|
// PtrHeadString
|
|
{
|
|
name: "PtrHeadString",
|
|
data: &struct {
|
|
A string `json:"a"`
|
|
}{A: "foo"},
|
|
},
|
|
{
|
|
name: "PtrHeadStringOmitEmpty",
|
|
data: &struct {
|
|
A string `json:"a,omitempty"`
|
|
}{A: "foo"},
|
|
},
|
|
{
|
|
name: "PtrHeadStringString",
|
|
data: &struct {
|
|
A string `json:"a,string"`
|
|
}{A: "foo"},
|
|
},
|
|
{
|
|
name: "PtrHeadStringStringOmitEmpty",
|
|
data: &struct {
|
|
A string `json:"a,string,omitempty"`
|
|
}{A: "foo"},
|
|
},
|
|
|
|
// PtrHeadStringPtr
|
|
{
|
|
name: "PtrHeadStringPtr",
|
|
data: &struct {
|
|
A *string `json:"a"`
|
|
}{A: stringptr("foo")},
|
|
},
|
|
{
|
|
name: "PtrHeadStringPtrOmitEmpty",
|
|
data: &struct {
|
|
A *string `json:"a,omitempty"`
|
|
}{A: stringptr("foo")},
|
|
},
|
|
{
|
|
name: "PtrHeadStringPtrString",
|
|
data: &struct {
|
|
A *string `json:"a,string"`
|
|
}{A: stringptr("foo")},
|
|
},
|
|
{
|
|
name: "PtrHeadStringPtrStringOmitEmpty",
|
|
data: &struct {
|
|
A *string `json:"a,string,omitempty"`
|
|
}{A: stringptr("foo")},
|
|
},
|
|
|
|
// PtrHeadStringPtrNil
|
|
{
|
|
name: "PtrHeadStringPtrNil",
|
|
data: &struct {
|
|
A *string `json:"a"`
|
|
}{A: nil},
|
|
},
|
|
{
|
|
name: "PtrHeadStringPtrNilOmitEmpty",
|
|
data: &struct {
|
|
A *string `json:"a,omitempty"`
|
|
}{A: nil},
|
|
},
|
|
{
|
|
name: "PtrHeadStringPtrNilString",
|
|
data: &struct {
|
|
A *string `json:"a,string"`
|
|
}{A: nil},
|
|
},
|
|
{
|
|
name: "PtrHeadStringPtrNilStringOmitEmpty",
|
|
data: &struct {
|
|
A *string `json:"a,string,omitempty"`
|
|
}{A: nil},
|
|
},
|
|
|
|
// PtrHeadStringNil
|
|
{
|
|
name: "PtrHeadStringNil",
|
|
data: (*struct {
|
|
A *string `json:"a"`
|
|
})(nil),
|
|
},
|
|
{
|
|
name: "PtrHeadStringNilOmitEmpty",
|
|
data: (*struct {
|
|
A *string `json:"a,omitempty"`
|
|
})(nil),
|
|
},
|
|
{
|
|
name: "PtrHeadStringNilString",
|
|
data: (*struct {
|
|
A *string `json:"a,string"`
|
|
})(nil),
|
|
},
|
|
{
|
|
name: "PtrHeadStringNilStringOmitEmpty",
|
|
data: (*struct {
|
|
A *string `json:"a,string,omitempty"`
|
|
})(nil),
|
|
},
|
|
|
|
// HeadStringZeroMultiFields
|
|
{
|
|
name: "HeadStringZeroMultiFields",
|
|
data: struct {
|
|
A string `json:"a"`
|
|
B string `json:"b"`
|
|
C string `json:"c"`
|
|
}{},
|
|
},
|
|
{
|
|
name: "HeadStringZeroMultiFieldsOmitEmpty",
|
|
data: struct {
|
|
A string `json:"a,omitempty"`
|
|
B string `json:"b,omitempty"`
|
|
C string `json:"c,omitempty"`
|
|
}{},
|
|
},
|
|
{
|
|
name: "HeadStringZeroMultiFieldsString",
|
|
data: struct {
|
|
A string `json:"a,string"`
|
|
B string `json:"b,string"`
|
|
C string `json:"c,string"`
|
|
}{},
|
|
},
|
|
{
|
|
name: "HeadStringZeroMultiFieldsStringOmitEmpty",
|
|
data: struct {
|
|
A string `json:"a,string,omitempty"`
|
|
B string `json:"b,string,omitempty"`
|
|
C string `json:"c,string,omitempty"`
|
|
}{},
|
|
},
|
|
|
|
// HeadStringMultiFields
|
|
{
|
|
name: "HeadStringMultiFields",
|
|
data: struct {
|
|
A string `json:"a"`
|
|
B string `json:"b"`
|
|
C string `json:"c"`
|
|
}{A: "foo", B: "bar", C: "baz"},
|
|
},
|
|
{
|
|
name: "HeadStringMultiFieldsOmitEmpty",
|
|
data: struct {
|
|
A string `json:"a,omitempty"`
|
|
B string `json:"b,omitempty"`
|
|
C string `json:"c,omitempty"`
|
|
}{A: "foo", B: "bar", C: "baz"},
|
|
},
|
|
{
|
|
name: "HeadStringMultiFieldsString",
|
|
data: struct {
|
|
A string `json:"a,string"`
|
|
B string `json:"b,string"`
|
|
C string `json:"c,string"`
|
|
}{A: "foo", B: "bar", C: "baz"},
|
|
},
|
|
{
|
|
name: "HeadStringMultiFieldsStringOmitEmpty",
|
|
data: struct {
|
|
A string `json:"a,string,omitempty"`
|
|
B string `json:"b,string,omitempty"`
|
|
C string `json:"c,string,omitempty"`
|
|
}{A: "foo", B: "bar", C: "baz"},
|
|
},
|
|
|
|
// HeadStringPtrMultiFields
|
|
{
|
|
name: "HeadStringPtrMultiFields",
|
|
data: struct {
|
|
A *string `json:"a"`
|
|
B *string `json:"b"`
|
|
C *string `json:"c"`
|
|
}{A: stringptr("foo"), B: stringptr("bar"), C: stringptr("baz")},
|
|
},
|
|
{
|
|
name: "HeadStringPtrMultiFieldsOmitEmpty",
|
|
data: struct {
|
|
A *string `json:"a,omitempty"`
|
|
B *string `json:"b,omitempty"`
|
|
C *string `json:"c,omitempty"`
|
|
}{A: stringptr("foo"), B: stringptr("bar"), C: stringptr("baz")},
|
|
},
|
|
{
|
|
name: "HeadStringPtrMultiFieldsString",
|
|
data: struct {
|
|
A *string `json:"a,string"`
|
|
B *string `json:"b,string"`
|
|
C *string `json:"c,string"`
|
|
}{A: stringptr("foo"), B: stringptr("bar"), C: stringptr("baz")},
|
|
},
|
|
{
|
|
name: "HeadStringPtrMultiFieldsStringOmitEmpty",
|
|
data: struct {
|
|
A *string `json:"a,string,omitempty"`
|
|
B *string `json:"b,string,omitempty"`
|
|
C *string `json:"c,string,omitempty"`
|
|
}{A: stringptr("foo"), B: stringptr("bar"), C: stringptr("baz")},
|
|
},
|
|
|
|
// HeadStringPtrNilMultiFields
|
|
{
|
|
name: "HeadStringPtrNilMultiFields",
|
|
data: struct {
|
|
A *string `json:"a"`
|
|
B *string `json:"b"`
|
|
C *string `json:"c"`
|
|
}{A: nil, B: nil, C: nil},
|
|
},
|
|
{
|
|
name: "HeadStringPtrNilMultiFieldsOmitEmpty",
|
|
data: struct {
|
|
A *string `json:"a,omitempty"`
|
|
B *string `json:"b,omitempty"`
|
|
C *string `json:"c,omitempty"`
|
|
}{A: nil, B: nil, C: nil},
|
|
},
|
|
{
|
|
name: "HeadStringPtrNilMultiFieldsString",
|
|
data: struct {
|
|
A *string `json:"a,string"`
|
|
B *string `json:"b,string"`
|
|
C *string `json:"c,string"`
|
|
}{A: nil, B: nil, C: nil},
|
|
},
|
|
{
|
|
name: "HeadStringPtrNilMultiFieldsStringOmitEmpty",
|
|
data: struct {
|
|
A *string `json:"a,string,omitempty"`
|
|
B *string `json:"b,string,omitempty"`
|
|
C *string `json:"c,string,omitempty"`
|
|
}{A: nil, B: nil, C: nil},
|
|
},
|
|
|
|
// PtrHeadStringZeroMultiFields
|
|
{
|
|
name: "PtrHeadStringZeroMultiFields",
|
|
data: &struct {
|
|
A string `json:"a"`
|
|
B string `json:"b"`
|
|
C string `json:"c"`
|
|
}{},
|
|
},
|
|
{
|
|
name: "PtrHeadStringZeroMultiFieldsOmitEmpty",
|
|
data: &struct {
|
|
A string `json:"a,omitempty"`
|
|
B string `json:"b,omitempty"`
|
|
C string `json:"c,omitempty"`
|
|
}{},
|
|
},
|
|
{
|
|
name: "PtrHeadStringZeroMultiFieldsString",
|
|
data: &struct {
|
|
A string `json:"a,string"`
|
|
B string `json:"b,string"`
|
|
C string `json:"c,string"`
|
|
}{},
|
|
},
|
|
{
|
|
name: "PtrHeadStringZeroMultiFieldsStringOmitEmpty",
|
|
data: &struct {
|
|
A string `json:"a,string,omitempty"`
|
|
B string `json:"b,string,omitempty"`
|
|
C string `json:"c,string,omitempty"`
|
|
}{},
|
|
},
|
|
|
|
// PtrHeadStringMultiFields
|
|
{
|
|
name: "PtrHeadStringMultiFields",
|
|
data: &struct {
|
|
A string `json:"a"`
|
|
B string `json:"b"`
|
|
C string `json:"c"`
|
|
}{A: "foo", B: "bar", C: "baz"},
|
|
},
|
|
{
|
|
name: "PtrHeadStringMultiFieldsOmitEmpty",
|
|
data: &struct {
|
|
A string `json:"a,omitempty"`
|
|
B string `json:"b,omitempty"`
|
|
C string `json:"c,omitempty"`
|
|
}{A: "foo", B: "bar", C: "baz"},
|
|
},
|
|
{
|
|
name: "PtrHeadStringMultiFieldsString",
|
|
data: &struct {
|
|
A string `json:"a,string"`
|
|
B string `json:"b,string"`
|
|
C string `json:"c,string"`
|
|
}{A: "foo", B: "bar", C: "baz"},
|
|
},
|
|
{
|
|
name: "PtrHeadStringMultiFieldsStringOmitEmpty",
|
|
data: &struct {
|
|
A string `json:"a,string,omitempty"`
|
|
B string `json:"b,string,omitempty"`
|
|
C string `json:"c,string,omitempty"`
|
|
}{A: "foo", B: "bar", C: "baz"},
|
|
},
|
|
|
|
// PtrHeadStringPtrMultiFields
|
|
{
|
|
name: "PtrHeadStringPtrMultiFields",
|
|
data: &struct {
|
|
A *string `json:"a"`
|
|
B *string `json:"b"`
|
|
C *string `json:"c"`
|
|
}{A: stringptr("foo"), B: stringptr("bar"), C: stringptr("baz")},
|
|
},
|
|
{
|
|
name: "PtrHeadStringPtrMultiFieldsOmitEmpty",
|
|
data: &struct {
|
|
A *string `json:"a,omitempty"`
|
|
B *string `json:"b,omitempty"`
|
|
C *string `json:"c,omitempty"`
|
|
}{A: stringptr("foo"), B: stringptr("bar"), C: stringptr("baz")},
|
|
},
|
|
{
|
|
name: "PtrHeadStringPtrMultiFieldsString",
|
|
data: &struct {
|
|
A *string `json:"a,string"`
|
|
B *string `json:"b,string"`
|
|
C *string `json:"c,string"`
|
|
}{A: stringptr("foo"), B: stringptr("bar"), C: stringptr("baz")},
|
|
},
|
|
{
|
|
name: "PtrHeadStringPtrMultiFieldsStringOmitEmpty",
|
|
data: &struct {
|
|
A *string `json:"a,string,omitempty"`
|
|
B *string `json:"b,string,omitempty"`
|
|
C *string `json:"c,string,omitempty"`
|
|
}{A: stringptr("foo"), B: stringptr("bar"), C: stringptr("baz")},
|
|
},
|
|
|
|
// PtrHeadStringPtrNilMultiFields
|
|
{
|
|
name: "PtrHeadStringPtrNilMultiFields",
|
|
data: &struct {
|
|
A *string `json:"a"`
|
|
B *string `json:"b"`
|
|
C *string `json:"c"`
|
|
}{A: nil, B: nil, C: nil},
|
|
},
|
|
{
|
|
name: "PtrHeadStringPtrNilMultiFieldsOmitEmpty",
|
|
data: &struct {
|
|
A *string `json:"a,omitempty"`
|
|
B *string `json:"b,omitempty"`
|
|
C *string `json:"c,omitempty"`
|
|
}{A: nil, B: nil, C: nil},
|
|
},
|
|
{
|
|
name: "PtrHeadStringPtrNilMultiFieldsString",
|
|
data: &struct {
|
|
A *string `json:"a,string"`
|
|
B *string `json:"b,string"`
|
|
C *string `json:"c,string"`
|
|
}{A: nil, B: nil, C: nil},
|
|
},
|
|
{
|
|
name: "PtrHeadStringPtrNilMultiFieldsStringOmitEmpty",
|
|
data: &struct {
|
|
A *string `json:"a,string,omitempty"`
|
|
B *string `json:"b,string,omitempty"`
|
|
C *string `json:"c,string,omitempty"`
|
|
}{A: nil, B: nil, C: nil},
|
|
},
|
|
|
|
// PtrHeadStringNilMultiFields
|
|
{
|
|
name: "PtrHeadStringNilMultiFields",
|
|
data: (*struct {
|
|
A *string `json:"a"`
|
|
B *string `json:"b"`
|
|
C *string `json:"c"`
|
|
})(nil),
|
|
},
|
|
{
|
|
name: "PtrHeadStringNilMultiFieldsOmitEmpty",
|
|
data: (*struct {
|
|
A *string `json:"a,omitempty"`
|
|
B *string `json:"b,omitempty"`
|
|
C *string `json:"c,omitempty"`
|
|
})(nil),
|
|
},
|
|
{
|
|
name: "PtrHeadStringNilMultiFieldsString",
|
|
data: (*struct {
|
|
A *string `json:"a,string"`
|
|
B *string `json:"b,string"`
|
|
C *string `json:"c,string"`
|
|
})(nil),
|
|
},
|
|
{
|
|
name: "PtrHeadStringNilMultiFieldsStringOmitEmpty",
|
|
data: (*struct {
|
|
A *string `json:"a,string,omitempty"`
|
|
B *string `json:"b,string,omitempty"`
|
|
C *string `json:"c,string,omitempty"`
|
|
})(nil),
|
|
},
|
|
|
|
// HeadStringZeroNotRoot
|
|
{
|
|
name: "HeadStringZeroNotRoot",
|
|
data: struct {
|
|
A struct {
|
|
A string `json:"a"`
|
|
}
|
|
}{},
|
|
},
|
|
{
|
|
name: "HeadStringZeroNotRootOmitEmpty",
|
|
data: struct {
|
|
A struct {
|
|
A string `json:"a,omitempty"`
|
|
}
|
|
}{},
|
|
},
|
|
{
|
|
name: "HeadStringZeroNotRootString",
|
|
data: struct {
|
|
A struct {
|
|
A string `json:"a,string"`
|
|
}
|
|
}{},
|
|
},
|
|
{
|
|
name: "HeadStringZeroNotRootStringOmitEmpty",
|
|
data: struct {
|
|
A struct {
|
|
A string `json:"a,string,omitempty"`
|
|
}
|
|
}{},
|
|
},
|
|
|
|
// HeadStringNotRoot
|
|
{
|
|
name: "HeadStringNotRoot",
|
|
data: struct {
|
|
A struct {
|
|
A string `json:"a"`
|
|
}
|
|
}{A: struct {
|
|
A string `json:"a"`
|
|
}{A: "foo"}},
|
|
},
|
|
{
|
|
name: "HeadStringNotRootOmitEmpty",
|
|
data: struct {
|
|
A struct {
|
|
A string `json:"a,omitempty"`
|
|
}
|
|
}{A: struct {
|
|
A string `json:"a,omitempty"`
|
|
}{A: "foo"}},
|
|
},
|
|
{
|
|
name: "HeadStringNotRootString",
|
|
data: struct {
|
|
A struct {
|
|
A string `json:"a,string"`
|
|
}
|
|
}{A: struct {
|
|
A string `json:"a,string"`
|
|
}{A: "foo"}},
|
|
},
|
|
{
|
|
name: "HeadStringNotRootStringOmitEmpty",
|
|
data: struct {
|
|
A struct {
|
|
A string `json:"a,string,omitempty"`
|
|
}
|
|
}{A: struct {
|
|
A string `json:"a,string,omitempty"`
|
|
}{A: "foo"}},
|
|
},
|
|
|
|
// HeadStringPtrNotRoot
|
|
{
|
|
name: "HeadStringPtrNotRoot",
|
|
data: struct {
|
|
A struct {
|
|
A *string `json:"a"`
|
|
}
|
|
}{A: struct {
|
|
A *string `json:"a"`
|
|
}{stringptr("foo")}},
|
|
},
|
|
{
|
|
name: "HeadStringPtrNotRootOmitEmpty",
|
|
data: struct {
|
|
A struct {
|
|
A *string `json:"a,omitempty"`
|
|
}
|
|
}{A: struct {
|
|
A *string `json:"a,omitempty"`
|
|
}{stringptr("foo")}},
|
|
},
|
|
{
|
|
name: "HeadStringPtrNotRootString",
|
|
data: struct {
|
|
A struct {
|
|
A *string `json:"a,string"`
|
|
}
|
|
}{A: struct {
|
|
A *string `json:"a,string"`
|
|
}{stringptr("foo")}},
|
|
},
|
|
{
|
|
name: "HeadStringPtrNotRootStringOmitEmpty",
|
|
data: struct {
|
|
A struct {
|
|
A *string `json:"a,string,omitempty"`
|
|
}
|
|
}{A: struct {
|
|
A *string `json:"a,string,omitempty"`
|
|
}{stringptr("foo")}},
|
|
},
|
|
|
|
// HeadStringPtrNilNotRoot
|
|
{
|
|
name: "HeadStringPtrNilNotRoot",
|
|
data: struct {
|
|
A struct {
|
|
A *string `json:"a"`
|
|
}
|
|
}{},
|
|
},
|
|
{
|
|
name: "HeadStringPtrNilNotRootOmitEmpty",
|
|
data: struct {
|
|
A struct {
|
|
A *string `json:"a,omitempty"`
|
|
}
|
|
}{},
|
|
},
|
|
{
|
|
name: "HeadStringPtrNilNotRootString",
|
|
data: struct {
|
|
A struct {
|
|
A *string `json:"a,string"`
|
|
}
|
|
}{},
|
|
},
|
|
{
|
|
name: "HeadStringPtrNilNotRootStringOmitEmpty",
|
|
data: struct {
|
|
A struct {
|
|
A *string `json:"a,string,omitempty"`
|
|
}
|
|
}{},
|
|
},
|
|
|
|
// PtrHeadStringZeroNotRoot
|
|
{
|
|
name: "PtrHeadStringZeroNotRoot",
|
|
data: struct {
|
|
A *struct {
|
|
A string `json:"a"`
|
|
}
|
|
}{A: new(struct {
|
|
A string `json:"a"`
|
|
})},
|
|
},
|
|
{
|
|
name: "PtrHeadStringZeroNotRootOmitEmpty",
|
|
data: struct {
|
|
A *struct {
|
|
A string `json:"a,omitempty"`
|
|
}
|
|
}{A: new(struct {
|
|
A string `json:"a,omitempty"`
|
|
})},
|
|
},
|
|
{
|
|
name: "PtrHeadStringZeroNotRootString",
|
|
data: struct {
|
|
A *struct {
|
|
A string `json:"a,string"`
|
|
}
|
|
}{A: new(struct {
|
|
A string `json:"a,string"`
|
|
})},
|
|
},
|
|
{
|
|
name: "PtrHeadStringZeroNotRootStringOmitEmpty",
|
|
data: struct {
|
|
A *struct {
|
|
A string `json:"a,string,omitempty"`
|
|
}
|
|
}{A: new(struct {
|
|
A string `json:"a,string,omitempty"`
|
|
})},
|
|
},
|
|
|
|
// PtrHeadStringNotRoot
|
|
{
|
|
name: "PtrHeadStringNotRoot",
|
|
data: struct {
|
|
A *struct {
|
|
A string `json:"a"`
|
|
}
|
|
}{A: &(struct {
|
|
A string `json:"a"`
|
|
}{A: "foo"})},
|
|
},
|
|
{
|
|
name: "PtrHeadStringNotRootOmitEmpty",
|
|
data: struct {
|
|
A *struct {
|
|
A string `json:"a,omitempty"`
|
|
}
|
|
}{A: &(struct {
|
|
A string `json:"a,omitempty"`
|
|
}{A: "foo"})},
|
|
},
|
|
{
|
|
name: "PtrHeadStringNotRootString",
|
|
data: struct {
|
|
A *struct {
|
|
A string `json:"a,string"`
|
|
}
|
|
}{A: &(struct {
|
|
A string `json:"a,string"`
|
|
}{A: "foo"})},
|
|
},
|
|
{
|
|
name: "PtrHeadStringNotRootStringOmitEmpty",
|
|
data: struct {
|
|
A *struct {
|
|
A string `json:"a,string,omitempty"`
|
|
}
|
|
}{A: &(struct {
|
|
A string `json:"a,string,omitempty"`
|
|
}{A: "foo"})},
|
|
},
|
|
|
|
// PtrHeadStringPtrNotRoot
|
|
{
|
|
name: "PtrHeadStringPtrNotRoot",
|
|
data: struct {
|
|
A *struct {
|
|
A *string `json:"a"`
|
|
}
|
|
}{A: &(struct {
|
|
A *string `json:"a"`
|
|
}{A: stringptr("foo")})},
|
|
},
|
|
{
|
|
name: "PtrHeadStringPtrNotRootOmitEmpty",
|
|
data: struct {
|
|
A *struct {
|
|
A *string `json:"a,omitempty"`
|
|
}
|
|
}{A: &(struct {
|
|
A *string `json:"a,omitempty"`
|
|
}{A: stringptr("foo")})},
|
|
},
|
|
{
|
|
name: "PtrHeadStringPtrNotRootString",
|
|
data: struct {
|
|
A *struct {
|
|
A *string `json:"a,string"`
|
|
}
|
|
}{A: &(struct {
|
|
A *string `json:"a,string"`
|
|
}{A: stringptr("foo")})},
|
|
},
|
|
{
|
|
name: "PtrHeadStringPtrNotRootStringOmitEmpty",
|
|
data: struct {
|
|
A *struct {
|
|
A *string `json:"a,string,omitempty"`
|
|
}
|
|
}{A: &(struct {
|
|
A *string `json:"a,string,omitempty"`
|
|
}{A: stringptr("foo")})},
|
|
},
|
|
|
|
// PtrHeadStringPtrNilNotRoot
|
|
{
|
|
name: "PtrHeadStringPtrNilNotRoot",
|
|
data: struct {
|
|
A *struct {
|
|
A *string `json:"a"`
|
|
}
|
|
}{A: &(struct {
|
|
A *string `json:"a"`
|
|
}{A: nil})},
|
|
},
|
|
{
|
|
name: "PtrHeadStringPtrNilNotRootOmitEmpty",
|
|
data: struct {
|
|
A *struct {
|
|
A *string `json:"a,omitempty"`
|
|
}
|
|
}{A: &(struct {
|
|
A *string `json:"a,omitempty"`
|
|
}{A: nil})},
|
|
},
|
|
{
|
|
name: "PtrHeadStringPtrNilNotRootString",
|
|
data: struct {
|
|
A *struct {
|
|
A *string `json:"a,string"`
|
|
}
|
|
}{A: &(struct {
|
|
A *string `json:"a,string"`
|
|
}{A: nil})},
|
|
},
|
|
{
|
|
name: "PtrHeadStringPtrNilNotRootStringOmitEmpty",
|
|
data: struct {
|
|
A *struct {
|
|
A *string `json:"a,string,omitempty"`
|
|
}
|
|
}{A: &(struct {
|
|
A *string `json:"a,string,omitempty"`
|
|
}{A: nil})},
|
|
},
|
|
|
|
// PtrHeadStringNilNotRoot
|
|
{
|
|
name: "PtrHeadStringNilNotRoot",
|
|
data: struct {
|
|
A *struct {
|
|
A *string `json:"a"`
|
|
}
|
|
}{A: nil},
|
|
},
|
|
{
|
|
name: "PtrHeadStringNilNotRootOmitEmpty",
|
|
data: struct {
|
|
A *struct {
|
|
A *string `json:"a,omitempty"`
|
|
} `json:",omitempty"`
|
|
}{A: nil},
|
|
},
|
|
{
|
|
name: "PtrHeadStringNilNotRootString",
|
|
data: struct {
|
|
A *struct {
|
|
A *string `json:"a,string"`
|
|
} `json:",string"`
|
|
}{A: nil},
|
|
},
|
|
{
|
|
name: "PtrHeadStringNilNotRootStringOmitEmpty",
|
|
data: struct {
|
|
A *struct {
|
|
A *string `json:"a,string,omitempty"`
|
|
} `json:",string,omitempty"`
|
|
}{A: nil},
|
|
},
|
|
|
|
// HeadStringZeroMultiFieldsNotRoot
|
|
{
|
|
name: "HeadStringZeroMultiFieldsNotRoot",
|
|
data: struct {
|
|
A struct {
|
|
A string `json:"a"`
|
|
}
|
|
B struct {
|
|
B string `json:"b"`
|
|
}
|
|
}{},
|
|
},
|
|
{
|
|
name: "HeadStringZeroMultiFieldsNotRootOmitEmpty",
|
|
data: struct {
|
|
A struct {
|
|
A string `json:"a,omitempty"`
|
|
}
|
|
B struct {
|
|
B string `json:"b,omitempty"`
|
|
}
|
|
}{},
|
|
},
|
|
{
|
|
name: "HeadStringZeroMultiFieldsNotRootString",
|
|
data: struct {
|
|
A struct {
|
|
A string `json:"a,string"`
|
|
}
|
|
B struct {
|
|
B string `json:"b,string"`
|
|
}
|
|
}{},
|
|
},
|
|
{
|
|
name: "HeadStringZeroMultiFieldsNotRootStringOmitEmpty",
|
|
data: struct {
|
|
A struct {
|
|
A string `json:"a,string,omitempty"`
|
|
}
|
|
B struct {
|
|
B string `json:"b,string,omitempty"`
|
|
}
|
|
}{},
|
|
},
|
|
|
|
// HeadStringMultiFieldsNotRoot
|
|
{
|
|
name: "HeadStringMultiFieldsNotRoot",
|
|
data: struct {
|
|
A struct {
|
|
A string `json:"a"`
|
|
}
|
|
B struct {
|
|
B string `json:"b"`
|
|
}
|
|
}{A: struct {
|
|
A string `json:"a"`
|
|
}{A: "foo"}, B: struct {
|
|
B string `json:"b"`
|
|
}{B: "bar"}},
|
|
},
|
|
{
|
|
name: "HeadStringMultiFieldsNotRootOmitEmpty",
|
|
data: struct {
|
|
A struct {
|
|
A string `json:"a,omitempty"`
|
|
}
|
|
B struct {
|
|
B string `json:"b,omitempty"`
|
|
}
|
|
}{A: struct {
|
|
A string `json:"a,omitempty"`
|
|
}{A: "foo"}, B: struct {
|
|
B string `json:"b,omitempty"`
|
|
}{B: "bar"}},
|
|
},
|
|
{
|
|
name: "HeadStringMultiFieldsNotRootString",
|
|
data: struct {
|
|
A struct {
|
|
A string `json:"a,string"`
|
|
}
|
|
B struct {
|
|
B string `json:"b,string"`
|
|
}
|
|
}{A: struct {
|
|
A string `json:"a,string"`
|
|
}{A: "foo"}, B: struct {
|
|
B string `json:"b,string"`
|
|
}{B: "bar"}},
|
|
},
|
|
{
|
|
name: "HeadStringMultiFieldsNotRootStringOmitEmpty",
|
|
data: struct {
|
|
A struct {
|
|
A string `json:"a,string,omitempty"`
|
|
}
|
|
B struct {
|
|
B string `json:"b,string,omitempty"`
|
|
}
|
|
}{A: struct {
|
|
A string `json:"a,string,omitempty"`
|
|
}{A: "foo"}, B: struct {
|
|
B string `json:"b,string,omitempty"`
|
|
}{B: "bar"}},
|
|
},
|
|
|
|
// HeadStringPtrMultiFieldsNotRoot
|
|
{
|
|
name: "HeadStringPtrMultiFieldsNotRoot",
|
|
data: struct {
|
|
A struct {
|
|
A *string `json:"a"`
|
|
}
|
|
B struct {
|
|
B *string `json:"b"`
|
|
}
|
|
}{A: struct {
|
|
A *string `json:"a"`
|
|
}{A: stringptr("foo")}, B: struct {
|
|
B *string `json:"b"`
|
|
}{B: stringptr("bar")}},
|
|
},
|
|
{
|
|
name: "HeadStringPtrMultiFieldsNotRootOmitEmpty",
|
|
data: struct {
|
|
A struct {
|
|
A *string `json:"a,omitempty"`
|
|
}
|
|
B struct {
|
|
B *string `json:"b,omitempty"`
|
|
}
|
|
}{A: struct {
|
|
A *string `json:"a,omitempty"`
|
|
}{A: stringptr("foo")}, B: struct {
|
|
B *string `json:"b,omitempty"`
|
|
}{B: stringptr("bar")}},
|
|
},
|
|
{
|
|
name: "HeadStringPtrMultiFieldsNotRootString",
|
|
data: struct {
|
|
A struct {
|
|
A *string `json:"a,string"`
|
|
}
|
|
B struct {
|
|
B *string `json:"b,string"`
|
|
}
|
|
}{A: struct {
|
|
A *string `json:"a,string"`
|
|
}{A: stringptr("foo")}, B: struct {
|
|
B *string `json:"b,string"`
|
|
}{B: stringptr("bar")}},
|
|
},
|
|
{
|
|
name: "HeadStringPtrMultiFieldsNotRootStringOmitEmpty",
|
|
data: struct {
|
|
A struct {
|
|
A *string `json:"a,string,omitempty"`
|
|
}
|
|
B struct {
|
|
B *string `json:"b,string,omitempty"`
|
|
}
|
|
}{A: struct {
|
|
A *string `json:"a,string,omitempty"`
|
|
}{A: stringptr("foo")}, B: struct {
|
|
B *string `json:"b,string,omitempty"`
|
|
}{B: stringptr("bar")}},
|
|
},
|
|
|
|
// HeadStringPtrNilMultiFieldsNotRoot
|
|
{
|
|
name: "HeadStringPtrNilMultiFieldsNotRoot",
|
|
data: struct {
|
|
A struct {
|
|
A *string `json:"a"`
|
|
}
|
|
B struct {
|
|
B *string `json:"b"`
|
|
}
|
|
}{A: struct {
|
|
A *string `json:"a"`
|
|
}{A: nil}, B: struct {
|
|
B *string `json:"b"`
|
|
}{B: nil}},
|
|
},
|
|
{
|
|
name: "HeadStringPtrNilMultiFieldsNotRootOmitEmpty",
|
|
data: struct {
|
|
A struct {
|
|
A *string `json:"a,omitempty"`
|
|
}
|
|
B struct {
|
|
B *string `json:"b,omitempty"`
|
|
}
|
|
}{A: struct {
|
|
A *string `json:"a,omitempty"`
|
|
}{A: nil}, B: struct {
|
|
B *string `json:"b,omitempty"`
|
|
}{B: nil}},
|
|
},
|
|
{
|
|
name: "HeadStringPtrNilMultiFieldsNotRootString",
|
|
data: struct {
|
|
A struct {
|
|
A *string `json:"a,string"`
|
|
}
|
|
B struct {
|
|
B *string `json:"b,string"`
|
|
}
|
|
}{A: struct {
|
|
A *string `json:"a,string"`
|
|
}{A: nil}, B: struct {
|
|
B *string `json:"b,string"`
|
|
}{B: nil}},
|
|
},
|
|
{
|
|
name: "HeadStringPtrNilMultiFieldsNotRootStringOmitEmpty",
|
|
data: struct {
|
|
A struct {
|
|
A *string `json:"a,string,omitempty"`
|
|
}
|
|
B struct {
|
|
B *string `json:"b,string,omitempty"`
|
|
}
|
|
}{A: struct {
|
|
A *string `json:"a,string,omitempty"`
|
|
}{A: nil}, B: struct {
|
|
B *string `json:"b,string,omitempty"`
|
|
}{B: nil}},
|
|
},
|
|
|
|
// PtrHeadStringZeroMultiFieldsNotRoot
|
|
{
|
|
name: "PtrHeadStringZeroMultiFieldsNotRoot",
|
|
data: &struct {
|
|
A struct {
|
|
A string `json:"a"`
|
|
}
|
|
B struct {
|
|
B string `json:"b"`
|
|
}
|
|
}{},
|
|
},
|
|
{
|
|
name: "PtrHeadStringZeroMultiFieldsNotRootOmitEmpty",
|
|
data: &struct {
|
|
A struct {
|
|
A string `json:"a,omitempty"`
|
|
}
|
|
B struct {
|
|
B string `json:"b,omitempty"`
|
|
}
|
|
}{},
|
|
},
|
|
{
|
|
name: "PtrHeadStringZeroMultiFieldsNotRootString",
|
|
data: &struct {
|
|
A struct {
|
|
A string `json:"a,string"`
|
|
}
|
|
B struct {
|
|
B string `json:"b,string"`
|
|
}
|
|
}{},
|
|
},
|
|
{
|
|
name: "PtrHeadStringZeroMultiFieldsNotRootStringOmitEmpty",
|
|
data: &struct {
|
|
A struct {
|
|
A string `json:"a,string,omitempty"`
|
|
}
|
|
B struct {
|
|
B string `json:"b,string,omitempty"`
|
|
}
|
|
}{},
|
|
},
|
|
|
|
// PtrHeadStringMultiFieldsNotRoot
|
|
{
|
|
name: "PtrHeadStringMultiFieldsNotRoot",
|
|
data: &struct {
|
|
A struct {
|
|
A string `json:"a"`
|
|
}
|
|
B struct {
|
|
B string `json:"b"`
|
|
}
|
|
}{A: struct {
|
|
A string `json:"a"`
|
|
}{A: "foo"}, B: struct {
|
|
B string `json:"b"`
|
|
}{B: "bar"}},
|
|
},
|
|
{
|
|
name: "PtrHeadStringMultiFieldsNotRootOmitEmpty",
|
|
data: &struct {
|
|
A struct {
|
|
A string `json:"a,omitempty"`
|
|
}
|
|
B struct {
|
|
B string `json:"b,omitempty"`
|
|
}
|
|
}{A: struct {
|
|
A string `json:"a,omitempty"`
|
|
}{A: "foo"}, B: struct {
|
|
B string `json:"b,omitempty"`
|
|
}{B: "bar"}},
|
|
},
|
|
{
|
|
name: "PtrHeadStringMultiFieldsNotRootString",
|
|
data: &struct {
|
|
A struct {
|
|
A string `json:"a,string"`
|
|
}
|
|
B struct {
|
|
B string `json:"b,string"`
|
|
}
|
|
}{A: struct {
|
|
A string `json:"a,string"`
|
|
}{A: "foo"}, B: struct {
|
|
B string `json:"b,string"`
|
|
}{B: "bar"}},
|
|
},
|
|
{
|
|
name: "PtrHeadStringMultiFieldsNotRootStringOmitEmpty",
|
|
data: &struct {
|
|
A struct {
|
|
A string `json:"a,string,omitempty"`
|
|
}
|
|
B struct {
|
|
B string `json:"b,string,omitempty"`
|
|
}
|
|
}{A: struct {
|
|
A string `json:"a,string,omitempty"`
|
|
}{A: "foo"}, B: struct {
|
|
B string `json:"b,string,omitempty"`
|
|
}{B: "bar"}},
|
|
},
|
|
|
|
// PtrHeadStringPtrMultiFieldsNotRoot
|
|
{
|
|
name: "PtrHeadStringPtrMultiFieldsNotRoot",
|
|
data: &struct {
|
|
A *struct {
|
|
A *string `json:"a"`
|
|
}
|
|
B *struct {
|
|
B *string `json:"b"`
|
|
}
|
|
}{A: &(struct {
|
|
A *string `json:"a"`
|
|
}{A: stringptr("foo")}), B: &(struct {
|
|
B *string `json:"b"`
|
|
}{B: stringptr("bar")})},
|
|
},
|
|
{
|
|
name: "PtrHeadStringPtrMultiFieldsNotRootOmitEmpty",
|
|
data: &struct {
|
|
A *struct {
|
|
A *string `json:"a,omitempty"`
|
|
}
|
|
B *struct {
|
|
B *string `json:"b,omitempty"`
|
|
}
|
|
}{A: &(struct {
|
|
A *string `json:"a,omitempty"`
|
|
}{A: stringptr("foo")}), B: &(struct {
|
|
B *string `json:"b,omitempty"`
|
|
}{B: stringptr("bar")})},
|
|
},
|
|
{
|
|
name: "PtrHeadStringPtrMultiFieldsNotRootString",
|
|
data: &struct {
|
|
A *struct {
|
|
A *string `json:"a,string"`
|
|
}
|
|
B *struct {
|
|
B *string `json:"b,string"`
|
|
}
|
|
}{A: &(struct {
|
|
A *string `json:"a,string"`
|
|
}{A: stringptr("foo")}), B: &(struct {
|
|
B *string `json:"b,string"`
|
|
}{B: stringptr("bar")})},
|
|
},
|
|
{
|
|
name: "PtrHeadStringPtrMultiFieldsNotRootStringOmitEmpty",
|
|
data: &struct {
|
|
A *struct {
|
|
A *string `json:"a,string,omitempty"`
|
|
}
|
|
B *struct {
|
|
B *string `json:"b,string,omitempty"`
|
|
}
|
|
}{A: &(struct {
|
|
A *string `json:"a,string,omitempty"`
|
|
}{A: stringptr("foo")}), B: &(struct {
|
|
B *string `json:"b,string,omitempty"`
|
|
}{B: stringptr("bar")})},
|
|
},
|
|
|
|
// PtrHeadStringPtrNilMultiFieldsNotRoot
|
|
{
|
|
name: "PtrHeadStringPtrNilMultiFieldsNotRoot",
|
|
data: &struct {
|
|
A *struct {
|
|
A *string `json:"a"`
|
|
}
|
|
B *struct {
|
|
B *string `json:"b"`
|
|
}
|
|
}{A: nil, B: nil},
|
|
},
|
|
{
|
|
name: "PtrHeadStringPtrNilMultiFieldsNotRootOmitEmpty",
|
|
data: &struct {
|
|
A *struct {
|
|
A *string `json:"a,omitempty"`
|
|
}
|
|
B *struct {
|
|
B *string `json:"b,omitempty"`
|
|
}
|
|
}{A: nil, B: nil},
|
|
},
|
|
{
|
|
name: "PtrHeadStringPtrNilMultiFieldsNotRootString",
|
|
data: &struct {
|
|
A *struct {
|
|
A *string `json:"a,string"`
|
|
}
|
|
B *struct {
|
|
B *string `json:"b,string"`
|
|
}
|
|
}{A: nil, B: nil},
|
|
},
|
|
{
|
|
name: "PtrHeadStringPtrNilMultiFieldsNotRootStringOmitEmpty",
|
|
data: &struct {
|
|
A *struct {
|
|
A *string `json:"a,string,omitempty"`
|
|
}
|
|
B *struct {
|
|
B *string `json:"b,string,omitempty"`
|
|
}
|
|
}{A: nil, B: nil},
|
|
},
|
|
|
|
< |