go-json/cover_slice_test.go

1862 lines
37 KiB
Go
Raw Normal View History

2021-03-03 08:54:40 +03:00
package json_test
import (
"bytes"
"fmt"
"testing"
"github.com/goccy/go-json"
)
func TestCoverSlice(t *testing.T) {
type structSlice struct {
A []int `json:"a"`
}
type structSliceOmitEmpty struct {
A []int `json:"a,omitempty"`
}
type structSliceString struct {
A []int `json:"a,string"`
}
type structSlicePtr struct {
A *[]int `json:"a"`
}
type structSlicePtrOmitEmpty struct {
A *[]int `json:"a,omitempty"`
}
type structSlicePtrString struct {
A *[]int `json:"a,string"`
}
type structSlicePtrContent struct {
A []*int `json:"a"`
}
type structSliceOmitEmptyPtrContent struct {
A []*int `json:"a,omitempty"`
}
type structSliceStringPtrContent struct {
A []*int `json:"a,string"`
}
type structSlicePtrPtrContent struct {
A *[]*int `json:"a"`
}
type structSlicePtrOmitEmptyPtrContent struct {
A *[]*int `json:"a,omitempty"`
}
type structSlicePtrStringPtrContent struct {
A *[]*int `json:"a,string"`
}
tests := []struct {
name string
data interface{}
}{
// HeadSliceZero
{
name: "HeadSliceZero",
data: struct {
A []int `json:"a"`
}{},
},
{
name: "HeadSliceZeroOmitEmpty",
data: struct {
A []int `json:"a,omitempty"`
}{},
},
{
name: "HeadSliceZeroString",
data: struct {
A []int `json:"a,string"`
}{},
},
// HeadSlice
{
name: "HeadSlice",
data: struct {
A []int `json:"a"`
}{A: []int{-1}},
},
{
name: "HeadSliceOmitEmpty",
data: struct {
A []int `json:"a,omitempty"`
}{A: []int{-1}},
},
{
name: "HeadSliceString",
data: struct {
A []int `json:"a,string"`
}{A: []int{-1}},
},
// HeadSlicePtr
{
name: "HeadSlicePtr",
data: struct {
A *[]int `json:"a"`
}{A: sliceptr([]int{-1})},
},
{
name: "HeadSlicePtrOmitEmpty",
data: struct {
A *[]int `json:"a,omitempty"`
}{A: sliceptr([]int{-1})},
},
{
name: "HeadSlicePtrString",
data: struct {
A *[]int `json:"a,string"`
}{A: sliceptr([]int{-1})},
},
// HeadSlicePtrNil
{
name: "HeadSlicePtrNil",
data: struct {
A *[]int `json:"a"`
}{A: nil},
},
{
name: "HeadSlicePtrNilOmitEmpty",
data: struct {
A *[]int `json:"a,omitempty"`
}{A: nil},
},
{
name: "HeadSlicePtrNilString",
data: struct {
A *[]int `json:"a,string"`
}{A: nil},
},
// PtrHeadSliceZero
{
name: "PtrHeadSliceZero",
data: &struct {
A []int `json:"a"`
}{},
},
{
name: "PtrHeadSliceZeroOmitEmpty",
data: &struct {
A []int `json:"a,omitempty"`
}{},
},
{
name: "PtrHeadSliceZeroString",
data: &struct {
A []int `json:"a,string"`
}{},
},
// PtrHeadSlice
{
name: "PtrHeadSlice",
data: &struct {
A []int `json:"a"`
}{A: []int{-1}},
},
{
name: "PtrHeadSliceOmitEmpty",
data: &struct {
A []int `json:"a,omitempty"`
}{A: []int{-1}},
},
{
name: "PtrHeadSliceString",
data: &struct {
A []int `json:"a,string"`
}{A: []int{-1}},
},
// PtrHeadSlicePtr
{
name: "PtrHeadSlicePtr",
data: &struct {
A *[]int `json:"a"`
}{A: sliceptr([]int{-1})},
},
{
name: "PtrHeadSlicePtrOmitEmpty",
data: &struct {
A *[]int `json:"a,omitempty"`
}{A: sliceptr([]int{-1})},
},
{
name: "PtrHeadSlicePtrString",
data: &struct {
A *[]int `json:"a,string"`
}{A: sliceptr([]int{-1})},
},
// PtrHeadSlicePtrNil
{
name: "PtrHeadSlicePtrNil",
data: &struct {
A *[]int `json:"a"`
}{A: nil},
},
{
name: "PtrHeadSlicePtrNilOmitEmpty",
data: &struct {
A *[]int `json:"a,omitempty"`
}{A: nil},
},
{
name: "PtrHeadSlicePtrNilString",
data: &struct {
A *[]int `json:"a,string"`
}{A: nil},
},
// PtrHeadSliceNil
{
name: "PtrHeadSliceNil",
data: (*struct {
A *[]int `json:"a"`
})(nil),
},
{
name: "PtrHeadSliceNilOmitEmpty",
data: (*struct {
A *[]int `json:"a,omitempty"`
})(nil),
},
{
name: "PtrHeadSliceNilString",
data: (*struct {
A *[]int `json:"a,string"`
})(nil),
},
// HeadSliceZeroMultiFields
{
name: "HeadSliceZeroMultiFields",
data: struct {
A []int `json:"a"`
B []int `json:"b"`
C []int `json:"c"`
}{},
},
{
name: "HeadSliceZeroMultiFieldsOmitEmpty",
data: struct {
A []int `json:"a,omitempty"`
B []int `json:"b,omitempty"`
C []int `json:"c,omitempty"`
}{},
},
{
name: "HeadSliceZeroMultiFields",
data: struct {
A []int `json:"a,string"`
B []int `json:"b,string"`
C []int `json:"c,string"`
}{},
},
// HeadSliceMultiFields
{
name: "HeadSliceMultiFields",
data: struct {
A []int `json:"a"`
B []int `json:"b"`
C []int `json:"c"`
}{A: []int{-1}, B: []int{-2}, C: []int{-3}},
},
{
name: "HeadSliceMultiFieldsOmitEmpty",
data: struct {
A []int `json:"a,omitempty"`
B []int `json:"b,omitempty"`
C []int `json:"c,omitempty"`
}{A: []int{-1}, B: []int{-2}, C: []int{-3}},
},
{
name: "HeadSliceMultiFieldsString",
data: struct {
A []int `json:"a,string"`
B []int `json:"b,string"`
C []int `json:"c,string"`
}{A: []int{-1}, B: []int{-2}, C: []int{-3}},
},
// HeadSlicePtrMultiFields
{
name: "HeadSlicePtrMultiFields",
data: struct {
A *[]int `json:"a"`
B *[]int `json:"b"`
C *[]int `json:"c"`
}{A: sliceptr([]int{-1}), B: sliceptr([]int{-2}), C: sliceptr([]int{-3})},
},
{
name: "HeadSlicePtrMultiFieldsOmitEmpty",
data: struct {
A *[]int `json:"a,omitempty"`
B *[]int `json:"b,omitempty"`
C *[]int `json:"c,omitempty"`
}{A: sliceptr([]int{-1}), B: sliceptr([]int{-2}), C: sliceptr([]int{-3})},
},
{
name: "HeadSlicePtrMultiFieldsString",
data: struct {
A *[]int `json:"a,string"`
B *[]int `json:"b,string"`
C *[]int `json:"c,string"`
}{A: sliceptr([]int{-1}), B: sliceptr([]int{-2}), C: sliceptr([]int{-3})},
},
// HeadSlicePtrNilMultiFields
{
name: "HeadSlicePtrNilMultiFields",
data: struct {
A *[]int `json:"a"`
B *[]int `json:"b"`
C *[]int `json:"c"`
}{A: nil, B: nil, C: nil},
},
{
name: "HeadSlicePtrNilMultiFieldsOmitEmpty",
data: struct {
A *[]int `json:"a,omitempty"`
B *[]int `json:"b,omitempty"`
C *[]int `json:"c,omitempty"`
}{A: nil, B: nil, C: nil},
},
{
name: "HeadSlicePtrNilMultiFieldsString",
data: struct {
A *[]int `json:"a,string"`
B *[]int `json:"b,string"`
C *[]int `json:"c,string"`
}{A: nil, B: nil, C: nil},
},
// PtrHeadSliceZeroMultiFields
{
name: "PtrHeadSliceZeroMultiFields",
data: &struct {
A []int `json:"a"`
B []int `json:"b"`
}{},
},
{
name: "PtrHeadSliceZeroMultiFieldsOmitEmpty",
data: &struct {
A []int `json:"a,omitempty"`
B []int `json:"b,omitempty"`
}{},
},
{
name: "PtrHeadSliceZeroMultiFieldsString",
data: &struct {
A []int `json:"a,string"`
B []int `json:"b,string"`
}{},
},
// PtrHeadSliceMultiFields
{
name: "PtrHeadSliceMultiFields",
data: &struct {
A []int `json:"a"`
B []int `json:"b"`
}{A: []int{-1}, B: nil},
},
{
name: "PtrHeadSliceMultiFieldsOmitEmpty",
data: &struct {
A []int `json:"a,omitempty"`
B []int `json:"b,omitempty"`
}{A: []int{-1}, B: nil},
},
{
name: "PtrHeadSliceMultiFieldsString",
data: &struct {
A []int `json:"a,string"`
B []int `json:"b,string"`
}{A: []int{-1}, B: nil},
},
// PtrHeadSlicePtrMultiFields
{
name: "PtrHeadSlicePtrMultiFields",
data: &struct {
A *[]int `json:"a"`
B *[]int `json:"b"`
}{A: sliceptr([]int{-1}), B: sliceptr([]int{-2})},
},
{
name: "PtrHeadSlicePtrMultiFieldsOmitEmpty",
data: &struct {
A *[]int `json:"a,omitempty"`
B *[]int `json:"b,omitempty"`
}{A: sliceptr([]int{-1}), B: sliceptr([]int{-2})},
},
{
name: "PtrHeadSlicePtrMultiFieldsString",
data: &struct {
A *[]int `json:"a,string"`
B *[]int `json:"b,string"`
}{A: sliceptr([]int{-1}), B: sliceptr([]int{-2})},
},
// PtrHeadSlicePtrNilMultiFields
{
name: "PtrHeadSlicePtrNilMultiFields",
data: &struct {
A *[]int `json:"a"`
B *[]int `json:"b"`
}{A: nil, B: nil},
},
{
name: "PtrHeadSlicePtrNilMultiFieldsOmitEmpty",
data: &struct {
A *[]int `json:"a,omitempty"`
B *[]int `json:"b,omitempty"`
}{A: nil, B: nil},
},
{
name: "PtrHeadSlicePtrNilMultiFieldsString",
data: &struct {
A *[]int `json:"a,string"`
B *[]int `json:"b,string"`
}{A: nil, B: nil},
},
2021-03-03 18:13:33 +03:00
// PtrHeadSliceNilMultiFields
{
name: "PtrHeadSliceNilMultiFields",
data: (*struct {
A []int `json:"a"`
B []int `json:"b"`
})(nil),
},
{
name: "PtrHeadSliceNilMultiFieldsOmitEmpty",
data: (*struct {
A []int `json:"a,omitempty"`
B []int `json:"b,omitempty"`
})(nil),
},
{
name: "PtrHeadSliceNilMultiFieldsString",
data: (*struct {
A []int `json:"a,string"`
B []int `json:"b,string"`
})(nil),
},
2021-03-03 08:54:40 +03:00
// PtrHeadSliceNilMultiFields
{
name: "PtrHeadSliceNilMultiFields",
data: (*struct {
A *[]int `json:"a"`
B *[]int `json:"b"`
})(nil),
},
{
name: "PtrHeadSliceNilMultiFieldsOmitEmpty",
data: (*struct {
A *[]int `json:"a,omitempty"`
B *[]int `json:"b,omitempty"`
})(nil),
},
{
name: "PtrHeadSliceNilMultiFieldsString",
data: (*struct {
A *[]int `json:"a,string"`
B *[]int `json:"b,string"`
})(nil),
},
// HeadSliceZeroNotRoot
{
name: "HeadSliceZeroNotRoot",
data: struct {
A struct {
A []int `json:"a"`
}
}{},
},
{
name: "HeadSliceZeroNotRootOmitEmpty",
data: struct {
A struct {
A []int `json:"a,omitempty"`
}
}{},
},
{
name: "HeadSliceZeroNotRootString",
data: struct {
A struct {
A []int `json:"a,string"`
}
}{},
},
// HeadSliceNotRoot
{
name: "HeadSliceNotRoot",
data: struct {
A struct {
A []int `json:"a"`
}
}{A: struct {
A []int `json:"a"`
2021-03-03 18:13:33 +03:00
}{A: []int{-1}}},
2021-03-03 08:54:40 +03:00
},
{
name: "HeadSliceNotRootOmitEmpty",
data: struct {
A struct {
A []int `json:"a,omitempty"`
}
}{A: struct {
A []int `json:"a,omitempty"`
2021-03-03 18:13:33 +03:00
}{A: []int{-1}}},
2021-03-03 08:54:40 +03:00
},
{
name: "HeadSliceNotRootString",
data: struct {
A struct {
A []int `json:"a,string"`
}
}{A: struct {
A []int `json:"a,string"`
2021-03-03 18:13:33 +03:00
}{A: []int{-1}}},
2021-03-03 08:54:40 +03:00
},
// HeadSlicePtrNotRoot
{
name: "HeadSlicePtrNotRoot",
data: struct {
A struct {
A *[]int `json:"a"`
}
}{A: struct {
A *[]int `json:"a"`
2021-03-03 18:13:33 +03:00
}{sliceptr([]int{-1})}},
2021-03-03 08:54:40 +03:00
},
{
name: "HeadSlicePtrNotRootOmitEmpty",
data: struct {
A struct {
A *[]int `json:"a,omitempty"`
}
}{A: struct {
A *[]int `json:"a,omitempty"`
2021-03-03 18:13:33 +03:00
}{sliceptr([]int{-1})}},
2021-03-03 08:54:40 +03:00
},
{
name: "HeadSlicePtrNotRootString",
data: struct {
A struct {
A *[]int `json:"a,string"`
}
}{A: struct {
A *[]int `json:"a,string"`
2021-03-03 18:13:33 +03:00
}{sliceptr([]int{-1})}},
2021-03-03 08:54:40 +03:00
},
// HeadSlicePtrNilNotRoot
{
name: "HeadSlicePtrNilNotRoot",
data: struct {
A struct {
A *[]int `json:"a"`
}
}{},
},
{
name: "HeadSlicePtrNilNotRootOmitEmpty",
data: struct {
A struct {
A *[]int `json:"a,omitempty"`
}
}{},
},
{
name: "HeadSlicePtrNilNotRootString",
data: struct {
A struct {
A *[]int `json:"a,string"`
}
}{},
},
// PtrHeadSliceZeroNotRoot
{
2021-03-03 18:13:33 +03:00
name: "PtrHeadSliceZeroNotRoot",
2021-03-03 08:54:40 +03:00
data: struct {
A *struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a"`
2021-03-03 08:54:40 +03:00
}
}{A: new(struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a"`
2021-03-03 08:54:40 +03:00
})},
},
{
2021-03-03 18:13:33 +03:00
name: "PtrHeadSliceZeroNotRootOmitEmpty",
2021-03-03 08:54:40 +03:00
data: struct {
A *struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a,omitempty"`
2021-03-03 08:54:40 +03:00
}
}{A: new(struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a,omitempty"`
2021-03-03 08:54:40 +03:00
})},
},
{
2021-03-03 18:13:33 +03:00
name: "PtrHeadSliceZeroNotRootString",
2021-03-03 08:54:40 +03:00
data: struct {
A *struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a,string"`
2021-03-03 08:54:40 +03:00
}
}{A: new(struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a,string"`
2021-03-03 08:54:40 +03:00
})},
},
2021-03-03 18:13:33 +03:00
// PtrHeadSliceNotRoot
2021-03-03 08:54:40 +03:00
{
2021-03-03 18:13:33 +03:00
name: "PtrHeadSliceNotRoot",
2021-03-03 08:54:40 +03:00
data: struct {
A *struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a"`
2021-03-03 08:54:40 +03:00
}
}{A: &(struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a"`
}{A: []int{-1}})},
2021-03-03 08:54:40 +03:00
},
{
2021-03-03 18:13:33 +03:00
name: "PtrHeadSliceNotRootOmitEmpty",
2021-03-03 08:54:40 +03:00
data: struct {
A *struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a,omitempty"`
2021-03-03 08:54:40 +03:00
}
}{A: &(struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a,omitempty"`
}{A: []int{-1}})},
2021-03-03 08:54:40 +03:00
},
{
2021-03-03 18:13:33 +03:00
name: "PtrHeadSliceNotRootString",
2021-03-03 08:54:40 +03:00
data: struct {
A *struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a,string"`
2021-03-03 08:54:40 +03:00
}
}{A: &(struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a,string"`
}{A: []int{-1}})},
2021-03-03 08:54:40 +03:00
},
2021-03-03 18:13:33 +03:00
// PtrHeadSlicePtrNotRoot
2021-03-03 08:54:40 +03:00
{
2021-03-03 18:13:33 +03:00
name: "PtrHeadSlicePtrNotRoot",
2021-03-03 08:54:40 +03:00
data: struct {
A *struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a"`
2021-03-03 08:54:40 +03:00
}
}{A: &(struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a"`
}{A: sliceptr([]int{-1})})},
2021-03-03 08:54:40 +03:00
},
{
2021-03-03 18:13:33 +03:00
name: "PtrHeadSlicePtrNotRootOmitEmpty",
2021-03-03 08:54:40 +03:00
data: struct {
A *struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a,omitempty"`
2021-03-03 08:54:40 +03:00
}
}{A: &(struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a,omitempty"`
}{A: sliceptr([]int{-1})})},
2021-03-03 08:54:40 +03:00
},
{
2021-03-03 18:13:33 +03:00
name: "PtrHeadSlicePtrNotRootString",
2021-03-03 08:54:40 +03:00
data: struct {
A *struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a,string"`
2021-03-03 08:54:40 +03:00
}
}{A: &(struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a,string"`
}{A: sliceptr([]int{-1})})},
2021-03-03 08:54:40 +03:00
},
2021-03-03 18:13:33 +03:00
// PtrHeadSlicePtrNilNotRoot
2021-03-03 08:54:40 +03:00
{
2021-03-03 18:13:33 +03:00
name: "PtrHeadSlicePtrNilNotRoot",
2021-03-03 08:54:40 +03:00
data: struct {
A *struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a"`
2021-03-03 08:54:40 +03:00
}
}{A: &(struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a"`
2021-03-03 08:54:40 +03:00
}{A: nil})},
},
{
2021-03-03 18:13:33 +03:00
name: "PtrHeadSlicePtrNilNotRootOmitEmpty",
2021-03-03 08:54:40 +03:00
data: struct {
A *struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a,omitempty"`
2021-03-03 08:54:40 +03:00
}
}{A: &(struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a,omitempty"`
2021-03-03 08:54:40 +03:00
}{A: nil})},
},
{
2021-03-03 18:13:33 +03:00
name: "PtrHeadSlicePtrNilNotRootString",
2021-03-03 08:54:40 +03:00
data: struct {
A *struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a,string"`
2021-03-03 08:54:40 +03:00
}
}{A: &(struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a,string"`
2021-03-03 08:54:40 +03:00
}{A: nil})},
},
2021-03-03 18:13:33 +03:00
// PtrHeadSliceNilNotRoot
2021-03-03 08:54:40 +03:00
{
2021-03-03 18:13:33 +03:00
name: "PtrHeadSliceNilNotRoot",
2021-03-03 08:54:40 +03:00
data: struct {
A *struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a"`
2021-03-03 08:54:40 +03:00
}
}{A: nil},
},
{
2021-03-03 18:13:33 +03:00
name: "PtrHeadSliceNilNotRootOmitEmpty",
2021-03-03 08:54:40 +03:00
data: struct {
A *struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a,omitempty"`
2021-03-03 08:54:40 +03:00
} `json:",omitempty"`
}{A: nil},
},
{
2021-03-03 18:13:33 +03:00
name: "PtrHeadSliceNilNotRootString",
2021-03-03 08:54:40 +03:00
data: struct {
A *struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a,string"`
2021-03-03 08:54:40 +03:00
} `json:",string"`
}{A: nil},
},
2021-03-03 18:13:33 +03:00
// HeadSliceZeroMultiFieldsNotRoot
2021-03-03 08:54:40 +03:00
{
2021-03-03 18:13:33 +03:00
name: "HeadSliceZeroMultiFieldsNotRoot",
2021-03-03 08:54:40 +03:00
data: struct {
A struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a"`
2021-03-03 08:54:40 +03:00
}
B struct {
2021-03-03 18:13:33 +03:00
B []int `json:"b"`
2021-03-03 08:54:40 +03:00
}
}{},
},
{
2021-03-03 18:13:33 +03:00
name: "HeadSliceZeroMultiFieldsNotRootOmitEmpty",
2021-03-03 08:54:40 +03:00
data: struct {
A struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a,omitempty"`
2021-03-03 08:54:40 +03:00
}
B struct {
2021-03-03 18:13:33 +03:00
B []int `json:"b,omitempty"`
2021-03-03 08:54:40 +03:00
}
}{},
},
{
2021-03-03 18:13:33 +03:00
name: "HeadSliceZeroMultiFieldsNotRootString",
2021-03-03 08:54:40 +03:00
data: struct {
A struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a,string"`
2021-03-03 08:54:40 +03:00
}
B struct {
2021-03-03 18:13:33 +03:00
B []int `json:"b,string"`
2021-03-03 08:54:40 +03:00
}
}{},
},
2021-03-03 18:13:33 +03:00
// HeadSliceMultiFieldsNotRoot
2021-03-03 08:54:40 +03:00
{
2021-03-03 18:13:33 +03:00
name: "HeadSliceMultiFieldsNotRoot",
2021-03-03 08:54:40 +03:00
data: struct {
A struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a"`
2021-03-03 08:54:40 +03:00
}
B struct {
2021-03-03 18:13:33 +03:00
B []int `json:"b"`
2021-03-03 08:54:40 +03:00
}
}{A: struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a"`
}{A: []int{-1}}, B: struct {
B []int `json:"b"`
}{B: []int{0}}},
2021-03-03 08:54:40 +03:00
},
{
2021-03-03 18:13:33 +03:00
name: "HeadSliceMultiFieldsNotRootOmitEmpty",
2021-03-03 08:54:40 +03:00
data: struct {
A struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a,omitempty"`
2021-03-03 08:54:40 +03:00
}
B struct {
2021-03-03 18:13:33 +03:00
B []int `json:"b,omitempty"`
2021-03-03 08:54:40 +03:00
}
}{A: struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a,omitempty"`
}{A: []int{-1}}, B: struct {
B []int `json:"b,omitempty"`
}{B: []int{1}}},
2021-03-03 08:54:40 +03:00
},
{
2021-03-03 18:13:33 +03:00
name: "HeadSliceMultiFieldsNotRootString",
2021-03-03 08:54:40 +03:00
data: struct {
A struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a,string"`
2021-03-03 08:54:40 +03:00
}
B struct {
2021-03-03 18:13:33 +03:00
B []int `json:"b,string"`
2021-03-03 08:54:40 +03:00
}
}{A: struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a,string"`
}{A: []int{-1}}, B: struct {
B []int `json:"b,string"`
}{B: []int{1}}},
2021-03-03 08:54:40 +03:00
},
2021-03-03 18:13:33 +03:00
// HeadSlicePtrMultiFieldsNotRoot
2021-03-03 08:54:40 +03:00
{
2021-03-03 18:13:33 +03:00
name: "HeadSlicePtrMultiFieldsNotRoot",
2021-03-03 08:54:40 +03:00
data: struct {
A struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a"`
2021-03-03 08:54:40 +03:00
}
B struct {
2021-03-03 18:13:33 +03:00
B *[]int `json:"b"`
2021-03-03 08:54:40 +03:00
}
}{A: struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a"`
}{A: sliceptr([]int{-1})}, B: struct {
B *[]int `json:"b"`
}{B: sliceptr([]int{1})}},
2021-03-03 08:54:40 +03:00
},
{
2021-03-03 18:13:33 +03:00
name: "HeadSlicePtrMultiFieldsNotRootOmitEmpty",
2021-03-03 08:54:40 +03:00
data: struct {
A struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a,omitempty"`
2021-03-03 08:54:40 +03:00
}
B struct {
2021-03-03 18:13:33 +03:00
B *[]int `json:"b,omitempty"`
2021-03-03 08:54:40 +03:00
}
}{A: struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a,omitempty"`
}{A: sliceptr([]int{-1})}, B: struct {
B *[]int `json:"b,omitempty"`
}{B: sliceptr([]int{1})}},
2021-03-03 08:54:40 +03:00
},
{
2021-03-03 18:13:33 +03:00
name: "HeadSlicePtrMultiFieldsNotRootString",
2021-03-03 08:54:40 +03:00
data: struct {
A struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a,string"`
2021-03-03 08:54:40 +03:00
}
B struct {
2021-03-03 18:13:33 +03:00
B *[]int `json:"b,string"`
2021-03-03 08:54:40 +03:00
}
}{A: struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a,string"`
}{A: sliceptr([]int{-1})}, B: struct {
B *[]int `json:"b,string"`
}{B: sliceptr([]int{1})}},
2021-03-03 08:54:40 +03:00
},
2021-03-03 18:13:33 +03:00
// HeadSlicePtrNilMultiFieldsNotRoot
2021-03-03 08:54:40 +03:00
{
2021-03-03 18:13:33 +03:00
name: "HeadSlicePtrNilMultiFieldsNotRoot",
2021-03-03 08:54:40 +03:00
data: struct {
A struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a"`
2021-03-03 08:54:40 +03:00
}
B struct {
2021-03-03 18:13:33 +03:00
B *[]int `json:"b"`
2021-03-03 08:54:40 +03:00
}
}{A: struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a"`
2021-03-03 08:54:40 +03:00
}{A: nil}, B: struct {
2021-03-03 18:13:33 +03:00
B *[]int `json:"b"`
2021-03-03 08:54:40 +03:00
}{B: nil}},
},
{
2021-03-03 18:13:33 +03:00
name: "HeadSlicePtrNilMultiFieldsNotRootOmitEmpty",
2021-03-03 08:54:40 +03:00
data: struct {
A struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a,omitempty"`
2021-03-03 08:54:40 +03:00
}
B struct {
2021-03-03 18:13:33 +03:00
B *[]int `json:"b,omitempty"`
2021-03-03 08:54:40 +03:00
}
}{A: struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a,omitempty"`
2021-03-03 08:54:40 +03:00
}{A: nil}, B: struct {
2021-03-03 18:13:33 +03:00
B *[]int `json:"b,omitempty"`
2021-03-03 08:54:40 +03:00
}{B: nil}},
},
{
2021-03-03 18:13:33 +03:00
name: "HeadSlicePtrNilMultiFieldsNotRootString",
2021-03-03 08:54:40 +03:00
data: struct {
A struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a,string"`
2021-03-03 08:54:40 +03:00
}
B struct {
2021-03-03 18:13:33 +03:00
B *[]int `json:"b,string"`
2021-03-03 08:54:40 +03:00
}
}{A: struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a,string"`
2021-03-03 08:54:40 +03:00
}{A: nil}, B: struct {
2021-03-03 18:13:33 +03:00
B *[]int `json:"b,string"`
2021-03-03 08:54:40 +03:00
}{B: nil}},
},
2021-03-03 18:13:33 +03:00
// PtrHeadSliceZeroMultiFieldsNotRoot
2021-03-03 08:54:40 +03:00
{
2021-03-03 18:13:33 +03:00
name: "PtrHeadSliceZeroMultiFieldsNotRoot",
2021-03-03 08:54:40 +03:00
data: &struct {
A struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a"`
2021-03-03 08:54:40 +03:00
}
B struct {
2021-03-03 18:13:33 +03:00
B []int `json:"b"`
2021-03-03 08:54:40 +03:00
}
}{},
},
{
2021-03-03 18:13:33 +03:00
name: "PtrHeadSliceZeroMultiFieldsNotRootOmitEmpty",
2021-03-03 08:54:40 +03:00
data: &struct {
A struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a,omitempty"`
2021-03-03 08:54:40 +03:00
}
B struct {
2021-03-03 18:13:33 +03:00
B []int `json:"b,omitempty"`
2021-03-03 08:54:40 +03:00
}
}{},
},
{
2021-03-03 18:13:33 +03:00
name: "PtrHeadSliceZeroMultiFieldsNotRootString",
2021-03-03 08:54:40 +03:00
data: &struct {
A struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a,string"`
2021-03-03 08:54:40 +03:00
}
B struct {
2021-03-03 18:13:33 +03:00
B []int `json:"b,string"`
2021-03-03 08:54:40 +03:00
}
}{},
},
2021-03-03 18:13:33 +03:00
// PtrHeadSliceMultiFieldsNotRoot
2021-03-03 08:54:40 +03:00
{
2021-03-03 18:13:33 +03:00
name: "PtrHeadSliceMultiFieldsNotRoot",
2021-03-03 08:54:40 +03:00
data: &struct {
A struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a"`
2021-03-03 08:54:40 +03:00
}
B struct {
2021-03-03 18:13:33 +03:00
B []int `json:"b"`
2021-03-03 08:54:40 +03:00
}
}{A: struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a"`
}{A: []int{-1}}, B: struct {
B []int `json:"b"`
}{B: []int{1}}},
2021-03-03 08:54:40 +03:00
},
{
2021-03-03 18:13:33 +03:00
name: "PtrHeadSliceMultiFieldsNotRootOmitEmpty",
2021-03-03 08:54:40 +03:00
data: &struct {
A struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a,omitempty"`
2021-03-03 08:54:40 +03:00
}
B struct {
2021-03-03 18:13:33 +03:00
B []int `json:"b,omitempty"`
2021-03-03 08:54:40 +03:00
}
}{A: struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a,omitempty"`
}{A: []int{-1}}, B: struct {
B []int `json:"b,omitempty"`
}{B: []int{1}}},
2021-03-03 08:54:40 +03:00
},
{
2021-03-03 18:13:33 +03:00
name: "PtrHeadSliceMultiFieldsNotRootString",
2021-03-03 08:54:40 +03:00
data: &struct {
A struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a,string"`
2021-03-03 08:54:40 +03:00
}
B struct {
2021-03-03 18:13:33 +03:00
B []int `json:"b,string"`
2021-03-03 08:54:40 +03:00
}
}{A: struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a,string"`
}{A: []int{-1}}, B: struct {
B []int `json:"b,string"`
}{B: []int{1}}},
2021-03-03 08:54:40 +03:00
},
2021-03-03 18:13:33 +03:00
// PtrHeadSlicePtrMultiFieldsNotRoot
2021-03-03 08:54:40 +03:00
{
2021-03-03 18:13:33 +03:00
name: "PtrHeadSlicePtrMultiFieldsNotRoot",
2021-03-03 08:54:40 +03:00
data: &struct {
A *struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a"`
2021-03-03 08:54:40 +03:00
}
B *struct {
2021-03-03 18:13:33 +03:00
B *[]int `json:"b"`
2021-03-03 08:54:40 +03:00
}
}{A: &(struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a"`
}{A: sliceptr([]int{-1})}), B: &(struct {
B *[]int `json:"b"`
}{B: sliceptr([]int{1})})},
2021-03-03 08:54:40 +03:00
},
{
2021-03-03 18:13:33 +03:00
name: "PtrHeadSlicePtrMultiFieldsNotRootOmitEmpty",
2021-03-03 08:54:40 +03:00
data: &struct {
A *struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a,omitempty"`
2021-03-03 08:54:40 +03:00
}
B *struct {
2021-03-03 18:13:33 +03:00
B *[]int `json:"b,omitempty"`
2021-03-03 08:54:40 +03:00
}
}{A: &(struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a,omitempty"`
}{A: sliceptr([]int{-1})}), B: &(struct {
B *[]int `json:"b,omitempty"`
}{B: sliceptr([]int{1})})},
2021-03-03 08:54:40 +03:00
},
{
2021-03-03 18:13:33 +03:00
name: "PtrHeadSlicePtrMultiFieldsNotRootString",
2021-03-03 08:54:40 +03:00
data: &struct {
A *struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a,string"`
2021-03-03 08:54:40 +03:00
}
B *struct {
2021-03-03 18:13:33 +03:00
B *[]int `json:"b,string"`
2021-03-03 08:54:40 +03:00
}
}{A: &(struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a,string"`
}{A: sliceptr([]int{-1})}), B: &(struct {
B *[]int `json:"b,string"`
}{B: sliceptr([]int{1})})},
2021-03-03 08:54:40 +03:00
},
2021-03-03 18:13:33 +03:00
// PtrHeadSlicePtrNilMultiFieldsNotRoot
2021-03-03 08:54:40 +03:00
{
2021-03-03 18:13:33 +03:00
name: "PtrHeadSlicePtrNilMultiFieldsNotRoot",
2021-03-03 08:54:40 +03:00
data: &struct {
A *struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a"`
2021-03-03 08:54:40 +03:00
}
B *struct {
2021-03-03 18:13:33 +03:00
B *[]int `json:"b"`
2021-03-03 08:54:40 +03:00
}
}{A: nil, B: nil},
},
{
2021-03-03 18:13:33 +03:00
name: "PtrHeadSlicePtrNilMultiFieldsNotRootOmitEmpty",
2021-03-03 08:54:40 +03:00
data: &struct {
A *struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a,omitempty"`
2021-03-03 08:54:40 +03:00
} `json:",omitempty"`
B *struct {
2021-03-03 18:13:33 +03:00
B *[]int `json:"b,omitempty"`
2021-03-03 08:54:40 +03:00
} `json:",omitempty"`
}{A: nil, B: nil},
},
{
2021-03-03 18:13:33 +03:00
name: "PtrHeadSlicePtrNilMultiFieldsNotRootString",
2021-03-03 08:54:40 +03:00
data: &struct {
A *struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a,string"`
2021-03-03 08:54:40 +03:00
} `json:",string"`
B *struct {
2021-03-03 18:13:33 +03:00
B *[]int `json:"b,string"`
2021-03-03 08:54:40 +03:00
} `json:",string"`
}{A: nil, B: nil},
},
2021-03-03 18:13:33 +03:00
// PtrHeadSliceNilMultiFieldsNotRoot
2021-03-03 08:54:40 +03:00
{
2021-03-03 18:13:33 +03:00
name: "PtrHeadSliceNilMultiFieldsNotRoot",
2021-03-03 08:54:40 +03:00
data: (*struct {
A *struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a"`
2021-03-03 08:54:40 +03:00
}
B *struct {
2021-03-03 18:13:33 +03:00
B *[]int `json:"b"`
2021-03-03 08:54:40 +03:00
}
})(nil),
},
{
2021-03-03 18:13:33 +03:00
name: "PtrHeadSliceNilMultiFieldsNotRootOmitEmpty",
2021-03-03 08:54:40 +03:00
data: (*struct {
A *struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a,omitempty"`
2021-03-03 08:54:40 +03:00
}
B *struct {
2021-03-03 18:13:33 +03:00
B *[]int `json:"b,omitempty"`
2021-03-03 08:54:40 +03:00
}
})(nil),
},
{
2021-03-03 18:13:33 +03:00
name: "PtrHeadSliceNilMultiFieldsNotRootString",
2021-03-03 08:54:40 +03:00
data: (*struct {
A *struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a,string"`
2021-03-03 08:54:40 +03:00
}
B *struct {
2021-03-03 18:13:33 +03:00
B *[]int `json:"b,string"`
2021-03-03 08:54:40 +03:00
}
})(nil),
},
2021-03-03 18:13:33 +03:00
// PtrHeadSliceDoubleMultiFieldsNotRoot
2021-03-03 08:54:40 +03:00
{
2021-03-03 18:13:33 +03:00
name: "PtrHeadSliceDoubleMultiFieldsNotRoot",
2021-03-03 08:54:40 +03:00
data: &struct {
A *struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a"`
B []int `json:"b"`
2021-03-03 08:54:40 +03:00
}
B *struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a"`
B []int `json:"b"`
2021-03-03 08:54:40 +03:00
}
}{A: &(struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a"`
B []int `json:"b"`
}{A: []int{-1}, B: []int{1}}), B: &(struct {
A []int `json:"a"`
B []int `json:"b"`
}{A: []int{-1}, B: nil})},
2021-03-03 08:54:40 +03:00
},
{
2021-03-03 18:13:33 +03:00
name: "PtrHeadSliceDoubleMultiFieldsNotRootOmitEmpty",
2021-03-03 08:54:40 +03:00
data: &struct {
A *struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a,omitempty"`
B []int `json:"b,omitempty"`
2021-03-03 08:54:40 +03:00
}
B *struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a,omitempty"`
B []int `json:"b,omitempty"`
2021-03-03 08:54:40 +03:00
}
}{A: &(struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a,omitempty"`
B []int `json:"b,omitempty"`
}{A: []int{-1}, B: []int{1}}), B: &(struct {
A []int `json:"a,omitempty"`
B []int `json:"b,omitempty"`
}{A: []int{-1}, B: nil})},
2021-03-03 08:54:40 +03:00
},
{
2021-03-03 18:13:33 +03:00
name: "PtrHeadSliceDoubleMultiFieldsNotRootString",
2021-03-03 08:54:40 +03:00
data: &struct {
A *struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a,string"`
B []int `json:"b,string"`
2021-03-03 08:54:40 +03:00
}
B *struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a,string"`
B []int `json:"b,string"`
2021-03-03 08:54:40 +03:00
}
}{A: &(struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a,string"`
B []int `json:"b,string"`
}{A: []int{-1}, B: []int{1}}), B: &(struct {
A []int `json:"a,string"`
B []int `json:"b,string"`
}{A: []int{-1}, B: nil})},
2021-03-03 08:54:40 +03:00
},
2021-03-03 18:13:33 +03:00
// PtrHeadSliceNilDoubleMultiFieldsNotRoot
2021-03-03 08:54:40 +03:00
{
2021-03-03 18:13:33 +03:00
name: "PtrHeadSliceNilDoubleMultiFieldsNotRoot",
2021-03-03 08:54:40 +03:00
data: &struct {
A *struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a"`
B []int `json:"b"`
2021-03-03 08:54:40 +03:00
}
B *struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a"`
B []int `json:"b"`
2021-03-03 08:54:40 +03:00
}
}{A: nil, B: nil},
},
{
2021-03-03 18:13:33 +03:00
name: "PtrHeadSliceNilDoubleMultiFieldsNotRootOmitEmpty",
2021-03-03 08:54:40 +03:00
data: &struct {
A *struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a,omitempty"`
B []int `json:"b,omitempty"`
2021-03-03 08:54:40 +03:00
} `json:",omitempty"`
B *struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a,omitempty"`
B []int `json:"b,omitempty"`
2021-03-03 08:54:40 +03:00
} `json:",omitempty"`
}{A: nil, B: nil},
},
{
2021-03-03 18:13:33 +03:00
name: "PtrHeadSliceNilDoubleMultiFieldsNotRootString",
2021-03-03 08:54:40 +03:00
data: &struct {
A *struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a,string"`
B []int `json:"b,string"`
2021-03-03 08:54:40 +03:00
}
B *struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a,string"`
B []int `json:"b,string"`
2021-03-03 08:54:40 +03:00
}
}{A: nil, B: nil},
},
2021-03-03 18:13:33 +03:00
// PtrHeadSliceNilDoubleMultiFieldsNotRoot
2021-03-03 08:54:40 +03:00
{
2021-03-03 18:13:33 +03:00
name: "PtrHeadSliceNilDoubleMultiFieldsNotRoot",
2021-03-03 08:54:40 +03:00
data: (*struct {
A *struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a"`
B []int `json:"b"`
2021-03-03 08:54:40 +03:00
}
B *struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a"`
B []int `json:"b"`
2021-03-03 08:54:40 +03:00
}
})(nil),
},
{
2021-03-03 18:13:33 +03:00
name: "PtrHeadSliceNilDoubleMultiFieldsNotRootOmitEmpty",
2021-03-03 08:54:40 +03:00
data: (*struct {
A *struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a,omitempty"`
B []int `json:"b,omitempty"`
2021-03-03 08:54:40 +03:00
}
B *struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a,omitempty"`
B []int `json:"b,omitempty"`
2021-03-03 08:54:40 +03:00
}
})(nil),
},
{
2021-03-03 18:13:33 +03:00
name: "PtrHeadSliceNilDoubleMultiFieldsNotRootString",
2021-03-03 08:54:40 +03:00
data: (*struct {
A *struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a,string"`
B []int `json:"b,string"`
2021-03-03 08:54:40 +03:00
}
B *struct {
2021-03-03 18:13:33 +03:00
A []int `json:"a,string"`
B []int `json:"b,string"`
2021-03-03 08:54:40 +03:00
}
})(nil),
},
2021-03-03 18:13:33 +03:00
// PtrHeadSlicePtrDoubleMultiFieldsNotRoot
2021-03-03 08:54:40 +03:00
{
2021-03-03 18:13:33 +03:00
name: "PtrHeadSlicePtrDoubleMultiFieldsNotRoot",
2021-03-03 08:54:40 +03:00
data: &struct {
A *struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a"`
B *[]int `json:"b"`
2021-03-03 08:54:40 +03:00
}
B *struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a"`
B *[]int `json:"b"`
2021-03-03 08:54:40 +03:00
}
}{A: &(struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a"`
B *[]int `json:"b"`
}{A: sliceptr([]int{-1}), B: sliceptr([]int{1})}), B: &(struct {
A *[]int `json:"a"`
B *[]int `json:"b"`
}{A: nil, B: nil})},
2021-03-03 08:54:40 +03:00
},
{
2021-03-03 18:13:33 +03:00
name: "PtrHeadSlicePtrDoubleMultiFieldsNotRootOmitEmpty",
2021-03-03 08:54:40 +03:00
data: &struct {
A *struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a,omitempty"`
B *[]int `json:"b,omitempty"`
2021-03-03 08:54:40 +03:00
}
B *struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a,omitempty"`
B *[]int `json:"b,omitempty"`
2021-03-03 08:54:40 +03:00
}
}{A: &(struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a,omitempty"`
B *[]int `json:"b,omitempty"`
}{A: sliceptr([]int{-1}), B: sliceptr([]int{1})}), B: &(struct {
A *[]int `json:"a,omitempty"`
B *[]int `json:"b,omitempty"`
}{A: nil, B: nil})},
2021-03-03 08:54:40 +03:00
},
{
2021-03-03 18:13:33 +03:00
name: "PtrHeadSlicePtrDoubleMultiFieldsNotRootString",
2021-03-03 08:54:40 +03:00
data: &struct {
A *struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a,string"`
B *[]int `json:"b,string"`
2021-03-03 08:54:40 +03:00
}
B *struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a,string"`
B *[]int `json:"b,string"`
2021-03-03 08:54:40 +03:00
}
}{A: &(struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a,string"`
B *[]int `json:"b,string"`
}{A: sliceptr([]int{-1}), B: sliceptr([]int{1})}), B: &(struct {
A *[]int `json:"a,string"`
B *[]int `json:"b,string"`
}{A: nil, B: nil})},
2021-03-03 08:54:40 +03:00
},
2021-03-03 18:13:33 +03:00
// PtrHeadSlicePtrNilDoubleMultiFieldsNotRoot
2021-03-03 08:54:40 +03:00
{
2021-03-03 18:13:33 +03:00
name: "PtrHeadSlicePtrNilDoubleMultiFieldsNotRoot",
2021-03-03 08:54:40 +03:00
data: &struct {
A *struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a"`
B *[]int `json:"b"`
2021-03-03 08:54:40 +03:00
}
B *struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a"`
B *[]int `json:"b"`
2021-03-03 08:54:40 +03:00
}
}{A: nil, B: nil},
},
{
2021-03-03 18:13:33 +03:00
name: "PtrHeadSlicePtrNilDoubleMultiFieldsNotRootOmitEmpty",
2021-03-03 08:54:40 +03:00
data: &struct {
A *struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a,omitempty"`
B *[]int `json:"b,omitempty"`
2021-03-03 08:54:40 +03:00
} `json:",omitempty"`
B *struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a,omitempty"`
B *[]int `json:"b,omitempty"`
2021-03-03 08:54:40 +03:00
} `json:",omitempty"`
}{A: nil, B: nil},
},
{
2021-03-03 18:13:33 +03:00
name: "PtrHeadSlicePtrNilDoubleMultiFieldsNotRootString",
2021-03-03 08:54:40 +03:00
data: &struct {
A *struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a,string"`
B *[]int `json:"b,string"`
2021-03-03 08:54:40 +03:00
}
B *struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a,string"`
B *[]int `json:"b,string"`
2021-03-03 08:54:40 +03:00
}
}{A: nil, B: nil},
},
2021-03-03 18:13:33 +03:00
// PtrHeadSlicePtrNilDoubleMultiFieldsNotRoot
2021-03-03 08:54:40 +03:00
{
2021-03-03 18:13:33 +03:00
name: "PtrHeadSlicePtrNilDoubleMultiFieldsNotRoot",
2021-03-03 08:54:40 +03:00
data: (*struct {
A *struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a"`
B *[]int `json:"b"`
2021-03-03 08:54:40 +03:00
}
B *struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a"`
B *[]int `json:"b"`
2021-03-03 08:54:40 +03:00
}
})(nil),
},
{
2021-03-03 18:13:33 +03:00
name: "PtrHeadSlicePtrNilDoubleMultiFieldsNotRootOmitEmpty",
2021-03-03 08:54:40 +03:00
data: (*struct {
A *struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a,omitempty"`
B *[]int `json:"b,omitempty"`
2021-03-03 08:54:40 +03:00
}
B *struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a,omitempty"`
B *[]int `json:"b,omitempty"`
2021-03-03 08:54:40 +03:00
}
})(nil),
},
{
2021-03-03 18:13:33 +03:00
name: "PtrHeadSlicePtrNilDoubleMultiFieldsNotRootString",
2021-03-03 08:54:40 +03:00
data: (*struct {
A *struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a,string"`
B *[]int `json:"b,string"`
2021-03-03 08:54:40 +03:00
}
B *struct {
2021-03-03 18:13:33 +03:00
A *[]int `json:"a,string"`
B *[]int `json:"b,string"`
2021-03-03 08:54:40 +03:00
}
})(nil),
},
2021-03-03 18:13:33 +03:00
// AnonymousHeadSlice
{
name: "AnonymousHeadSlice",
data: struct {
structSlice
B []int `json:"b"`
}{
structSlice: structSlice{A: []int{-1}},
B: nil,
2021-03-03 08:54:40 +03:00
},
2021-03-03 18:13:33 +03:00
},
{
name: "AnonymousHeadSliceOmitEmpty",
data: struct {
structSliceOmitEmpty
B []int `json:"b,omitempty"`
}{
structSliceOmitEmpty: structSliceOmitEmpty{A: []int{-1}},
B: nil,
2021-03-03 08:54:40 +03:00
},
2021-03-03 18:13:33 +03:00
},
{
name: "AnonymousHeadSliceString",
data: struct {
structSliceString
B []int `json:"b,string"`
}{
structSliceString: structSliceString{A: []int{-1}},
B: nil,
2021-03-03 08:54:40 +03:00
},
2021-03-03 18:13:33 +03:00
},
2021-03-03 08:54:40 +03:00
2021-03-03 18:13:33 +03:00
// PtrAnonymousHeadSlice
{
name: "PtrAnonymousHeadSlice",
data: struct {
*structSlice
B []int `json:"b"`
}{
structSlice: &structSlice{A: []int{-1}},
B: nil,
2021-03-03 08:54:40 +03:00
},
2021-03-03 18:13:33 +03:00
},
{
name: "PtrAnonymousHeadSliceOmitEmpty",
data: struct {
*structSliceOmitEmpty
B []int `json:"b,omitempty"`
}{
structSliceOmitEmpty: &structSliceOmitEmpty{A: []int{-1}},
B: nil,
2021-03-03 08:54:40 +03:00
},
2021-03-03 18:13:33 +03:00
},
{
name: "PtrAnonymousHeadSliceString",
data: struct {
*structSliceString
B []int `json:"b,string"`
}{
structSliceString: &structSliceString{A: []int{-1}},
B: nil,
2021-03-03 08:54:40 +03:00
},
2021-03-03 18:13:33 +03:00
},
2021-03-03 08:54:40 +03:00
2021-03-03 18:13:33 +03:00
// PtrAnonymousHeadSliceNil
{
name: "PtrAnonymousHeadSliceNil",
data: struct {
*structSlice
B []int `json:"b"`
}{
structSlice: &structSlice{A: nil},
B: nil,
2021-03-03 08:54:40 +03:00
},
2021-03-03 18:13:33 +03:00
},
{
name: "PtrAnonymousHeadSliceNilOmitEmpty",
data: struct {
*structSliceOmitEmpty
B []int `json:"b,omitempty"`
}{
structSliceOmitEmpty: &structSliceOmitEmpty{A: nil},
B: nil,
2021-03-03 08:54:40 +03:00
},
2021-03-03 18:13:33 +03:00
},
{
name: "PtrAnonymousHeadSliceNilString",
data: struct {
*structSliceString
B []int `json:"b,string"`
}{
structSliceString: &structSliceString{A: nil},
B: nil,
2021-03-03 08:54:40 +03:00
},
2021-03-03 18:13:33 +03:00
},
2021-03-03 08:54:40 +03:00
2021-03-03 18:13:33 +03:00
// NilPtrAnonymousHeadSlice
{
name: "NilPtrAnonymousHeadSlice",
data: struct {
*structSlice
B []int `json:"b"`
}{
structSlice: nil,
B: []int{-1},
2021-03-03 08:54:40 +03:00
},
2021-03-03 18:13:33 +03:00
},
{
name: "NilPtrAnonymousHeadSliceOmitEmpty",
data: struct {
*structSliceOmitEmpty
B []int `json:"b,omitempty"`
}{
structSliceOmitEmpty: nil,
B: []int{-1},
2021-03-03 08:54:40 +03:00
},
2021-03-03 18:13:33 +03:00
},
{
name: "NilPtrAnonymousHeadSliceString",
data: struct {
*structSliceString
B []int `json:"b,string"`
}{
structSliceString: nil,
B: []int{-1},
2021-03-03 08:54:40 +03:00
},
2021-03-03 18:13:33 +03:00
},
2021-03-03 08:54:40 +03:00
2021-03-03 18:13:33 +03:00
// AnonymousHeadSlicePtr
{
name: "AnonymousHeadSlicePtr",
data: struct {
structSlicePtr
B *[]int `json:"b"`
}{
structSlicePtr: structSlicePtr{A: sliceptr([]int{-1})},
B: nil,
2021-03-03 08:54:40 +03:00
},
2021-03-03 18:13:33 +03:00
},
{
name: "AnonymousHeadSlicePtrOmitEmpty",
data: struct {
structSlicePtrOmitEmpty
B *[]int `json:"b,omitempty"`
}{
structSlicePtrOmitEmpty: structSlicePtrOmitEmpty{A: sliceptr([]int{-1})},
B: nil,
2021-03-03 08:54:40 +03:00
},
2021-03-03 18:13:33 +03:00
},
{
name: "AnonymousHeadSlicePtrString",
data: struct {
structSlicePtrString
B *[]int `json:"b,string"`
}{
structSlicePtrString: structSlicePtrString{A: sliceptr([]int{-1})},
B: nil,
2021-03-03 08:54:40 +03:00
},
2021-03-03 18:13:33 +03:00
},
2021-03-03 08:54:40 +03:00
2021-03-03 18:13:33 +03:00
// AnonymousHeadSlicePtrNil
{
name: "AnonymousHeadSlicePtrNil",
data: struct {
structSlicePtr
B *[]int `json:"b"`
}{
structSlicePtr: structSlicePtr{A: nil},
B: sliceptr([]int{-1}),
2021-03-03 08:54:40 +03:00
},
2021-03-03 18:13:33 +03:00
},
{
name: "AnonymousHeadSlicePtrNilOmitEmpty",
data: struct {
structSlicePtrOmitEmpty
B *[]int `json:"b,omitempty"`
}{
structSlicePtrOmitEmpty: structSlicePtrOmitEmpty{A: nil},
B: sliceptr([]int{-1}),
2021-03-03 08:54:40 +03:00
},
2021-03-03 18:13:33 +03:00
},
{
name: "AnonymousHeadSlicePtrNilString",
data: struct {
structSlicePtrString
B *[]int `json:"b,string"`
}{
structSlicePtrString: structSlicePtrString{A: nil},
B: sliceptr([]int{-1}),
2021-03-03 08:54:40 +03:00
},
2021-03-03 18:13:33 +03:00
},
2021-03-03 08:54:40 +03:00
2021-03-03 18:13:33 +03:00
// PtrAnonymousHeadSlicePtr
{
name: "PtrAnonymousHeadSlicePtr",
data: struct {
*structSlicePtr
B *[]int `json:"b"`
}{
structSlicePtr: &structSlicePtr{A: sliceptr([]int{-1})},
B: nil,
2021-03-03 08:54:40 +03:00
},
2021-03-03 18:13:33 +03:00
},
{
name: "PtrAnonymousHeadSlicePtrOmitEmpty",
data: struct {
*structSlicePtrOmitEmpty
B *[]int `json:"b,omitempty"`
}{
structSlicePtrOmitEmpty: &structSlicePtrOmitEmpty{A: sliceptr([]int{-1})},
B: nil,
2021-03-03 08:54:40 +03:00
},
2021-03-03 18:13:33 +03:00
},
{
name: "PtrAnonymousHeadSlicePtrString",
data: struct {
*structSlicePtrString
B *[]int `json:"b,string"`
}{
structSlicePtrString: &structSlicePtrString{A: sliceptr([]int{-1})},
B: nil,
2021-03-03 08:54:40 +03:00
},
2021-03-03 18:13:33 +03:00
},
2021-03-03 08:54:40 +03:00
2021-03-03 18:13:33 +03:00
// NilPtrAnonymousHeadSlicePtr
{
name: "NilPtrAnonymousHeadSlicePtr",
data: struct {
*structSlicePtr
B *[]int `json:"b"`
}{
structSlicePtr: nil,
B: sliceptr([]int{-1}),
2021-03-03 08:54:40 +03:00
},
2021-03-03 18:13:33 +03:00
},
{
name: "NilPtrAnonymousHeadSlicePtrOmitEmpty",
data: struct {
*structSlicePtrOmitEmpty
B *[]int `json:"b,omitempty"`
}{
structSlicePtrOmitEmpty: nil,
B: sliceptr([]int{-1}),
2021-03-03 08:54:40 +03:00
},
2021-03-03 18:13:33 +03:00
},
{
name: "NilPtrAnonymousHeadSlicePtrString",
data: struct {
*structSlicePtrString
B *[]int `json:"b,string"`
}{
structSlicePtrString: nil,
B: sliceptr([]int{-1}),
2021-03-03 08:54:40 +03:00
},
2021-03-03 18:13:33 +03:00
},
2021-03-03 08:54:40 +03:00
2021-03-03 18:13:33 +03:00
// AnonymousHeadSliceOnly
{
name: "AnonymousHeadSliceOnly",
data: struct {
structSlice
}{
structSlice: structSlice{A: []int{-1}},
2021-03-03 08:54:40 +03:00
},
2021-03-03 18:13:33 +03:00
},
{
name: "AnonymousHeadSliceOnlyOmitEmpty",
data: struct {
structSliceOmitEmpty
}{
structSliceOmitEmpty: structSliceOmitEmpty{A: []int{-1}},
2021-03-03 08:54:40 +03:00
},
2021-03-03 18:13:33 +03:00
},
{
name: "AnonymousHeadSliceOnlyString",
data: struct {
structSliceString
}{
structSliceString: structSliceString{A: []int{-1}},
},
},
// PtrAnonymousHeadSliceOnly
{
name: "PtrAnonymousHeadSliceOnly",
data: struct {
*structSlice
}{
structSlice: &structSlice{A: []int{-1}},
},
},
{
name: "PtrAnonymousHeadSliceOnlyOmitEmpty",
data: struct {
*structSliceOmitEmpty
}{
structSliceOmitEmpty: &structSliceOmitEmpty{A: []int{-1}},
},
},
{
name: "PtrAnonymousHeadSliceOnlyString",
data: struct {
*structSliceString
}{
structSliceString: &structSliceString{A: []int{-1}},
2021-03-03 08:54:40 +03:00
},
2021-03-03 18:13:33 +03:00
},
2021-03-03 08:54:40 +03:00
2021-03-03 18:13:33 +03:00
// NilPtrAnonymousHeadSliceOnly
{
name: "NilPtrAnonymousHeadSliceOnly",
data: struct {
*structSlice
}{
structSlice: nil,
2021-03-03 08:54:40 +03:00
},
2021-03-03 18:13:33 +03:00
},
{
name: "NilPtrAnonymousHeadSliceOnlyOmitEmpty",
data: struct {
*structSliceOmitEmpty
}{
structSliceOmitEmpty: nil,
2021-03-03 08:54:40 +03:00
},
2021-03-03 18:13:33 +03:00
},
{
name: "NilPtrAnonymousHeadSliceOnlyString",
data: struct {
*structSliceString
}{
structSliceString: nil,
2021-03-03 08:54:40 +03:00
},
2021-03-03 18:13:33 +03:00
},
2021-03-03 08:54:40 +03:00
2021-03-03 18:13:33 +03:00
// AnonymousHeadSlicePtrOnly
{
name: "AnonymousHeadSlicePtrOnly",
data: struct {
structSlicePtr
}{
structSlicePtr: structSlicePtr{A: sliceptr([]int{-1})},
2021-03-03 08:54:40 +03:00
},
2021-03-03 18:13:33 +03:00
},
{
name: "AnonymousHeadSlicePtrOnlyOmitEmpty",
data: struct {
structSlicePtrOmitEmpty
}{
structSlicePtrOmitEmpty: structSlicePtrOmitEmpty{A: sliceptr([]int{-1})},
2021-03-03 08:54:40 +03:00
},
2021-03-03 18:13:33 +03:00
},
{
name: "AnonymousHeadSlicePtrOnlyString",
data: struct {
structSlicePtrString
}{
structSlicePtrString: structSlicePtrString{A: sliceptr([]int{-1})},
2021-03-03 08:54:40 +03:00
},
2021-03-03 18:13:33 +03:00
},
2021-03-03 08:54:40 +03:00
2021-03-03 18:13:33 +03:00
// AnonymousHeadSlicePtrNilOnly
{
name: "AnonymousHeadSlicePtrNilOnly",
data: struct {
structSlicePtr
}{
structSlicePtr: structSlicePtr{A: nil},
2021-03-03 08:54:40 +03:00
},
2021-03-03 18:13:33 +03:00
},
{
name: "AnonymousHeadSlicePtrNilOnlyOmitEmpty",
data: struct {
structSlicePtrOmitEmpty
}{
structSlicePtrOmitEmpty: structSlicePtrOmitEmpty{A: nil},
2021-03-03 08:54:40 +03:00
},
2021-03-03 18:13:33 +03:00
},
{
name: "AnonymousHeadSlicePtrNilOnlyString",
data: struct {
structSlicePtrString
}{
structSlicePtrString: structSlicePtrString{A: nil},
2021-03-03 08:54:40 +03:00
},
2021-03-03 18:13:33 +03:00
},
2021-03-03 08:54:40 +03:00
2021-03-03 18:13:33 +03:00
// PtrAnonymousHeadSlicePtrOnly
{
name: "PtrAnonymousHeadSlicePtrOnly",
data: struct {
*structSlicePtr
}{
structSlicePtr: &structSlicePtr{A: sliceptr([]int{-1})},
2021-03-03 08:54:40 +03:00
},
2021-03-03 18:13:33 +03:00
},
{
name: "PtrAnonymousHeadSlicePtrOnlyOmitEmpty",
data: struct {
*structSlicePtrOmitEmpty
}{
structSlicePtrOmitEmpty: &structSlicePtrOmitEmpty{A: sliceptr([]int{-1})},
2021-03-03 08:54:40 +03:00
},
2021-03-03 18:13:33 +03:00
},
{
name: "PtrAnonymousHeadSlicePtrOnlyString",
data: struct {
*structSlicePtrString
}{
structSlicePtrString: &structSlicePtrString{A: sliceptr([]int{-1})},
2021-03-03 08:54:40 +03:00
},
2021-03-03 18:13:33 +03:00
},
2021-03-03 08:54:40 +03:00
2021-03-03 18:13:33 +03:00
// NilPtrAnonymousHeadSlicePtrOnly
{
name: "NilPtrAnonymousHeadSlicePtrOnly",
data: struct {
*structSlicePtr
}{
structSlicePtr: nil,
2021-03-03 08:54:40 +03:00
},
2021-03-03 18:13:33 +03:00
},
{
name: "NilPtrAnonymousHeadSlicePtrOnlyOmitEmpty",
data: struct {
*structSlicePtrOmitEmpty
}{
structSlicePtrOmitEmpty: nil,
2021-03-03 08:54:40 +03:00
},
2021-03-03 18:13:33 +03:00
},
{
name: "NilPtrAnonymousHeadSlicePtrOnlyString",
data: struct {
*structSlicePtrString
}{
structSlicePtrString: nil,
2021-03-03 08:54:40 +03:00
},
2021-03-03 18:13:33 +03:00
},
2021-03-03 08:54:40 +03:00
}
for _, test := range tests {
for _, indent := range []bool{false} {
for _, htmlEscape := range []bool{false} {
fmt.Println(test.name)
var buf bytes.Buffer
enc := json.NewEncoder(&buf)
enc.SetEscapeHTML(htmlEscape)
if indent {
enc.SetIndent("", " ")
}
if err := enc.Encode(test.data); err != nil {
t.Fatalf("%s(htmlEscape:%v,indent:%v): %+v: %s", test.name, htmlEscape, indent, test.data, err)
}
stdresult := encodeByEncodingJSON(test.data, indent, htmlEscape)
if buf.String() != stdresult {
t.Errorf("%s(htmlEscape:%v,indent:%v): doesn't compatible with encoding/json. expected %q but got %q", test.name, htmlEscape, indent, stdresult, buf.String())
}
}
}
}
}