go-json/cover_string_test.go

1806 lines
36 KiB
Go
Raw Permalink Normal View History

2021-01-16 16:16:26 +03:00
package json_test
import (
"bytes"
"testing"
"github.com/goccy/go-json"
)
func TestCoverString(t *testing.T) {
type structString struct {
A string `json:"a"`
}
2021-01-20 18:22:20 +03:00
type structStringOmitEmpty struct {
A string `json:"a,omitempty"`
}
type structStringString struct {
A string `json:"a,string"`
}
2021-01-16 16:16:26 +03:00
type structStringPtr struct {
A *string `json:"a"`
}
2021-01-20 18:22:20 +03:00
type structStringPtrOmitEmpty struct {
A *string `json:"a,omitempty"`
}
type structStringPtrString struct {
A *string `json:"a,string"`
}
2021-01-16 16:16:26 +03:00
tests := []struct {
2021-01-22 12:19:54 +03:00
name string
data interface{}
2021-01-16 16:16:26 +03:00
}{
2021-01-20 18:22:20 +03:00
// HeadStringZero
2021-01-16 16:16:26 +03:00
{
2021-01-22 12:19:54 +03:00
name: "HeadStringZero",
2021-01-16 16:16:26 +03:00
data: struct {
A string `json:"a"`
}{},
},
2021-01-20 18:22:20 +03:00
{
2021-01-22 12:19:54 +03:00
name: "HeadStringZeroOmitEmpty",
2021-01-20 18:22:20 +03:00
data: struct {
A string `json:"a,omitempty"`
}{},
},
{
2021-01-22 12:19:54 +03:00
name: "HeadStringZeroString",
2021-01-20 18:22:20 +03:00
data: struct {
A string `json:"a,string"`
}{},
},
// HeadString
2021-01-16 16:16:26 +03:00
{
2021-01-22 12:19:54 +03:00
name: "HeadString",
2021-01-16 16:16:26 +03:00
data: struct {
A string `json:"a"`
}{A: "foo"},
},
2021-01-20 18:22:20 +03:00
{
2021-01-22 12:19:54 +03:00
name: "HeadStringOmitEmpty",
2021-01-20 18:22:20 +03:00
data: struct {
A string `json:"a,omitempty"`
}{A: "foo"},
},
{
2021-01-22 12:19:54 +03:00
name: "HeadStringString",
2021-01-20 18:22:20 +03:00
data: struct {
A string `json:"a,string"`
}{A: "foo"},
},
// HeadStringPtr
2021-01-16 16:16:26 +03:00
{
2021-01-22 12:19:54 +03:00
name: "HeadStringPtr",
2021-01-16 16:16:26 +03:00
data: struct {
A *string `json:"a"`
}{A: stringptr("foo")},
},
2021-01-20 18:22:20 +03:00
{
2021-01-22 12:19:54 +03:00
name: "HeadStringPtrOmitEmpty",
2021-01-20 18:22:20 +03:00
data: struct {
A *string `json:"a,omitempty"`
}{A: stringptr("foo")},
},
{
2021-01-22 12:19:54 +03:00
name: "HeadStringPtrString",
2021-01-20 18:22:20 +03:00
data: struct {
A *string `json:"a,string"`
}{A: stringptr("foo")},
},
// HeadStringPtrNil
2021-01-16 16:16:26 +03:00
{
2021-01-22 12:19:54 +03:00
name: "HeadStringPtrNil",
2021-01-16 16:16:26 +03:00
data: struct {
A *string `json:"a"`
}{A: nil},
},
2021-01-20 18:22:20 +03:00
{
2021-01-22 12:19:54 +03:00
name: "HeadStringPtrNilOmitEmpty",
2021-01-20 18:22:20 +03:00
data: struct {
A *string `json:"a,omitempty"`
}{A: nil},
},
{
2021-01-22 12:19:54 +03:00
name: "HeadStringPtrNilString",
2021-01-20 18:22:20 +03:00
data: struct {
A *string `json:"a,string"`
}{A: nil},
},
// PtrHeadStringZero
2021-01-16 16:16:26 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringZero",
2021-01-16 16:16:26 +03:00
data: &struct {
A string `json:"a"`
}{},
},
2021-01-20 18:22:20 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringZeroOmitEmpty",
2021-01-20 18:22:20 +03:00
data: &struct {
A string `json:"a,omitempty"`
}{},
},
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringZeroString",
2021-01-20 18:22:20 +03:00
data: &struct {
A string `json:"a,string"`
}{},
},
// PtrHeadString
2021-01-16 16:16:26 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadString",
2021-01-16 16:16:26 +03:00
data: &struct {
A string `json:"a"`
}{A: "foo"},
},
2021-01-20 18:22:20 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringOmitEmpty",
2021-01-20 18:22:20 +03:00
data: &struct {
A string `json:"a,omitempty"`
}{A: "foo"},
},
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringString",
2021-01-20 18:22:20 +03:00
data: &struct {
A string `json:"a,string"`
}{A: "foo"},
},
// PtrHeadStringPtr
2021-01-16 16:16:26 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringPtr",
2021-01-16 16:16:26 +03:00
data: &struct {
A *string `json:"a"`
}{A: stringptr("foo")},
},
2021-01-20 18:22:20 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringPtrOmitEmpty",
2021-01-20 18:22:20 +03:00
data: &struct {
A *string `json:"a,omitempty"`
}{A: stringptr("foo")},
},
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringPtrString",
2021-01-20 18:22:20 +03:00
data: &struct {
A *string `json:"a,string"`
}{A: stringptr("foo")},
},
// PtrHeadStringPtrNil
2021-01-16 16:16:26 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringPtrNil",
2021-01-16 16:16:26 +03:00
data: &struct {
A *string `json:"a"`
}{A: nil},
},
2021-01-20 18:22:20 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringPtrNilOmitEmpty",
2021-01-20 18:22:20 +03:00
data: &struct {
A *string `json:"a,omitempty"`
}{A: nil},
},
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringPtrNilString",
2021-01-20 18:22:20 +03:00
data: &struct {
A *string `json:"a,string"`
}{A: nil},
},
// PtrHeadStringNil
2021-01-16 16:16:26 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringNil",
2021-01-16 16:16:26 +03:00
data: (*struct {
A *string `json:"a"`
})(nil),
},
2021-01-20 18:22:20 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringNilOmitEmpty",
2021-01-20 18:22:20 +03:00
data: (*struct {
A *string `json:"a,omitempty"`
})(nil),
},
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringNilString",
2021-01-20 18:22:20 +03:00
data: (*struct {
A *string `json:"a,string"`
})(nil),
},
// HeadStringZeroMultiFields
2021-01-16 16:16:26 +03:00
{
2021-01-22 12:19:54 +03:00
name: "HeadStringZeroMultiFields",
2021-01-16 16:16:26 +03:00
data: struct {
A string `json:"a"`
B string `json:"b"`
2021-01-22 12:19:54 +03:00
C string `json:"c"`
2021-01-16 16:16:26 +03:00
}{},
},
2021-01-20 18:22:20 +03:00
{
2021-01-22 12:19:54 +03:00
name: "HeadStringZeroMultiFieldsOmitEmpty",
2021-01-20 18:22:20 +03:00
data: struct {
A string `json:"a,omitempty"`
B string `json:"b,omitempty"`
2021-01-22 12:19:54 +03:00
C string `json:"c,omitempty"`
2021-01-20 18:22:20 +03:00
}{},
},
{
2021-01-22 12:19:54 +03:00
name: "HeadStringZeroMultiFieldsString",
2021-01-20 18:22:20 +03:00
data: struct {
A string `json:"a,string"`
B string `json:"b,string"`
2021-01-22 12:19:54 +03:00
C string `json:"c,string"`
2021-01-20 18:22:20 +03:00
}{},
},
// HeadStringMultiFields
2021-01-16 16:16:26 +03:00
{
2021-01-22 12:19:54 +03:00
name: "HeadStringMultiFields",
2021-01-16 16:16:26 +03:00
data: struct {
A string `json:"a"`
B string `json:"b"`
2021-01-22 12:19:54 +03:00
C string `json:"c"`
}{A: "foo", B: "bar", C: "baz"},
2021-01-16 16:16:26 +03:00
},
2021-01-20 18:22:20 +03:00
{
2021-01-22 12:19:54 +03:00
name: "HeadStringMultiFieldsOmitEmpty",
2021-01-20 18:22:20 +03:00
data: struct {
A string `json:"a,omitempty"`
B string `json:"b,omitempty"`
2021-01-22 12:19:54 +03:00
C string `json:"c,omitempty"`
}{A: "foo", B: "bar", C: "baz"},
2021-01-20 18:22:20 +03:00
},
{
2021-01-22 12:19:54 +03:00
name: "HeadStringMultiFieldsString",
2021-01-20 18:22:20 +03:00
data: struct {
A string `json:"a,string"`
B string `json:"b,string"`
2021-01-22 12:19:54 +03:00
C string `json:"c,string"`
}{A: "foo", B: "bar", C: "baz"},
2021-01-20 18:22:20 +03:00
},
// HeadStringPtrMultiFields
2021-01-16 16:16:26 +03:00
{
2021-01-22 12:19:54 +03:00
name: "HeadStringPtrMultiFields",
2021-01-16 16:16:26 +03:00
data: struct {
A *string `json:"a"`
B *string `json:"b"`
2021-01-22 12:19:54 +03:00
C *string `json:"c"`
}{A: stringptr("foo"), B: stringptr("bar"), C: stringptr("baz")},
2021-01-16 16:16:26 +03:00
},
2021-01-20 18:22:20 +03:00
{
2021-01-22 12:19:54 +03:00
name: "HeadStringPtrMultiFieldsOmitEmpty",
2021-01-20 18:22:20 +03:00
data: struct {
A *string `json:"a,omitempty"`
B *string `json:"b,omitempty"`
2021-01-22 12:19:54 +03:00
C *string `json:"c,omitempty"`
}{A: stringptr("foo"), B: stringptr("bar"), C: stringptr("baz")},
2021-01-20 18:22:20 +03:00
},
{
2021-01-22 12:19:54 +03:00
name: "HeadStringPtrMultiFieldsString",
2021-01-20 18:22:20 +03:00
data: struct {
A *string `json:"a,string"`
B *string `json:"b,string"`
2021-01-22 12:19:54 +03:00
C *string `json:"c,string"`
}{A: stringptr("foo"), B: stringptr("bar"), C: stringptr("baz")},
2021-01-20 18:22:20 +03:00
},
// HeadStringPtrNilMultiFields
2021-01-16 16:16:26 +03:00
{
2021-01-22 12:19:54 +03:00
name: "HeadStringPtrNilMultiFields",
2021-01-16 16:16:26 +03:00
data: struct {
A *string `json:"a"`
B *string `json:"b"`
2021-01-22 12:19:54 +03:00
C *string `json:"c"`
}{A: nil, B: nil, C: nil},
2021-01-16 16:16:26 +03:00
},
2021-01-20 18:22:20 +03:00
{
2021-01-22 12:19:54 +03:00
name: "HeadStringPtrNilMultiFieldsOmitEmpty",
2021-01-20 18:22:20 +03:00
data: struct {
A *string `json:"a,omitempty"`
B *string `json:"b,omitempty"`
2021-01-22 12:19:54 +03:00
C *string `json:"c,omitempty"`
}{A: nil, B: nil, C: nil},
2021-01-20 18:22:20 +03:00
},
{
2021-01-22 12:19:54 +03:00
name: "HeadStringPtrNilMultiFieldsString",
2021-01-20 18:22:20 +03:00
data: struct {
A *string `json:"a,string"`
B *string `json:"b,string"`
2021-01-22 12:19:54 +03:00
C *string `json:"c,string"`
}{A: nil, B: nil, C: nil},
2021-01-20 18:22:20 +03:00
},
// PtrHeadStringZeroMultiFields
2021-01-16 16:16:26 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringZeroMultiFields",
2021-01-16 16:16:26 +03:00
data: &struct {
A string `json:"a"`
B string `json:"b"`
2021-01-22 12:19:54 +03:00
C string `json:"c"`
2021-01-16 16:16:26 +03:00
}{},
},
2021-01-20 18:22:20 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringZeroMultiFieldsOmitEmpty",
2021-01-20 18:22:20 +03:00
data: &struct {
A string `json:"a,omitempty"`
B string `json:"b,omitempty"`
2021-01-22 12:19:54 +03:00
C string `json:"c,omitempty"`
2021-01-20 18:22:20 +03:00
}{},
},
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringZeroMultiFieldsString",
2021-01-20 18:22:20 +03:00
data: &struct {
A string `json:"a,string"`
B string `json:"b,string"`
2021-01-22 12:19:54 +03:00
C string `json:"c,string"`
2021-01-20 18:22:20 +03:00
}{},
},
// PtrHeadStringMultiFields
2021-01-16 16:16:26 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringMultiFields",
2021-01-16 16:16:26 +03:00
data: &struct {
A string `json:"a"`
B string `json:"b"`
2021-01-22 12:19:54 +03:00
C string `json:"c"`
}{A: "foo", B: "bar", C: "baz"},
2021-01-16 16:16:26 +03:00
},
2021-01-20 18:22:20 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringMultiFieldsOmitEmpty",
2021-01-20 18:22:20 +03:00
data: &struct {
A string `json:"a,omitempty"`
B string `json:"b,omitempty"`
2021-01-22 12:19:54 +03:00
C string `json:"c,omitempty"`
}{A: "foo", B: "bar", C: "baz"},
2021-01-20 18:22:20 +03:00
},
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringMultiFieldsString",
2021-01-20 18:22:20 +03:00
data: &struct {
A string `json:"a,string"`
B string `json:"b,string"`
2021-01-22 12:19:54 +03:00
C string `json:"c,string"`
}{A: "foo", B: "bar", C: "baz"},
2021-01-20 18:22:20 +03:00
},
// PtrHeadStringPtrMultiFields
2021-01-16 16:16:26 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringPtrMultiFields",
2021-01-16 16:16:26 +03:00
data: &struct {
A *string `json:"a"`
B *string `json:"b"`
2021-01-22 12:19:54 +03:00
C *string `json:"c"`
}{A: stringptr("foo"), B: stringptr("bar"), C: stringptr("baz")},
2021-01-16 16:16:26 +03:00
},
2021-01-20 18:22:20 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringPtrMultiFieldsOmitEmpty",
2021-01-20 18:22:20 +03:00
data: &struct {
A *string `json:"a,omitempty"`
B *string `json:"b,omitempty"`
2021-01-22 12:19:54 +03:00
C *string `json:"c,omitempty"`
}{A: stringptr("foo"), B: stringptr("bar"), C: stringptr("baz")},
2021-01-20 18:22:20 +03:00
},
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringPtrMultiFieldsString",
2021-01-20 18:22:20 +03:00
data: &struct {
A *string `json:"a,string"`
B *string `json:"b,string"`
2021-01-22 12:19:54 +03:00
C *string `json:"c,string"`
}{A: stringptr("foo"), B: stringptr("bar"), C: stringptr("baz")},
2021-01-20 18:22:20 +03:00
},
// PtrHeadStringPtrNilMultiFields
2021-01-16 16:16:26 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringPtrNilMultiFields",
2021-01-16 16:16:26 +03:00
data: &struct {
A *string `json:"a"`
B *string `json:"b"`
2021-01-22 12:19:54 +03:00
C *string `json:"c"`
}{A: nil, B: nil, C: nil},
2021-01-16 16:16:26 +03:00
},
2021-01-20 18:22:20 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringPtrNilMultiFieldsOmitEmpty",
2021-01-20 18:22:20 +03:00
data: &struct {
A *string `json:"a,omitempty"`
B *string `json:"b,omitempty"`
2021-01-22 12:19:54 +03:00
C *string `json:"c,omitempty"`
}{A: nil, B: nil, C: nil},
2021-01-20 18:22:20 +03:00
},
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringPtrNilMultiFieldsString",
2021-01-20 18:22:20 +03:00
data: &struct {
A *string `json:"a,string"`
B *string `json:"b,string"`
2021-01-22 12:19:54 +03:00
C *string `json:"c,string"`
}{A: nil, B: nil, C: nil},
2021-01-20 18:22:20 +03:00
},
// PtrHeadStringNilMultiFields
2021-01-16 16:16:26 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringNilMultiFields",
2021-01-16 16:16:26 +03:00
data: (*struct {
A *string `json:"a"`
B *string `json:"b"`
2021-01-22 12:19:54 +03:00
C *string `json:"c"`
2021-01-16 16:16:26 +03:00
})(nil),
},
2021-01-20 18:22:20 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringNilMultiFieldsOmitEmpty",
2021-01-20 18:22:20 +03:00
data: (*struct {
A *string `json:"a,omitempty"`
B *string `json:"b,omitempty"`
2021-01-22 12:19:54 +03:00
C *string `json:"c,omitempty"`
2021-01-20 18:22:20 +03:00
})(nil),
},
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringNilMultiFieldsString",
2021-01-20 18:22:20 +03:00
data: (*struct {
A *string `json:"a,string"`
B *string `json:"b,string"`
2021-01-22 12:19:54 +03:00
C *string `json:"c,string"`
2021-01-20 18:22:20 +03:00
})(nil),
},
// HeadStringZeroNotRoot
2021-01-16 16:16:26 +03:00
{
2021-01-22 12:19:54 +03:00
name: "HeadStringZeroNotRoot",
2021-01-16 16:16:26 +03:00
data: struct {
A struct {
A string `json:"a"`
}
}{},
},
{
2021-01-22 12:19:54 +03:00
name: "HeadStringZeroNotRootOmitEmpty",
2021-01-16 16:16:26 +03:00
data: struct {
A struct {
2021-01-20 18:22:20 +03:00
A string `json:"a,omitempty"`
2021-01-16 16:16:26 +03:00
}
2021-01-20 18:22:20 +03:00
}{},
2021-01-16 16:16:26 +03:00
},
{
2021-01-22 12:19:54 +03:00
name: "HeadStringZeroNotRootString",
2021-01-20 18:22:20 +03:00
data: struct {
A struct {
A string `json:"a,string"`
}
}{},
},
// HeadStringNotRoot
{
2021-01-22 12:19:54 +03:00
name: "HeadStringNotRoot",
2021-01-20 18:22:20 +03:00
data: struct {
A struct {
A string `json:"a"`
}
}{A: struct {
A string `json:"a"`
}{A: "foo"}},
},
{
2021-01-22 12:19:54 +03:00
name: "HeadStringNotRootOmitEmpty",
2021-01-20 18:22:20 +03:00
data: struct {
A struct {
A string `json:"a,omitempty"`
}
}{A: struct {
A string `json:"a,omitempty"`
}{A: "foo"}},
},
{
2021-01-22 12:19:54 +03:00
name: "HeadStringNotRootString",
2021-01-20 18:22:20 +03:00
data: struct {
A struct {
A string `json:"a,string"`
}
}{A: struct {
A string `json:"a,string"`
}{A: "foo"}},
},
// HeadStringPtrNotRoot
{
2021-01-22 12:19:54 +03:00
name: "HeadStringPtrNotRoot",
2021-01-16 16:16:26 +03:00
data: struct {
A struct {
A *string `json:"a"`
}
}{A: struct {
A *string `json:"a"`
}{stringptr("foo")}},
},
2021-01-20 18:22:20 +03:00
{
2021-01-22 12:19:54 +03:00
name: "HeadStringPtrNotRootOmitEmpty",
2021-01-20 18:22:20 +03:00
data: struct {
A struct {
A *string `json:"a,omitempty"`
}
}{A: struct {
A *string `json:"a,omitempty"`
}{stringptr("foo")}},
},
{
2021-01-22 12:19:54 +03:00
name: "HeadStringPtrNotRootString",
2021-01-20 18:22:20 +03:00
data: struct {
A struct {
A *string `json:"a,string"`
}
}{A: struct {
A *string `json:"a,string"`
}{stringptr("foo")}},
},
// HeadStringPtrNilNotRoot
2021-01-16 16:16:26 +03:00
{
2021-01-22 12:19:54 +03:00
name: "HeadStringPtrNilNotRoot",
2021-01-16 16:16:26 +03:00
data: struct {
A struct {
A *string `json:"a"`
}
}{},
},
2021-01-20 18:22:20 +03:00
{
2021-01-22 12:19:54 +03:00
name: "HeadStringPtrNilNotRootOmitEmpty",
2021-01-20 18:22:20 +03:00
data: struct {
A struct {
A *string `json:"a,omitempty"`
}
}{},
},
{
2021-01-22 12:19:54 +03:00
name: "HeadStringPtrNilNotRootString",
2021-01-20 18:22:20 +03:00
data: struct {
A struct {
A *string `json:"a,string"`
}
}{},
},
// PtrHeadStringZeroNotRoot
2021-01-16 16:16:26 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringZeroNotRoot",
2021-01-16 16:16:26 +03:00
data: struct {
A *struct {
A string `json:"a"`
}
}{A: new(struct {
A string `json:"a"`
})},
},
2021-01-20 18:22:20 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringZeroNotRootOmitEmpty",
2021-01-20 18:22:20 +03:00
data: struct {
A *struct {
A string `json:"a,omitempty"`
}
}{A: new(struct {
A string `json:"a,omitempty"`
})},
},
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringZeroNotRootString",
2021-01-20 18:22:20 +03:00
data: struct {
A *struct {
A string `json:"a,string"`
}
}{A: new(struct {
A string `json:"a,string"`
})},
},
// PtrHeadStringNotRoot
2021-01-16 16:16:26 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringNotRoot",
2021-01-16 16:16:26 +03:00
data: struct {
A *struct {
A string `json:"a"`
}
}{A: &(struct {
A string `json:"a"`
}{A: "foo"})},
},
2021-01-20 18:22:20 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringNotRootOmitEmpty",
2021-01-20 18:22:20 +03:00
data: struct {
A *struct {
A string `json:"a,omitempty"`
}
}{A: &(struct {
A string `json:"a,omitempty"`
}{A: "foo"})},
},
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringNotRootString",
2021-01-20 18:22:20 +03:00
data: struct {
A *struct {
A string `json:"a,string"`
}
}{A: &(struct {
A string `json:"a,string"`
}{A: "foo"})},
},
// PtrHeadStringPtrNotRoot
2021-01-16 16:16:26 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringPtrNotRoot",
2021-01-16 16:16:26 +03:00
data: struct {
A *struct {
A *string `json:"a"`
}
}{A: &(struct {
A *string `json:"a"`
}{A: stringptr("foo")})},
},
2021-01-20 18:22:20 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringPtrNotRootOmitEmpty",
2021-01-20 18:22:20 +03:00
data: struct {
A *struct {
A *string `json:"a,omitempty"`
}
}{A: &(struct {
A *string `json:"a,omitempty"`
}{A: stringptr("foo")})},
},
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringPtrNotRootString",
2021-01-20 18:22:20 +03:00
data: struct {
A *struct {
A *string `json:"a,string"`
}
}{A: &(struct {
A *string `json:"a,string"`
}{A: stringptr("foo")})},
},
// PtrHeadStringPtrNilNotRoot
2021-01-16 16:16:26 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringPtrNilNotRoot",
2021-01-16 16:16:26 +03:00
data: struct {
A *struct {
A *string `json:"a"`
}
}{A: &(struct {
A *string `json:"a"`
}{A: nil})},
},
2021-01-20 18:22:20 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringPtrNilNotRootOmitEmpty",
2021-01-20 18:22:20 +03:00
data: struct {
A *struct {
A *string `json:"a,omitempty"`
}
}{A: &(struct {
A *string `json:"a,omitempty"`
}{A: nil})},
},
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringPtrNilNotRootString",
2021-01-20 18:22:20 +03:00
data: struct {
A *struct {
A *string `json:"a,string"`
}
}{A: &(struct {
A *string `json:"a,string"`
}{A: nil})},
},
// PtrHeadStringNilNotRoot
2021-01-16 16:16:26 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringNilNotRoot",
2021-01-16 16:16:26 +03:00
data: struct {
A *struct {
A *string `json:"a"`
}
}{A: nil},
},
2021-01-20 18:22:20 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringNilNotRootOmitEmpty",
2021-01-20 18:22:20 +03:00
data: struct {
A *struct {
A *string `json:"a,omitempty"`
} `json:",omitempty"`
}{A: nil},
},
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringNilNotRootString",
2021-01-20 18:22:20 +03:00
data: struct {
A *struct {
A *string `json:"a,string"`
} `json:",string"`
}{A: nil},
},
// HeadStringZeroMultiFieldsNotRoot
2021-01-16 16:16:26 +03:00
{
2021-01-22 12:19:54 +03:00
name: "HeadStringZeroMultiFieldsNotRoot",
2021-01-16 16:16:26 +03:00
data: struct {
A struct {
A string `json:"a"`
}
B struct {
B string `json:"b"`
}
}{},
},
2021-01-20 18:22:20 +03:00
{
2021-01-22 12:19:54 +03:00
name: "HeadStringZeroMultiFieldsNotRootOmitEmpty",
2021-01-20 18:22:20 +03:00
data: struct {
A struct {
A string `json:"a,omitempty"`
}
B struct {
B string `json:"b,omitempty"`
}
}{},
},
{
2021-01-22 12:19:54 +03:00
name: "HeadStringZeroMultiFieldsNotRootString",
2021-01-20 18:22:20 +03:00
data: struct {
A struct {
A string `json:"a,string"`
}
B struct {
B string `json:"b,string"`
}
}{},
},
// HeadStringMultiFieldsNotRoot
2021-01-16 16:16:26 +03:00
{
2021-01-22 12:19:54 +03:00
name: "HeadStringMultiFieldsNotRoot",
2021-01-16 16:16:26 +03:00
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"}},
},
2021-01-20 18:22:20 +03:00
{
2021-01-22 12:19:54 +03:00
name: "HeadStringMultiFieldsNotRootOmitEmpty",
2021-01-20 18:22:20 +03:00
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"}},
},
{
2021-01-22 12:19:54 +03:00
name: "HeadStringMultiFieldsNotRootString",
2021-01-20 18:22:20 +03:00
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"}},
},
// HeadStringPtrMultiFieldsNotRoot
2021-01-16 16:16:26 +03:00
{
2021-01-22 12:19:54 +03:00
name: "HeadStringPtrMultiFieldsNotRoot",
2021-01-16 16:16:26 +03:00
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")}},
},
2021-01-20 18:22:20 +03:00
{
2021-01-22 12:19:54 +03:00
name: "HeadStringPtrMultiFieldsNotRootOmitEmpty",
2021-01-20 18:22:20 +03:00
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")}},
},
{
2021-01-22 12:19:54 +03:00
name: "HeadStringPtrMultiFieldsNotRootString",
2021-01-20 18:22:20 +03:00
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")}},
},
// HeadStringPtrNilMultiFieldsNotRoot
2021-01-16 16:16:26 +03:00
{
2021-01-22 12:19:54 +03:00
name: "HeadStringPtrNilMultiFieldsNotRoot",
2021-01-16 16:16:26 +03:00
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}},
},
{
2021-01-22 12:19:54 +03:00
name: "HeadStringPtrNilMultiFieldsNotRootOmitEmpty",
2021-01-20 18:22:20 +03:00
data: struct {
2021-01-16 16:16:26 +03:00
A struct {
2021-01-20 18:22:20 +03:00
A *string `json:"a,omitempty"`
2021-01-16 16:16:26 +03:00
}
B struct {
2021-01-20 18:22:20 +03:00
B *string `json:"b,omitempty"`
2021-01-16 16:16:26 +03:00
}
2021-01-20 18:22:20 +03:00
}{A: struct {
A *string `json:"a,omitempty"`
}{A: nil}, B: struct {
B *string `json:"b,omitempty"`
}{B: nil}},
},
{
2021-01-22 12:19:54 +03:00
name: "HeadStringPtrNilMultiFieldsNotRootString",
2021-01-20 18:22:20 +03:00
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}},
},
// PtrHeadStringZeroMultiFieldsNotRoot
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringZeroMultiFieldsNotRoot",
2021-01-20 18:22:20 +03:00
data: &struct {
A struct {
A string `json:"a"`
}
B struct {
B string `json:"b"`
}
}{},
},
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringZeroMultiFieldsNotRootOmitEmpty",
2021-01-20 18:22:20 +03:00
data: &struct {
A struct {
A string `json:"a,omitempty"`
}
B struct {
B string `json:"b,omitempty"`
}
}{},
},
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringZeroMultiFieldsNotRootString",
2021-01-20 18:22:20 +03:00
data: &struct {
A struct {
A string `json:"a,string"`
}
B struct {
B string `json:"b,string"`
}
}{},
},
// PtrHeadStringMultiFieldsNotRoot
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringMultiFieldsNotRoot",
2021-01-16 16:16:26 +03:00
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"}},
},
2021-01-20 18:22:20 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringMultiFieldsNotRootOmitEmpty",
2021-01-20 18:22:20 +03:00
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"}},
},
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringMultiFieldsNotRootString",
2021-01-20 18:22:20 +03:00
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"}},
},
// PtrHeadStringPtrMultiFieldsNotRoot
2021-01-16 16:16:26 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringPtrMultiFieldsNotRoot",
2021-01-16 16:16:26 +03:00
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")})},
},
2021-01-20 18:22:20 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringPtrMultiFieldsNotRootOmitEmpty",
2021-01-20 18:22:20 +03:00
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")})},
},
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringPtrMultiFieldsNotRootString",
2021-01-20 18:22:20 +03:00
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")})},
},
// PtrHeadStringPtrNilMultiFieldsNotRoot
2021-01-16 16:16:26 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringPtrNilMultiFieldsNotRoot",
2021-01-16 16:16:26 +03:00
data: &struct {
A *struct {
A *string `json:"a"`
}
B *struct {
B *string `json:"b"`
}
}{A: nil, B: nil},
},
2021-01-20 18:22:20 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringPtrNilMultiFieldsNotRootOmitEmpty",
2021-01-20 18:22:20 +03:00
data: &struct {
A *struct {
A *string `json:"a,omitempty"`
}
B *struct {
B *string `json:"b,omitempty"`
}
}{A: nil, B: nil},
},
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringPtrNilMultiFieldsNotRootString",
2021-01-20 18:22:20 +03:00
data: &struct {
A *struct {
A *string `json:"a,string"`
}
B *struct {
B *string `json:"b,string"`
}
}{A: nil, B: nil},
},
// PtrHeadStringNilMultiFieldsNotRoot
2021-01-16 16:16:26 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringNilMultiFieldsNotRoot",
2021-01-16 16:16:26 +03:00
data: (*struct {
A *struct {
A *string `json:"a"`
}
B *struct {
B *string `json:"b"`
}
})(nil),
},
2021-01-20 18:22:20 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringNilMultiFieldsNotRootOmitEmpty",
2021-01-20 18:22:20 +03:00
data: (*struct {
A *struct {
A *string `json:"a,omitempty"`
}
B *struct {
B *string `json:"b,omitempty"`
}
})(nil),
},
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringNilMultiFieldsNotRootString",
2021-01-20 18:22:20 +03:00
data: (*struct {
A *struct {
A *string `json:"a,string"`
}
B *struct {
B *string `json:"b,string"`
}
})(nil),
},
// PtrHeadStringDoubleMultiFieldsNotRoot
2021-01-16 16:16:26 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringDoubleMultiFieldsNotRoot",
2021-01-16 16:16:26 +03:00
data: &struct {
A *struct {
A string `json:"a"`
B string `json:"b"`
2021-01-22 12:19:54 +03:00
C string `json:"c"`
2021-01-16 16:16:26 +03:00
}
B *struct {
A string `json:"a"`
B string `json:"b"`
2021-01-22 12:19:54 +03:00
C string `json:"c"`
2021-01-16 16:16:26 +03:00
}
}{A: &(struct {
A string `json:"a"`
B string `json:"b"`
2021-01-22 12:19:54 +03:00
C string `json:"c"`
}{A: "foo", B: "bar", C: "baz"}), B: &(struct {
2021-01-16 16:16:26 +03:00
A string `json:"a"`
B string `json:"b"`
2021-01-22 12:19:54 +03:00
C string `json:"c"`
}{A: "foo", B: "bar", C: "baz"})},
2021-01-16 16:16:26 +03:00
},
2021-01-20 18:22:20 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringDoubleMultiFieldsNotRootOmitEmpty",
2021-01-20 18:22:20 +03:00
data: &struct {
A *struct {
A string `json:"a,omitempty"`
B string `json:"b,omitempty"`
}
B *struct {
A string `json:"a,omitempty"`
B string `json:"b,omitempty"`
}
}{A: &(struct {
A string `json:"a,omitempty"`
B string `json:"b,omitempty"`
}{A: "foo", B: "bar"}), B: &(struct {
A string `json:"a,omitempty"`
B string `json:"b,omitempty"`
}{A: "foo", B: "bar"})},
},
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringDoubleMultiFieldsNotRootString",
2021-01-20 18:22:20 +03:00
data: &struct {
A *struct {
A string `json:"a,string"`
B string `json:"b,string"`
}
B *struct {
A string `json:"a,string"`
B string `json:"b,string"`
}
}{A: &(struct {
A string `json:"a,string"`
B string `json:"b,string"`
}{A: "foo", B: "bar"}), B: &(struct {
A string `json:"a,string"`
B string `json:"b,string"`
}{A: "foo", B: "bar"})},
},
// PtrHeadStringNilDoubleMultiFieldsNotRoot
2021-01-16 16:16:26 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringNilDoubleMultiFieldsNotRoot",
2021-01-16 16:16:26 +03:00
data: &struct {
A *struct {
A string `json:"a"`
B string `json:"b"`
}
B *struct {
A string `json:"a"`
B string `json:"b"`
}
}{A: nil, B: nil},
},
2021-01-20 18:22:20 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringNilDoubleMultiFieldsNotRootOmitEmpty",
2021-01-20 18:22:20 +03:00
data: &struct {
A *struct {
A string `json:"a,omitempty"`
B string `json:"b,omitempty"`
}
B *struct {
A string `json:"a,omitempty"`
B string `json:"b,omitempty"`
}
}{A: nil, B: nil},
},
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringNilDoubleMultiFieldsNotRootString",
2021-01-20 18:22:20 +03:00
data: &struct {
A *struct {
A string `json:"a,string"`
B string `json:"b,string"`
}
B *struct {
A string `json:"a,string"`
B string `json:"b,string"`
}
}{A: nil, B: nil},
},
// PtrHeadStringNilDoubleMultiFieldsNotRoot
2021-01-16 16:16:26 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringNilDoubleMultiFieldsNotRoot",
2021-01-16 16:16:26 +03:00
data: (*struct {
A *struct {
A string `json:"a"`
B string `json:"b"`
}
B *struct {
2021-01-20 18:22:20 +03:00
A string `json:"a"`
B string `json:"b"`
}
})(nil),
},
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringNilDoubleMultiFieldsNotRootOmitEmpty",
2021-01-20 18:22:20 +03:00
data: (*struct {
A *struct {
A string `json:"a,omitempty"`
B string `json:"b,omitempty"`
}
B *struct {
A string `json:"a,omitempty"`
B string `json:"b,omitempty"`
}
})(nil),
},
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringNilDoubleMultiFieldsNotRootString",
2021-01-20 18:22:20 +03:00
data: (*struct {
A *struct {
A string `json:"a,string"`
B string `json:"b,string"`
}
B *struct {
A string `json:"a,string"`
B string `json:"b,string"`
}
})(nil),
},
// PtrHeadStringPtrDoubleMultiFieldsNotRoot
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringPtrDoubleMultiFieldsNotRoot",
2021-01-20 18:22:20 +03:00
data: &struct {
A *struct {
A *string `json:"a"`
B *string `json:"b"`
}
B *struct {
A *string `json:"a"`
B *string `json:"b"`
}
}{A: &(struct {
A *string `json:"a"`
B *string `json:"b"`
}{A: stringptr("foo"), B: stringptr("bar")}), B: &(struct {
A *string `json:"a"`
B *string `json:"b"`
}{A: stringptr("foo"), B: stringptr("bar")})},
},
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringPtrDoubleMultiFieldsNotRootOmitEmpty",
2021-01-20 18:22:20 +03:00
data: &struct {
A *struct {
A *string `json:"a,omitempty"`
B *string `json:"b,omitempty"`
}
B *struct {
A *string `json:"a,omitempty"`
B *string `json:"b,omitempty"`
}
}{A: &(struct {
A *string `json:"a,omitempty"`
B *string `json:"b,omitempty"`
}{A: stringptr("foo"), B: stringptr("bar")}), B: &(struct {
A *string `json:"a,omitempty"`
B *string `json:"b,omitempty"`
}{A: stringptr("foo"), B: stringptr("bar")})},
},
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringPtrDoubleMultiFieldsNotRootString",
2021-01-20 18:22:20 +03:00
data: &struct {
A *struct {
A *string `json:"a,string"`
B *string `json:"b,string"`
}
B *struct {
A *string `json:"a,string"`
B *string `json:"b,string"`
}
}{A: &(struct {
A *string `json:"a,string"`
B *string `json:"b,string"`
}{A: stringptr("foo"), B: stringptr("bar")}), B: &(struct {
A *string `json:"a,string"`
B *string `json:"b,string"`
}{A: stringptr("foo"), B: stringptr("bar")})},
},
// PtrHeadStringPtrNilDoubleMultiFieldsNotRoot
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringPtrNilDoubleMultiFieldsNotRoot",
2021-01-20 18:22:20 +03:00
data: &struct {
A *struct {
A *string `json:"a"`
B *string `json:"b"`
}
B *struct {
A *string `json:"a"`
B *string `json:"b"`
}
}{A: nil, B: nil},
},
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringPtrNilDoubleMultiFieldsNotRootOmitEmpty",
2021-01-20 18:22:20 +03:00
data: &struct {
A *struct {
A *string `json:"a,omitempty"`
B *string `json:"b,omitempty"`
}
B *struct {
A *string `json:"a,omitempty"`
B *string `json:"b,omitempty"`
}
}{A: nil, B: nil},
},
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringPtrNilDoubleMultiFieldsNotRootString",
2021-01-20 18:22:20 +03:00
data: &struct {
A *struct {
A *string `json:"a,string"`
B *string `json:"b,string"`
}
B *struct {
A *string `json:"a,string"`
B *string `json:"b,string"`
2021-01-16 16:16:26 +03:00
}
2021-01-20 18:22:20 +03:00
}{A: nil, B: nil},
2021-01-16 16:16:26 +03:00
},
2021-01-20 18:22:20 +03:00
// PtrHeadStringPtrNilDoubleMultiFieldsNotRoot
2021-01-16 16:16:26 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringPtrNilDoubleMultiFieldsNotRoot",
2021-01-20 18:22:20 +03:00
data: (*struct {
2021-01-16 16:16:26 +03:00
A *struct {
A *string `json:"a"`
B *string `json:"b"`
}
B *struct {
A *string `json:"a"`
B *string `json:"b"`
}
2021-01-20 18:22:20 +03:00
})(nil),
2021-01-16 16:16:26 +03:00
},
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringPtrNilDoubleMultiFieldsNotRootOmitEmpty",
2021-01-20 18:22:20 +03:00
data: (*struct {
2021-01-16 16:16:26 +03:00
A *struct {
2021-01-20 18:22:20 +03:00
A *string `json:"a,omitempty"`
B *string `json:"b,omitempty"`
2021-01-16 16:16:26 +03:00
}
B *struct {
2021-01-20 18:22:20 +03:00
A *string `json:"a,omitempty"`
B *string `json:"b,omitempty"`
2021-01-16 16:16:26 +03:00
}
2021-01-20 18:22:20 +03:00
})(nil),
2021-01-16 16:16:26 +03:00
},
{
2021-01-22 12:19:54 +03:00
name: "PtrHeadStringPtrNilDoubleMultiFieldsNotRootString",
2021-01-16 16:16:26 +03:00
data: (*struct {
A *struct {
2021-01-20 18:22:20 +03:00
A *string `json:"a,string"`
B *string `json:"b,string"`
2021-01-16 16:16:26 +03:00
}
B *struct {
2021-01-20 18:22:20 +03:00
A *string `json:"a,string"`
B *string `json:"b,string"`
2021-01-16 16:16:26 +03:00
}
})(nil),
},
2021-01-20 18:22:20 +03:00
// AnonymousHeadString
2021-01-16 16:16:26 +03:00
{
2021-01-22 12:19:54 +03:00
name: "AnonymousHeadString",
2021-01-16 16:16:26 +03:00
data: struct {
structString
B string `json:"b"`
}{
structString: structString{A: "foo"},
B: "bar",
},
},
2021-01-20 18:22:20 +03:00
{
2021-01-22 12:19:54 +03:00
name: "AnonymousHeadStringOmitEmpty",
2021-01-20 18:22:20 +03:00
data: struct {
structStringOmitEmpty
B string `json:"b,omitempty"`
}{
structStringOmitEmpty: structStringOmitEmpty{A: "foo"},
B: "bar",
},
},
{
2021-01-22 12:19:54 +03:00
name: "AnonymousHeadStringString",
2021-01-20 18:22:20 +03:00
data: struct {
structStringString
B string `json:"b,string"`
}{
structStringString: structStringString{A: "foo"},
B: "bar",
},
},
// PtrAnonymousHeadString
2021-01-16 16:16:26 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrAnonymousHeadString",
2021-01-16 16:16:26 +03:00
data: struct {
*structString
B string `json:"b"`
}{
structString: &structString{A: "foo"},
B: "bar",
},
},
2021-01-20 18:22:20 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrAnonymousHeadStringOmitEmpty",
2021-01-20 18:22:20 +03:00
data: struct {
*structStringOmitEmpty
B string `json:"b,omitempty"`
}{
structStringOmitEmpty: &structStringOmitEmpty{A: "foo"},
B: "bar",
},
},
{
2021-01-22 12:19:54 +03:00
name: "PtrAnonymousHeadStringString",
2021-01-20 18:22:20 +03:00
data: struct {
*structStringString
B string `json:"b,string"`
}{
structStringString: &structStringString{A: "foo"},
B: "bar",
},
},
// NilPtrAnonymousHeadString
2021-01-16 16:16:26 +03:00
{
2021-01-22 12:19:54 +03:00
name: "NilPtrAnonymousHeadString",
2021-01-16 16:16:26 +03:00
data: struct {
*structString
B string `json:"b"`
}{
structString: nil,
B: "baz",
},
},
2021-01-20 18:22:20 +03:00
{
2021-01-22 12:19:54 +03:00
name: "NilPtrAnonymousHeadStringOmitEmpty",
2021-01-20 18:22:20 +03:00
data: struct {
*structStringOmitEmpty
B string `json:"b,omitempty"`
}{
structStringOmitEmpty: nil,
B: "baz",
},
},
{
2021-01-22 12:19:54 +03:00
name: "NilPtrAnonymousHeadStringString",
2021-01-20 18:22:20 +03:00
data: struct {
*structStringString
B string `json:"b,string"`
}{
structStringString: nil,
B: "baz",
},
},
// AnonymousHeadStringPtr
2021-01-16 16:16:26 +03:00
{
2021-01-22 12:19:54 +03:00
name: "AnonymousHeadStringPtr",
2021-01-16 16:16:26 +03:00
data: struct {
structStringPtr
B *string `json:"b"`
}{
structStringPtr: structStringPtr{A: stringptr("foo")},
B: stringptr("bar"),
},
},
2021-01-20 18:22:20 +03:00
{
2021-01-22 12:19:54 +03:00
name: "AnonymousHeadStringPtrOmitEmpty",
2021-01-20 18:22:20 +03:00
data: struct {
structStringPtrOmitEmpty
B *string `json:"b,omitempty"`
}{
structStringPtrOmitEmpty: structStringPtrOmitEmpty{A: stringptr("foo")},
B: stringptr("bar"),
},
},
{
2021-01-22 12:19:54 +03:00
name: "AnonymousHeadStringPtrString",
2021-01-20 18:22:20 +03:00
data: struct {
structStringPtrString
B *string `json:"b,string"`
}{
structStringPtrString: structStringPtrString{A: stringptr("foo")},
B: stringptr("bar"),
},
},
// AnonymousHeadStringPtrNil
2021-01-16 16:16:26 +03:00
{
2021-01-22 12:19:54 +03:00
name: "AnonymousHeadStringPtrNil",
2021-01-16 16:16:26 +03:00
data: struct {
structStringPtr
B *string `json:"b"`
}{
structStringPtr: structStringPtr{A: nil},
B: stringptr("foo"),
},
},
2021-01-20 18:22:20 +03:00
{
2021-01-22 12:19:54 +03:00
name: "AnonymousHeadStringPtrNilOmitEmpty",
2021-01-20 18:22:20 +03:00
data: struct {
structStringPtrOmitEmpty
B *string `json:"b,omitempty"`
}{
structStringPtrOmitEmpty: structStringPtrOmitEmpty{A: nil},
B: stringptr("foo"),
},
},
{
2021-01-22 12:19:54 +03:00
name: "AnonymousHeadStringPtrNilString",
2021-01-20 18:22:20 +03:00
data: struct {
structStringPtrString
B *string `json:"b,string"`
}{
structStringPtrString: structStringPtrString{A: nil},
B: stringptr("foo"),
},
},
// PtrAnonymousHeadStringPtr
2021-01-16 16:16:26 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrAnonymousHeadStringPtr",
2021-01-16 16:16:26 +03:00
data: struct {
*structStringPtr
B *string `json:"b"`
}{
structStringPtr: &structStringPtr{A: stringptr("foo")},
B: stringptr("bar"),
},
},
2021-01-20 18:22:20 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrAnonymousHeadStringPtrOmitEmpty",
2021-01-20 18:22:20 +03:00
data: struct {
*structStringPtrOmitEmpty
B *string `json:"b,omitempty"`
}{
structStringPtrOmitEmpty: &structStringPtrOmitEmpty{A: stringptr("foo")},
B: stringptr("bar"),
},
},
{
2021-01-22 12:19:54 +03:00
name: "PtrAnonymousHeadStringPtrString",
2021-01-20 18:22:20 +03:00
data: struct {
*structStringPtrString
B *string `json:"b,string"`
}{
structStringPtrString: &structStringPtrString{A: stringptr("foo")},
B: stringptr("bar"),
},
},
// NilPtrAnonymousHeadStringPtr
2021-01-16 16:16:26 +03:00
{
2021-01-22 12:19:54 +03:00
name: "NilPtrAnonymousHeadStringPtr",
2021-01-16 16:16:26 +03:00
data: struct {
*structStringPtr
B *string `json:"b"`
}{
structStringPtr: nil,
B: stringptr("foo"),
},
},
2021-01-20 18:22:20 +03:00
{
2021-01-22 12:19:54 +03:00
name: "NilPtrAnonymousHeadStringPtrOmitEmpty",
2021-01-20 18:22:20 +03:00
data: struct {
*structStringPtrOmitEmpty
B *string `json:"b,omitempty"`
}{
structStringPtrOmitEmpty: nil,
B: stringptr("foo"),
},
},
{
2021-01-22 12:19:54 +03:00
name: "NilPtrAnonymousHeadStringPtrString",
2021-01-20 18:22:20 +03:00
data: struct {
*structStringPtrString
B *string `json:"b,string"`
}{
structStringPtrString: nil,
B: stringptr("foo"),
},
},
// AnonymousHeadStringOnly
2021-01-16 16:16:26 +03:00
{
2021-01-22 12:19:54 +03:00
name: "AnonymousHeadStringOnly",
2021-01-16 16:16:26 +03:00
data: struct {
structString
}{
structString: structString{A: "foo"},
},
},
2021-01-20 18:22:20 +03:00
{
2021-01-22 12:19:54 +03:00
name: "AnonymousHeadStringOnlyOmitEmpty",
2021-01-20 18:22:20 +03:00
data: struct {
structStringOmitEmpty
}{
structStringOmitEmpty: structStringOmitEmpty{A: "foo"},
},
},
{
2021-01-22 12:19:54 +03:00
name: "AnonymousHeadStringOnlyString",
2021-01-20 18:22:20 +03:00
data: struct {
structStringString
}{
structStringString: structStringString{A: "foo"},
},
},
// PtrAnonymousHeadStringOnly
2021-01-16 16:16:26 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrAnonymousHeadStringOnly",
2021-01-16 16:16:26 +03:00
data: struct {
*structString
}{
structString: &structString{A: "foo"},
},
},
2021-01-20 18:22:20 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrAnonymousHeadStringOnlyOmitEmpty",
2021-01-20 18:22:20 +03:00
data: struct {
*structStringOmitEmpty
}{
structStringOmitEmpty: &structStringOmitEmpty{A: "foo"},
},
},
{
2021-01-22 12:19:54 +03:00
name: "PtrAnonymousHeadStringOnlyString",
2021-01-20 18:22:20 +03:00
data: struct {
*structStringString
}{
structStringString: &structStringString{A: "foo"},
},
},
// NilPtrAnonymousHeadStringOnly
2021-01-16 16:16:26 +03:00
{
2021-01-22 12:19:54 +03:00
name: "NilPtrAnonymousHeadStringOnly",
2021-01-16 16:16:26 +03:00
data: struct {
*structString
}{
structString: nil,
},
},
2021-01-20 18:22:20 +03:00
{
2021-01-22 12:19:54 +03:00
name: "NilPtrAnonymousHeadStringOnlyOmitEmpty",
2021-01-20 18:22:20 +03:00
data: struct {
*structStringOmitEmpty
}{
structStringOmitEmpty: nil,
},
},
{
2021-01-22 12:19:54 +03:00
name: "NilPtrAnonymousHeadStringOnlyString",
2021-01-20 18:22:20 +03:00
data: struct {
*structStringString
}{
structStringString: nil,
},
},
// AnonymousHeadStringPtrOnly
2021-01-16 16:16:26 +03:00
{
2021-01-22 12:19:54 +03:00
name: "AnonymousHeadStringPtrOnly",
2021-01-16 16:16:26 +03:00
data: struct {
structStringPtr
}{
structStringPtr: structStringPtr{A: stringptr("foo")},
},
},
2021-01-20 18:22:20 +03:00
{
2021-01-22 12:19:54 +03:00
name: "AnonymousHeadStringPtrOnlyOmitEmpty",
2021-01-20 18:22:20 +03:00
data: struct {
structStringPtrOmitEmpty
}{
structStringPtrOmitEmpty: structStringPtrOmitEmpty{A: stringptr("foo")},
},
},
{
2021-01-22 12:19:54 +03:00
name: "AnonymousHeadStringPtrOnlyString",
2021-01-20 18:22:20 +03:00
data: struct {
structStringPtrString
}{
structStringPtrString: structStringPtrString{A: stringptr("foo")},
},
},
// AnonymousHeadStringPtrNilOnly
2021-01-16 16:16:26 +03:00
{
2021-01-22 12:19:54 +03:00
name: "AnonymousHeadStringPtrNilOnly",
2021-01-16 16:16:26 +03:00
data: struct {
structStringPtr
}{
structStringPtr: structStringPtr{A: nil},
},
},
2021-01-20 18:22:20 +03:00
{
2021-01-22 12:19:54 +03:00
name: "AnonymousHeadStringPtrNilOnlyOmitEmpty",
2021-01-20 18:22:20 +03:00
data: struct {
structStringPtrOmitEmpty
}{
structStringPtrOmitEmpty: structStringPtrOmitEmpty{A: nil},
},
},
{
2021-01-22 12:19:54 +03:00
name: "AnonymousHeadStringPtrNilOnlyString",
2021-01-20 18:22:20 +03:00
data: struct {
structStringPtrString
}{
structStringPtrString: structStringPtrString{A: nil},
},
},
// PtrAnonymousHeadStringPtrOnly
2021-01-16 16:16:26 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrAnonymousHeadStringPtrOnly",
2021-01-16 16:16:26 +03:00
data: struct {
*structStringPtr
}{
structStringPtr: &structStringPtr{A: stringptr("foo")},
},
},
2021-01-20 18:22:20 +03:00
{
2021-01-22 12:19:54 +03:00
name: "PtrAnonymousHeadStringPtrOnlyOmitEmpty",
2021-01-20 18:22:20 +03:00
data: struct {
*structStringPtrOmitEmpty
}{
structStringPtrOmitEmpty: &structStringPtrOmitEmpty{A: stringptr("foo")},
},
},
{
2021-01-22 12:19:54 +03:00
name: "PtrAnonymousHeadStringPtrOnlyString",
2021-01-20 18:22:20 +03:00
data: struct {
*structStringPtrString
}{
structStringPtrString: &structStringPtrString{A: stringptr("foo")},
},
},
// NilPtrAnonymousHeadStringPtrOnly
2021-01-16 16:16:26 +03:00
{
2021-01-22 12:19:54 +03:00
name: "NilPtrAnonymousHeadStringPtrOnly",
2021-01-16 16:16:26 +03:00
data: struct {
*structStringPtr
}{
structStringPtr: nil,
},
},
2021-01-20 18:22:20 +03:00
{
2021-01-22 12:19:54 +03:00
name: "NilPtrAnonymousHeadStringPtrOnlyOmitEmpty",
2021-01-20 18:22:20 +03:00
data: struct {
*structStringPtrOmitEmpty
}{
structStringPtrOmitEmpty: nil,
},
},
{
2021-01-22 12:19:54 +03:00
name: "NilPtrAnonymousHeadStringPtrOnlyString",
2021-01-20 18:22:20 +03:00
data: struct {
*structStringPtrString
}{
structStringPtrString: nil,
},
},
2021-01-16 16:16:26 +03:00
}
for _, test := range tests {
2021-01-20 18:22:20 +03:00
for _, indent := range []bool{true, false} {
for _, htmlEscape := range []bool{true, false} {
var buf bytes.Buffer
enc := json.NewEncoder(&buf)
enc.SetEscapeHTML(htmlEscape)
if indent {
enc.SetIndent("", " ")
}
if err := enc.Encode(test.data); err != nil {
2021-01-22 12:19:54 +03:00
t.Fatalf("%s(htmlEscape:%T): %v: %s", test.name, htmlEscape, test.data, err)
2021-01-20 18:22:20 +03:00
}
stdresult := encodeByEncodingJSON(test.data, indent, htmlEscape)
if buf.String() != stdresult {
t.Errorf("%s(htmlEscape:%T): doesn't compatible with encoding/json. expected %q but got %q", test.name, htmlEscape, stdresult, buf.String())
}
2021-01-16 16:16:26 +03:00
}
}
}
}