go-json/test/cover/cover_uint8_test.go

1811 lines
35 KiB
Go
Raw Normal View History

2021-01-16 16:16:26 +03:00
package json_test
import (
"bytes"
"fmt"
2021-01-16 16:16:26 +03:00
"testing"
"github.com/goccy/go-json"
)
func TestCoverUint8(t *testing.T) {
type structUint8 struct {
A uint8 `json:"a"`
}
type structUint8OmitEmpty struct {
A uint8 `json:"a,omitempty"`
}
type structUint8String struct {
A uint8 `json:"a,string"`
}
2021-01-16 16:16:26 +03:00
type structUint8Ptr struct {
A *uint8 `json:"a"`
}
type structUint8PtrOmitEmpty struct {
A *uint8 `json:"a,omitempty"`
}
type structUint8PtrString struct {
A *uint8 `json:"a,string"`
}
2021-01-16 16:16:26 +03:00
tests := []struct {
2021-02-15 05:27:37 +03:00
name string
data interface{}
2021-01-16 16:16:26 +03:00
}{
2021-03-19 17:31:29 +03:00
{
name: "Uint8",
data: uint8(10),
},
{
name: "Uint8Ptr",
data: uint8ptr(10),
},
{
name: "Uint8Ptr3",
data: uint8ptr3(10),
},
{
name: "Uint8PtrNil",
data: (*uint8)(nil),
},
{
name: "Uint8Ptr3Nil",
data: (***uint8)(nil),
},
// HeadUint8Zero
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8Zero",
2021-01-16 16:16:26 +03:00
data: struct {
A uint8 `json:"a"`
}{},
},
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8ZeroOmitEmpty",
data: struct {
A uint8 `json:"a,omitempty"`
}{},
},
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8ZeroString",
data: struct {
A uint8 `json:"a,string"`
}{},
},
// HeadUint8
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8",
2021-01-16 16:16:26 +03:00
data: struct {
A uint8 `json:"a"`
}{A: 1},
},
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8OmitEmpty",
data: struct {
A uint8 `json:"a,omitempty"`
}{A: 1},
},
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8String",
data: struct {
A uint8 `json:"a,string"`
}{A: 1},
},
// HeadUint8Ptr
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8Ptr",
2021-01-16 16:16:26 +03:00
data: struct {
A *uint8 `json:"a"`
}{A: uint8ptr(1)},
},
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8PtrOmitEmpty",
data: struct {
A *uint8 `json:"a,omitempty"`
}{A: uint8ptr(1)},
},
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8PtrString",
data: struct {
A *uint8 `json:"a,string"`
}{A: uint8ptr(1)},
},
// HeadUint8PtrNil
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8PtrNil",
2021-01-16 16:16:26 +03:00
data: struct {
A *uint8 `json:"a"`
}{A: nil},
},
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8PtrNilOmitEmpty",
data: struct {
A *uint8 `json:"a,omitempty"`
}{A: nil},
},
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8PtrNilString",
data: struct {
A *uint8 `json:"a,string"`
}{A: nil},
},
// PtrHeadUint8Zero
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8Zero",
2021-01-16 16:16:26 +03:00
data: &struct {
A uint8 `json:"a"`
}{},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8ZeroOmitEmpty",
data: &struct {
A uint8 `json:"a,omitempty"`
}{},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8ZeroString",
data: &struct {
A uint8 `json:"a,string"`
}{},
},
// PtrHeadUint8
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8",
2021-01-16 16:16:26 +03:00
data: &struct {
A uint8 `json:"a"`
}{A: 1},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8OmitEmpty",
data: &struct {
A uint8 `json:"a,omitempty"`
}{A: 1},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8String",
data: &struct {
A uint8 `json:"a,string"`
}{A: 1},
},
// PtrHeadUint8Ptr
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8Ptr",
2021-01-16 16:16:26 +03:00
data: &struct {
A *uint8 `json:"a"`
}{A: uint8ptr(1)},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8PtrOmitEmpty",
data: &struct {
A *uint8 `json:"a,omitempty"`
}{A: uint8ptr(1)},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8PtrString",
data: &struct {
A *uint8 `json:"a,string"`
}{A: uint8ptr(1)},
},
// PtrHeadUint8PtrNil
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8PtrNil",
2021-01-16 16:16:26 +03:00
data: &struct {
A *uint8 `json:"a"`
}{A: nil},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8PtrNilOmitEmpty",
data: &struct {
A *uint8 `json:"a,omitempty"`
}{A: nil},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8PtrNilString",
data: &struct {
A *uint8 `json:"a,string"`
}{A: nil},
},
// PtrHeadUint8Nil
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8Nil",
2021-01-16 16:16:26 +03:00
data: (*struct {
A *uint8 `json:"a"`
})(nil),
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8NilOmitEmpty",
data: (*struct {
A *uint8 `json:"a,omitempty"`
})(nil),
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8NilString",
data: (*struct {
A *uint8 `json:"a,string"`
})(nil),
},
// HeadUint8ZeroMultiFields
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8ZeroMultiFields",
2021-01-16 16:16:26 +03:00
data: struct {
A uint8 `json:"a"`
B uint8 `json:"b"`
2021-02-15 05:27:37 +03:00
C uint8 `json:"c"`
2021-01-16 16:16:26 +03:00
}{},
},
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8ZeroMultiFieldsOmitEmpty",
data: struct {
A uint8 `json:"a,omitempty"`
B uint8 `json:"b,omitempty"`
2021-02-15 05:27:37 +03:00
C uint8 `json:"c,omitempty"`
}{},
},
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8ZeroMultiFields",
data: struct {
A uint8 `json:"a,string"`
B uint8 `json:"b,string"`
2021-02-15 05:27:37 +03:00
C uint8 `json:"c,string"`
}{},
},
// HeadUint8MultiFields
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8MultiFields",
2021-01-16 16:16:26 +03:00
data: struct {
A uint8 `json:"a"`
B uint8 `json:"b"`
2021-02-15 05:27:37 +03:00
C uint8 `json:"c"`
}{A: 1, B: 2, C: 3},
2021-01-16 16:16:26 +03:00
},
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8MultiFieldsOmitEmpty",
2021-01-16 16:16:26 +03:00
data: struct {
A uint8 `json:"a,omitempty"`
B uint8 `json:"b,omitempty"`
2021-02-15 05:27:37 +03:00
C uint8 `json:"c,omitempty"`
}{A: 1, B: 2, C: 3},
2021-01-16 16:16:26 +03:00
},
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8MultiFieldsString",
2021-01-16 16:16:26 +03:00
data: struct {
A uint8 `json:"a,string"`
B uint8 `json:"b,string"`
2021-02-15 05:27:37 +03:00
C uint8 `json:"c,string"`
}{A: 1, B: 2, C: 3},
2021-01-16 16:16:26 +03:00
},
// HeadUint8PtrMultiFields
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8PtrMultiFields",
data: struct {
A *uint8 `json:"a"`
B *uint8 `json:"b"`
2021-02-15 05:27:37 +03:00
C *uint8 `json:"c"`
}{A: uint8ptr(1), B: uint8ptr(2), C: uint8ptr(3)},
2021-01-16 16:16:26 +03:00
},
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8PtrMultiFieldsOmitEmpty",
data: struct {
A *uint8 `json:"a,omitempty"`
B *uint8 `json:"b,omitempty"`
2021-02-15 05:27:37 +03:00
C *uint8 `json:"c,omitempty"`
}{A: uint8ptr(1), B: uint8ptr(2), C: uint8ptr(3)},
2021-01-16 16:16:26 +03:00
},
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8PtrMultiFieldsString",
data: struct {
A *uint8 `json:"a,string"`
B *uint8 `json:"b,string"`
2021-02-15 05:27:37 +03:00
C *uint8 `json:"c,string"`
}{A: uint8ptr(1), B: uint8ptr(2), C: uint8ptr(3)},
2021-01-16 16:16:26 +03:00
},
// HeadUint8PtrNilMultiFields
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8PtrNilMultiFields",
data: struct {
2021-01-16 16:16:26 +03:00
A *uint8 `json:"a"`
B *uint8 `json:"b"`
2021-02-15 05:27:37 +03:00
C *uint8 `json:"c"`
}{A: nil, B: nil, C: nil},
2021-01-16 16:16:26 +03:00
},
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8PtrNilMultiFieldsOmitEmpty",
data: struct {
A *uint8 `json:"a,omitempty"`
B *uint8 `json:"b,omitempty"`
2021-02-15 05:27:37 +03:00
C *uint8 `json:"c,omitempty"`
}{A: nil, B: nil, C: nil},
2021-01-16 16:16:26 +03:00
},
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8PtrNilMultiFieldsString",
data: struct {
A *uint8 `json:"a,string"`
B *uint8 `json:"b,string"`
2021-02-15 05:27:37 +03:00
C *uint8 `json:"c,string"`
}{A: nil, B: nil, C: nil},
},
// PtrHeadUint8ZeroMultiFields
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8ZeroMultiFields",
data: &struct {
A uint8 `json:"a"`
B uint8 `json:"b"`
}{},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8ZeroMultiFieldsOmitEmpty",
data: &struct {
A uint8 `json:"a,omitempty"`
B uint8 `json:"b,omitempty"`
}{},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8ZeroMultiFieldsString",
data: &struct {
A uint8 `json:"a,string"`
B uint8 `json:"b,string"`
}{},
},
// PtrHeadUint8MultiFields
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8MultiFields",
data: &struct {
A uint8 `json:"a"`
B uint8 `json:"b"`
}{A: 1, B: 2},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8MultiFieldsOmitEmpty",
data: &struct {
A uint8 `json:"a,omitempty"`
B uint8 `json:"b,omitempty"`
}{A: 1, B: 2},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8MultiFieldsString",
data: &struct {
A uint8 `json:"a,string"`
B uint8 `json:"b,string"`
}{A: 1, B: 2},
},
// PtrHeadUint8PtrMultiFields
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8PtrMultiFields",
data: &struct {
A *uint8 `json:"a"`
B *uint8 `json:"b"`
}{A: uint8ptr(1), B: uint8ptr(2)},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8PtrMultiFieldsOmitEmpty",
data: &struct {
A *uint8 `json:"a,omitempty"`
B *uint8 `json:"b,omitempty"`
}{A: uint8ptr(1), B: uint8ptr(2)},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8PtrMultiFieldsString",
data: &struct {
A *uint8 `json:"a,string"`
B *uint8 `json:"b,string"`
}{A: uint8ptr(1), B: uint8ptr(2)},
},
// PtrHeadUint8PtrNilMultiFields
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8PtrNilMultiFields",
data: &struct {
A *uint8 `json:"a"`
B *uint8 `json:"b"`
}{A: nil, B: nil},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8PtrNilMultiFieldsOmitEmpty",
data: &struct {
A *uint8 `json:"a,omitempty"`
B *uint8 `json:"b,omitempty"`
}{A: nil, B: nil},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8PtrNilMultiFieldsString",
data: &struct {
A *uint8 `json:"a,string"`
B *uint8 `json:"b,string"`
}{A: nil, B: nil},
},
// PtrHeadUint8NilMultiFields
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8NilMultiFields",
data: (*struct {
A *uint8 `json:"a"`
B *uint8 `json:"b"`
})(nil),
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8NilMultiFieldsOmitEmpty",
data: (*struct {
A *uint8 `json:"a,omitempty"`
B *uint8 `json:"b,omitempty"`
})(nil),
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8NilMultiFieldsString",
data: (*struct {
A *uint8 `json:"a,string"`
B *uint8 `json:"b,string"`
})(nil),
},
// HeadUint8ZeroNotRoot
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8ZeroNotRoot",
2021-01-16 16:16:26 +03:00
data: struct {
A struct {
A uint8 `json:"a"`
}
}{},
},
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8ZeroNotRootOmitEmpty",
data: struct {
A struct {
A uint8 `json:"a,omitempty"`
}
}{},
},
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8ZeroNotRootString",
data: struct {
A struct {
A uint8 `json:"a,string"`
}
}{},
},
// HeadUint8NotRoot
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8NotRoot",
2021-01-16 16:16:26 +03:00
data: struct {
A struct {
A uint8 `json:"a"`
}
}{A: struct {
A uint8 `json:"a"`
}{A: 1}},
},
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8NotRootOmitEmpty",
2021-01-16 16:16:26 +03:00
data: struct {
A struct {
A uint8 `json:"a,omitempty"`
2021-01-16 16:16:26 +03:00
}
}{A: struct {
A uint8 `json:"a,omitempty"`
}{A: 1}},
2021-01-16 16:16:26 +03:00
},
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8NotRootString",
2021-01-16 16:16:26 +03:00
data: struct {
A struct {
A uint8 `json:"a,string"`
2021-01-16 16:16:26 +03:00
}
}{A: struct {
A uint8 `json:"a,string"`
}{A: 1}},
2021-01-16 16:16:26 +03:00
},
// HeadUint8PtrNotRoot
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8PtrNotRoot",
2021-01-16 16:16:26 +03:00
data: struct {
A struct {
A *uint8 `json:"a"`
2021-01-16 16:16:26 +03:00
}
}{A: struct {
A *uint8 `json:"a"`
}{uint8ptr(1)}},
2021-01-16 16:16:26 +03:00
},
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8PtrNotRootOmitEmpty",
2021-01-16 16:16:26 +03:00
data: struct {
A struct {
A *uint8 `json:"a,omitempty"`
2021-01-16 16:16:26 +03:00
}
}{A: struct {
A *uint8 `json:"a,omitempty"`
}{uint8ptr(1)}},
2021-01-16 16:16:26 +03:00
},
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8PtrNotRootString",
2021-01-16 16:16:26 +03:00
data: struct {
A struct {
A *uint8 `json:"a,string"`
2021-01-16 16:16:26 +03:00
}
}{A: struct {
A *uint8 `json:"a,string"`
}{uint8ptr(1)}},
2021-01-16 16:16:26 +03:00
},
// HeadUint8PtrNilNotRoot
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8PtrNilNotRoot",
data: struct {
A struct {
A *uint8 `json:"a"`
}
}{},
},
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8PtrNilNotRootOmitEmpty",
data: struct {
A struct {
A *uint8 `json:"a,omitempty"`
}
}{},
},
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8PtrNilNotRootString",
data: struct {
A struct {
A *uint8 `json:"a,string"`
}
}{},
},
// PtrHeadUint8ZeroNotRoot
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8ZeroNotRoot",
data: struct {
A *struct {
A uint8 `json:"a"`
}
}{A: new(struct {
A uint8 `json:"a"`
})},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8ZeroNotRootOmitEmpty",
data: struct {
A *struct {
A uint8 `json:"a,omitempty"`
}
}{A: new(struct {
A uint8 `json:"a,omitempty"`
})},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8ZeroNotRootString",
data: struct {
A *struct {
A uint8 `json:"a,string"`
}
}{A: new(struct {
A uint8 `json:"a,string"`
})},
},
// PtrHeadUint8NotRoot
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8NotRoot",
data: struct {
A *struct {
A uint8 `json:"a"`
}
}{A: &(struct {
A uint8 `json:"a"`
}{A: 1})},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8NotRootOmitEmpty",
data: struct {
A *struct {
A uint8 `json:"a,omitempty"`
}
}{A: &(struct {
A uint8 `json:"a,omitempty"`
}{A: 1})},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8NotRootString",
data: struct {
A *struct {
A uint8 `json:"a,string"`
}
}{A: &(struct {
A uint8 `json:"a,string"`
}{A: 1})},
},
// PtrHeadUint8PtrNotRoot
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8PtrNotRoot",
data: struct {
A *struct {
A *uint8 `json:"a"`
}
}{A: &(struct {
A *uint8 `json:"a"`
}{A: uint8ptr(1)})},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8PtrNotRootOmitEmpty",
data: struct {
A *struct {
A *uint8 `json:"a,omitempty"`
}
}{A: &(struct {
A *uint8 `json:"a,omitempty"`
}{A: uint8ptr(1)})},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8PtrNotRootString",
data: struct {
A *struct {
A *uint8 `json:"a,string"`
}
}{A: &(struct {
A *uint8 `json:"a,string"`
}{A: uint8ptr(1)})},
},
// PtrHeadUint8PtrNilNotRoot
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8PtrNilNotRoot",
data: struct {
A *struct {
A *uint8 `json:"a"`
}
}{A: &(struct {
A *uint8 `json:"a"`
}{A: nil})},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8PtrNilNotRootOmitEmpty",
data: struct {
A *struct {
A *uint8 `json:"a,omitempty"`
}
}{A: &(struct {
A *uint8 `json:"a,omitempty"`
}{A: nil})},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8PtrNilNotRootString",
data: struct {
A *struct {
A *uint8 `json:"a,string"`
}
}{A: &(struct {
A *uint8 `json:"a,string"`
}{A: nil})},
},
// PtrHeadUint8NilNotRoot
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8NilNotRoot",
data: struct {
A *struct {
A *uint8 `json:"a"`
}
}{A: nil},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8NilNotRootOmitEmpty",
data: struct {
A *struct {
A *uint8 `json:"a,omitempty"`
} `json:",omitempty"`
}{A: nil},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8NilNotRootString",
data: struct {
A *struct {
A *uint8 `json:"a,string"`
} `json:",string"`
}{A: nil},
},
// HeadUint8ZeroMultiFieldsNotRoot
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8ZeroMultiFieldsNotRoot",
data: struct {
A struct {
A uint8 `json:"a"`
}
B struct {
B uint8 `json:"b"`
}
}{},
},
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8ZeroMultiFieldsNotRootOmitEmpty",
data: struct {
A struct {
A uint8 `json:"a,omitempty"`
}
B struct {
B uint8 `json:"b,omitempty"`
}
}{},
},
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8ZeroMultiFieldsNotRootString",
data: struct {
A struct {
A uint8 `json:"a,string"`
}
B struct {
B uint8 `json:"b,string"`
}
}{},
},
// HeadUint8MultiFieldsNotRoot
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8MultiFieldsNotRoot",
data: struct {
A struct {
A uint8 `json:"a"`
}
B struct {
B uint8 `json:"b"`
}
}{A: struct {
A uint8 `json:"a"`
}{A: 1}, B: struct {
B uint8 `json:"b"`
}{B: 2}},
},
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8MultiFieldsNotRootOmitEmpty",
data: struct {
A struct {
A uint8 `json:"a,omitempty"`
}
B struct {
B uint8 `json:"b,omitempty"`
}
}{A: struct {
A uint8 `json:"a,omitempty"`
}{A: 1}, B: struct {
B uint8 `json:"b,omitempty"`
}{B: 2}},
},
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8MultiFieldsNotRootString",
data: struct {
A struct {
A uint8 `json:"a,string"`
}
B struct {
B uint8 `json:"b,string"`
}
}{A: struct {
A uint8 `json:"a,string"`
}{A: 1}, B: struct {
B uint8 `json:"b,string"`
}{B: 2}},
},
// HeadUint8PtrMultiFieldsNotRoot
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8PtrMultiFieldsNotRoot",
data: struct {
A struct {
A *uint8 `json:"a"`
}
B struct {
B *uint8 `json:"b"`
}
}{A: struct {
A *uint8 `json:"a"`
}{A: uint8ptr(1)}, B: struct {
B *uint8 `json:"b"`
}{B: uint8ptr(2)}},
},
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8PtrMultiFieldsNotRootOmitEmpty",
data: struct {
A struct {
A *uint8 `json:"a,omitempty"`
}
B struct {
B *uint8 `json:"b,omitempty"`
}
}{A: struct {
A *uint8 `json:"a,omitempty"`
}{A: uint8ptr(1)}, B: struct {
B *uint8 `json:"b,omitempty"`
}{B: uint8ptr(2)}},
},
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8PtrMultiFieldsNotRootString",
data: struct {
A struct {
A *uint8 `json:"a,string"`
}
B struct {
B *uint8 `json:"b,string"`
}
}{A: struct {
A *uint8 `json:"a,string"`
}{A: uint8ptr(1)}, B: struct {
B *uint8 `json:"b,string"`
}{B: uint8ptr(2)}},
},
// HeadUint8PtrNilMultiFieldsNotRoot
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8PtrNilMultiFieldsNotRoot",
data: struct {
A struct {
A *uint8 `json:"a"`
}
B struct {
B *uint8 `json:"b"`
}
}{A: struct {
A *uint8 `json:"a"`
}{A: nil}, B: struct {
B *uint8 `json:"b"`
}{B: nil}},
},
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8PtrNilMultiFieldsNotRootOmitEmpty",
data: struct {
A struct {
A *uint8 `json:"a,omitempty"`
}
B struct {
B *uint8 `json:"b,omitempty"`
}
}{A: struct {
A *uint8 `json:"a,omitempty"`
}{A: nil}, B: struct {
B *uint8 `json:"b,omitempty"`
}{B: nil}},
},
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8PtrNilMultiFieldsNotRootString",
data: struct {
A struct {
A *uint8 `json:"a,string"`
}
B struct {
B *uint8 `json:"b,string"`
}
}{A: struct {
A *uint8 `json:"a,string"`
}{A: nil}, B: struct {
B *uint8 `json:"b,string"`
}{B: nil}},
},
// PtrHeadUint8ZeroMultiFieldsNotRoot
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8ZeroMultiFieldsNotRoot",
data: &struct {
A struct {
A uint8 `json:"a"`
2021-01-16 16:16:26 +03:00
}
B struct {
B uint8 `json:"b"`
}
}{},
2021-01-16 16:16:26 +03:00
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8ZeroMultiFieldsNotRootOmitEmpty",
data: &struct {
A struct {
A uint8 `json:"a,omitempty"`
2021-01-16 16:16:26 +03:00
}
B struct {
B uint8 `json:"b,omitempty"`
}
}{},
2021-01-16 16:16:26 +03:00
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8ZeroMultiFieldsNotRootString",
data: &struct {
2021-01-16 16:16:26 +03:00
A struct {
A uint8 `json:"a,string"`
2021-01-16 16:16:26 +03:00
}
B struct {
B uint8 `json:"b,string"`
2021-01-16 16:16:26 +03:00
}
}{},
},
// PtrHeadUint8MultiFieldsNotRoot
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8MultiFieldsNotRoot",
data: &struct {
2021-01-16 16:16:26 +03:00
A struct {
A uint8 `json:"a"`
}
B struct {
B uint8 `json:"b"`
}
}{A: struct {
A uint8 `json:"a"`
}{A: 1}, B: struct {
B uint8 `json:"b"`
}{B: 2}},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8MultiFieldsNotRootOmitEmpty",
data: &struct {
2021-01-16 16:16:26 +03:00
A struct {
A uint8 `json:"a,omitempty"`
2021-01-16 16:16:26 +03:00
}
B struct {
B uint8 `json:"b,omitempty"`
2021-01-16 16:16:26 +03:00
}
}{A: struct {
A uint8 `json:"a,omitempty"`
}{A: 1}, B: struct {
B uint8 `json:"b,omitempty"`
}{B: 2}},
2021-01-16 16:16:26 +03:00
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8MultiFieldsNotRootString",
data: &struct {
2021-01-16 16:16:26 +03:00
A struct {
A uint8 `json:"a,string"`
2021-01-16 16:16:26 +03:00
}
B struct {
B uint8 `json:"b,string"`
2021-01-16 16:16:26 +03:00
}
}{A: struct {
A uint8 `json:"a,string"`
}{A: 1}, B: struct {
B uint8 `json:"b,string"`
}{B: 2}},
2021-01-16 16:16:26 +03:00
},
// PtrHeadUint8PtrMultiFieldsNotRoot
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8PtrMultiFieldsNotRoot",
2021-01-16 16:16:26 +03:00
data: &struct {
A *struct {
A *uint8 `json:"a"`
2021-01-16 16:16:26 +03:00
}
B *struct {
B *uint8 `json:"b"`
2021-01-16 16:16:26 +03:00
}
}{A: &(struct {
A *uint8 `json:"a"`
}{A: uint8ptr(1)}), B: &(struct {
B *uint8 `json:"b"`
}{B: uint8ptr(2)})},
2021-01-16 16:16:26 +03:00
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8PtrMultiFieldsNotRootOmitEmpty",
2021-01-16 16:16:26 +03:00
data: &struct {
A *struct {
A *uint8 `json:"a,omitempty"`
}
B *struct {
B *uint8 `json:"b,omitempty"`
}
}{A: &(struct {
A *uint8 `json:"a,omitempty"`
}{A: uint8ptr(1)}), B: &(struct {
B *uint8 `json:"b,omitempty"`
}{B: uint8ptr(2)})},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8PtrMultiFieldsNotRootString",
data: &struct {
A *struct {
A *uint8 `json:"a,string"`
}
B *struct {
B *uint8 `json:"b,string"`
}
}{A: &(struct {
A *uint8 `json:"a,string"`
}{A: uint8ptr(1)}), B: &(struct {
B *uint8 `json:"b,string"`
}{B: uint8ptr(2)})},
},
// PtrHeadUint8PtrNilMultiFieldsNotRoot
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8PtrNilMultiFieldsNotRoot",
data: &struct {
A *struct {
A *uint8 `json:"a"`
}
B *struct {
B *uint8 `json:"b"`
}
}{A: nil, B: nil},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8PtrNilMultiFieldsNotRootOmitEmpty",
data: &struct {
A *struct {
A *uint8 `json:"a,omitempty"`
} `json:",omitempty"`
B *struct {
B *uint8 `json:"b,omitempty"`
} `json:",omitempty"`
}{A: nil, B: nil},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8PtrNilMultiFieldsNotRootString",
data: &struct {
A *struct {
A *uint8 `json:"a,string"`
} `json:",string"`
B *struct {
B *uint8 `json:"b,string"`
} `json:",string"`
}{A: nil, B: nil},
},
// PtrHeadUint8NilMultiFieldsNotRoot
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8NilMultiFieldsNotRoot",
data: (*struct {
A *struct {
A *uint8 `json:"a"`
}
B *struct {
B *uint8 `json:"b"`
}
})(nil),
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8NilMultiFieldsNotRootOmitEmpty",
data: (*struct {
A *struct {
A *uint8 `json:"a,omitempty"`
}
B *struct {
B *uint8 `json:"b,omitempty"`
}
})(nil),
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8NilMultiFieldsNotRootString",
data: (*struct {
A *struct {
A *uint8 `json:"a,string"`
}
B *struct {
B *uint8 `json:"b,string"`
}
})(nil),
},
// PtrHeadUint8DoubleMultiFieldsNotRoot
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8DoubleMultiFieldsNotRoot",
data: &struct {
A *struct {
2021-01-16 16:16:26 +03:00
A uint8 `json:"a"`
B uint8 `json:"b"`
2021-01-16 16:16:26 +03:00
}
B *struct {
A uint8 `json:"a"`
2021-01-16 16:16:26 +03:00
B uint8 `json:"b"`
}
}{A: &(struct {
2021-01-16 16:16:26 +03:00
A uint8 `json:"a"`
B uint8 `json:"b"`
}{A: 1, B: 2}), B: &(struct {
A uint8 `json:"a"`
B uint8 `json:"b"`
}{A: 3, B: 4})},
2021-01-16 16:16:26 +03:00
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8DoubleMultiFieldsNotRootOmitEmpty",
data: &struct {
A *struct {
A uint8 `json:"a,omitempty"`
B uint8 `json:"b,omitempty"`
}
B *struct {
A uint8 `json:"a,omitempty"`
B uint8 `json:"b,omitempty"`
}
}{A: &(struct {
A uint8 `json:"a,omitempty"`
B uint8 `json:"b,omitempty"`
}{A: 1, B: 2}), B: &(struct {
A uint8 `json:"a,omitempty"`
B uint8 `json:"b,omitempty"`
}{A: 3, B: 4})},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8DoubleMultiFieldsNotRootString",
2021-01-16 16:16:26 +03:00
data: &struct {
A *struct {
A uint8 `json:"a,string"`
B uint8 `json:"b,string"`
2021-01-16 16:16:26 +03:00
}
B *struct {
A uint8 `json:"a,string"`
B uint8 `json:"b,string"`
2021-01-16 16:16:26 +03:00
}
}{A: &(struct {
A uint8 `json:"a,string"`
B uint8 `json:"b,string"`
}{A: 1, B: 2}), B: &(struct {
A uint8 `json:"a,string"`
B uint8 `json:"b,string"`
}{A: 3, B: 4})},
2021-01-16 16:16:26 +03:00
},
// PtrHeadUint8NilDoubleMultiFieldsNotRoot
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8NilDoubleMultiFieldsNotRoot",
2021-01-16 16:16:26 +03:00
data: &struct {
A *struct {
A uint8 `json:"a"`
B uint8 `json:"b"`
2021-01-16 16:16:26 +03:00
}
B *struct {
A uint8 `json:"a"`
B uint8 `json:"b"`
2021-01-16 16:16:26 +03:00
}
}{A: nil, B: nil},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8NilDoubleMultiFieldsNotRootOmitEmpty",
data: &struct {
2021-01-16 16:16:26 +03:00
A *struct {
A uint8 `json:"a,omitempty"`
B uint8 `json:"b,omitempty"`
} `json:",omitempty"`
2021-01-16 16:16:26 +03:00
B *struct {
A uint8 `json:"a,omitempty"`
B uint8 `json:"b,omitempty"`
} `json:",omitempty"`
}{A: nil, B: nil},
2021-01-16 16:16:26 +03:00
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8NilDoubleMultiFieldsNotRootString",
2021-01-16 16:16:26 +03:00
data: &struct {
A *struct {
A uint8 `json:"a,string"`
B uint8 `json:"b,string"`
2021-01-16 16:16:26 +03:00
}
B *struct {
A uint8 `json:"a,string"`
B uint8 `json:"b,string"`
2021-01-16 16:16:26 +03:00
}
}{A: nil, B: nil},
2021-01-16 16:16:26 +03:00
},
// PtrHeadUint8NilDoubleMultiFieldsNotRoot
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8NilDoubleMultiFieldsNotRoot",
data: (*struct {
2021-01-16 16:16:26 +03:00
A *struct {
A uint8 `json:"a"`
B uint8 `json:"b"`
}
B *struct {
A uint8 `json:"a"`
B uint8 `json:"b"`
}
})(nil),
2021-01-16 16:16:26 +03:00
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8NilDoubleMultiFieldsNotRootOmitEmpty",
2021-01-16 16:16:26 +03:00
data: (*struct {
A *struct {
A uint8 `json:"a,omitempty"`
B uint8 `json:"b,omitempty"`
2021-01-16 16:16:26 +03:00
}
B *struct {
A uint8 `json:"a,omitempty"`
B uint8 `json:"b,omitempty"`
}
})(nil),
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8NilDoubleMultiFieldsNotRootString",
data: (*struct {
A *struct {
A uint8 `json:"a,string"`
B uint8 `json:"b,string"`
}
B *struct {
A uint8 `json:"a,string"`
B uint8 `json:"b,string"`
2021-01-16 16:16:26 +03:00
}
})(nil),
},
// PtrHeadUint8PtrDoubleMultiFieldsNotRoot
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8PtrDoubleMultiFieldsNotRoot",
2021-01-16 16:16:26 +03:00
data: &struct {
A *struct {
A *uint8 `json:"a"`
B *uint8 `json:"b"`
}
B *struct {
A *uint8 `json:"a"`
B *uint8 `json:"b"`
}
}{A: &(struct {
A *uint8 `json:"a"`
B *uint8 `json:"b"`
}{A: uint8ptr(1), B: uint8ptr(2)}), B: &(struct {
A *uint8 `json:"a"`
B *uint8 `json:"b"`
}{A: uint8ptr(3), B: uint8ptr(4)})},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8PtrDoubleMultiFieldsNotRootOmitEmpty",
data: &struct {
A *struct {
A *uint8 `json:"a,omitempty"`
B *uint8 `json:"b,omitempty"`
}
B *struct {
A *uint8 `json:"a,omitempty"`
B *uint8 `json:"b,omitempty"`
}
}{A: &(struct {
A *uint8 `json:"a,omitempty"`
B *uint8 `json:"b,omitempty"`
}{A: uint8ptr(1), B: uint8ptr(2)}), B: &(struct {
A *uint8 `json:"a,omitempty"`
B *uint8 `json:"b,omitempty"`
}{A: uint8ptr(3), B: uint8ptr(4)})},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8PtrDoubleMultiFieldsNotRootString",
data: &struct {
A *struct {
A *uint8 `json:"a,string"`
B *uint8 `json:"b,string"`
}
B *struct {
A *uint8 `json:"a,string"`
B *uint8 `json:"b,string"`
}
}{A: &(struct {
A *uint8 `json:"a,string"`
B *uint8 `json:"b,string"`
}{A: uint8ptr(1), B: uint8ptr(2)}), B: &(struct {
A *uint8 `json:"a,string"`
B *uint8 `json:"b,string"`
}{A: uint8ptr(3), B: uint8ptr(4)})},
},
// PtrHeadUint8PtrNilDoubleMultiFieldsNotRoot
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8PtrNilDoubleMultiFieldsNotRoot",
2021-01-16 16:16:26 +03:00
data: &struct {
A *struct {
A *uint8 `json:"a"`
B *uint8 `json:"b"`
}
B *struct {
A *uint8 `json:"a"`
B *uint8 `json:"b"`
}
}{A: nil, B: nil},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8PtrNilDoubleMultiFieldsNotRootOmitEmpty",
data: &struct {
A *struct {
A *uint8 `json:"a,omitempty"`
B *uint8 `json:"b,omitempty"`
} `json:",omitempty"`
B *struct {
A *uint8 `json:"a,omitempty"`
B *uint8 `json:"b,omitempty"`
} `json:",omitempty"`
}{A: nil, B: nil},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8PtrNilDoubleMultiFieldsNotRootString",
data: &struct {
A *struct {
A *uint8 `json:"a,string"`
B *uint8 `json:"b,string"`
}
B *struct {
A *uint8 `json:"a,string"`
B *uint8 `json:"b,string"`
}
}{A: nil, B: nil},
},
// PtrHeadUint8PtrNilDoubleMultiFieldsNotRoot
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8PtrNilDoubleMultiFieldsNotRoot",
2021-01-16 16:16:26 +03:00
data: (*struct {
A *struct {
A *uint8 `json:"a"`
B *uint8 `json:"b"`
}
B *struct {
A *uint8 `json:"a"`
B *uint8 `json:"b"`
}
})(nil),
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8PtrNilDoubleMultiFieldsNotRootOmitEmpty",
data: (*struct {
A *struct {
A *uint8 `json:"a,omitempty"`
B *uint8 `json:"b,omitempty"`
}
B *struct {
A *uint8 `json:"a,omitempty"`
B *uint8 `json:"b,omitempty"`
}
})(nil),
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8PtrNilDoubleMultiFieldsNotRootString",
data: (*struct {
A *struct {
A *uint8 `json:"a,string"`
B *uint8 `json:"b,string"`
}
B *struct {
A *uint8 `json:"a,string"`
B *uint8 `json:"b,string"`
}
})(nil),
},
// AnonymousHeadUint8
{
2021-02-15 05:27:37 +03:00
name: "AnonymousHeadUint8",
data: struct {
structUint8
B uint8 `json:"b"`
}{
structUint8: structUint8{A: 1},
B: 2,
},
},
{
2021-02-15 05:27:37 +03:00
name: "AnonymousHeadUint8OmitEmpty",
data: struct {
structUint8OmitEmpty
B uint8 `json:"b,omitempty"`
}{
structUint8OmitEmpty: structUint8OmitEmpty{A: 1},
B: 2,
},
},
{
2021-02-15 05:27:37 +03:00
name: "AnonymousHeadUint8String",
data: struct {
structUint8String
B uint8 `json:"b,string"`
}{
structUint8String: structUint8String{A: 1},
B: 2,
},
},
// PtrAnonymousHeadUint8
{
2021-02-15 05:27:37 +03:00
name: "PtrAnonymousHeadUint8",
data: struct {
*structUint8
B uint8 `json:"b"`
}{
structUint8: &structUint8{A: 1},
B: 2,
},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrAnonymousHeadUint8OmitEmpty",
data: struct {
*structUint8OmitEmpty
B uint8 `json:"b,omitempty"`
}{
structUint8OmitEmpty: &structUint8OmitEmpty{A: 1},
B: 2,
},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrAnonymousHeadUint8String",
data: struct {
*structUint8String
B uint8 `json:"b,string"`
}{
structUint8String: &structUint8String{A: 1},
B: 2,
},
},
// NilPtrAnonymousHeadUint8
{
2021-02-15 05:27:37 +03:00
name: "NilPtrAnonymousHeadUint8",
2021-01-16 16:16:26 +03:00
data: struct {
*structUint8
2021-01-16 16:16:26 +03:00
B uint8 `json:"b"`
}{
structUint8: nil,
2021-01-16 16:16:26 +03:00
B: 2,
},
},
{
2021-02-15 05:27:37 +03:00
name: "NilPtrAnonymousHeadUint8OmitEmpty",
2021-01-16 16:16:26 +03:00
data: struct {
*structUint8OmitEmpty
B uint8 `json:"b,omitempty"`
2021-01-16 16:16:26 +03:00
}{
structUint8OmitEmpty: nil,
B: 2,
2021-01-16 16:16:26 +03:00
},
},
{
2021-02-15 05:27:37 +03:00
name: "NilPtrAnonymousHeadUint8String",
2021-01-16 16:16:26 +03:00
data: struct {
*structUint8String
B uint8 `json:"b,string"`
2021-01-16 16:16:26 +03:00
}{
structUint8String: nil,
B: 2,
2021-01-16 16:16:26 +03:00
},
},
// AnonymousHeadUint8Ptr
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:27:37 +03:00
name: "AnonymousHeadUint8Ptr",
2021-01-16 16:16:26 +03:00
data: struct {
structUint8Ptr
B *uint8 `json:"b"`
}{
structUint8Ptr: structUint8Ptr{A: uint8ptr(1)},
B: uint8ptr(2),
},
},
{
2021-02-15 05:27:37 +03:00
name: "AnonymousHeadUint8PtrOmitEmpty",
data: struct {
structUint8PtrOmitEmpty
B *uint8 `json:"b,omitempty"`
}{
structUint8PtrOmitEmpty: structUint8PtrOmitEmpty{A: uint8ptr(1)},
B: uint8ptr(2),
},
},
{
2021-02-15 05:27:37 +03:00
name: "AnonymousHeadUint8PtrString",
data: struct {
structUint8PtrString
B *uint8 `json:"b,string"`
}{
structUint8PtrString: structUint8PtrString{A: uint8ptr(1)},
B: uint8ptr(2),
},
},
// AnonymousHeadUint8PtrNil
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:27:37 +03:00
name: "AnonymousHeadUint8PtrNil",
2021-01-16 16:16:26 +03:00
data: struct {
structUint8Ptr
B *uint8 `json:"b"`
}{
structUint8Ptr: structUint8Ptr{A: nil},
B: uint8ptr(2),
},
},
{
2021-02-15 05:27:37 +03:00
name: "AnonymousHeadUint8PtrNilOmitEmpty",
data: struct {
structUint8PtrOmitEmpty
B *uint8 `json:"b,omitempty"`
}{
structUint8PtrOmitEmpty: structUint8PtrOmitEmpty{A: nil},
B: uint8ptr(2),
},
},
{
2021-02-15 05:27:37 +03:00
name: "AnonymousHeadUint8PtrNilString",
data: struct {
structUint8PtrString
B *uint8 `json:"b,string"`
}{
structUint8PtrString: structUint8PtrString{A: nil},
B: uint8ptr(2),
},
},
// PtrAnonymousHeadUint8Ptr
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:27:37 +03:00
name: "PtrAnonymousHeadUint8Ptr",
2021-01-16 16:16:26 +03:00
data: struct {
*structUint8Ptr
B *uint8 `json:"b"`
}{
structUint8Ptr: &structUint8Ptr{A: uint8ptr(1)},
B: uint8ptr(2),
},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrAnonymousHeadUint8PtrOmitEmpty",
data: struct {
*structUint8PtrOmitEmpty
B *uint8 `json:"b,omitempty"`
}{
structUint8PtrOmitEmpty: &structUint8PtrOmitEmpty{A: uint8ptr(1)},
B: uint8ptr(2),
},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrAnonymousHeadUint8PtrString",
data: struct {
*structUint8PtrString
B *uint8 `json:"b,string"`
}{
structUint8PtrString: &structUint8PtrString{A: uint8ptr(1)},
B: uint8ptr(2),
},
},
// NilPtrAnonymousHeadUint8Ptr
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:27:37 +03:00
name: "NilPtrAnonymousHeadUint8Ptr",
2021-01-16 16:16:26 +03:00
data: struct {
*structUint8Ptr
B *uint8 `json:"b"`
}{
structUint8Ptr: nil,
B: uint8ptr(2),
},
},
{
2021-02-15 05:27:37 +03:00
name: "NilPtrAnonymousHeadUint8PtrOmitEmpty",
data: struct {
*structUint8PtrOmitEmpty
B *uint8 `json:"b,omitempty"`
}{
structUint8PtrOmitEmpty: nil,
B: uint8ptr(2),
},
},
{
2021-02-15 05:27:37 +03:00
name: "NilPtrAnonymousHeadUint8PtrString",
data: struct {
*structUint8PtrString
B *uint8 `json:"b,string"`
}{
structUint8PtrString: nil,
B: uint8ptr(2),
},
},
// AnonymousHeadUint8Only
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:27:37 +03:00
name: "AnonymousHeadUint8Only",
2021-01-16 16:16:26 +03:00
data: struct {
structUint8
}{
structUint8: structUint8{A: 1},
},
},
{
2021-02-15 05:27:37 +03:00
name: "AnonymousHeadUint8OnlyOmitEmpty",
data: struct {
structUint8OmitEmpty
}{
structUint8OmitEmpty: structUint8OmitEmpty{A: 1},
},
},
{
2021-02-15 05:27:37 +03:00
name: "AnonymousHeadUint8OnlyString",
data: struct {
structUint8String
}{
structUint8String: structUint8String{A: 1},
},
},
// PtrAnonymousHeadUint8Only
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:27:37 +03:00
name: "PtrAnonymousHeadUint8Only",
2021-01-16 16:16:26 +03:00
data: struct {
*structUint8
}{
structUint8: &structUint8{A: 1},
},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrAnonymousHeadUint8OnlyOmitEmpty",
data: struct {
*structUint8OmitEmpty
}{
structUint8OmitEmpty: &structUint8OmitEmpty{A: 1},
},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrAnonymousHeadUint8OnlyString",
data: struct {
*structUint8String
}{
structUint8String: &structUint8String{A: 1},
},
},
// NilPtrAnonymousHeadUint8Only
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:27:37 +03:00
name: "NilPtrAnonymousHeadUint8Only",
2021-01-16 16:16:26 +03:00
data: struct {
*structUint8
}{
structUint8: nil,
},
},
{
2021-02-15 05:27:37 +03:00
name: "NilPtrAnonymousHeadUint8OnlyOmitEmpty",
data: struct {
*structUint8OmitEmpty
}{
structUint8OmitEmpty: nil,
},
},
{
2021-02-15 05:27:37 +03:00
name: "NilPtrAnonymousHeadUint8OnlyString",
data: struct {
*structUint8String
}{
structUint8String: nil,
},
},
// AnonymousHeadUint8PtrOnly
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:27:37 +03:00
name: "AnonymousHeadUint8PtrOnly",
2021-01-16 16:16:26 +03:00
data: struct {
structUint8Ptr
}{
structUint8Ptr: structUint8Ptr{A: uint8ptr(1)},
},
},
{
2021-02-15 05:27:37 +03:00
name: "AnonymousHeadUint8PtrOnlyOmitEmpty",
data: struct {
structUint8PtrOmitEmpty
}{
structUint8PtrOmitEmpty: structUint8PtrOmitEmpty{A: uint8ptr(1)},
},
},
{
2021-02-15 05:27:37 +03:00
name: "AnonymousHeadUint8PtrOnlyString",
data: struct {
structUint8PtrString
}{
structUint8PtrString: structUint8PtrString{A: uint8ptr(1)},
},
},
// AnonymousHeadUint8PtrNilOnly
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:27:37 +03:00
name: "AnonymousHeadUint8PtrNilOnly",
2021-01-16 16:16:26 +03:00
data: struct {
structUint8Ptr
}{
structUint8Ptr: structUint8Ptr{A: nil},
},
},
{
2021-02-15 05:27:37 +03:00
name: "AnonymousHeadUint8PtrNilOnlyOmitEmpty",
data: struct {
structUint8PtrOmitEmpty
}{
structUint8PtrOmitEmpty: structUint8PtrOmitEmpty{A: nil},
},
},
{
2021-02-15 05:27:37 +03:00
name: "AnonymousHeadUint8PtrNilOnlyString",
data: struct {
structUint8PtrString
}{
structUint8PtrString: structUint8PtrString{A: nil},
},
},
// PtrAnonymousHeadUint8PtrOnly
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:27:37 +03:00
name: "PtrAnonymousHeadUint8PtrOnly",
2021-01-16 16:16:26 +03:00
data: struct {
*structUint8Ptr
}{
structUint8Ptr: &structUint8Ptr{A: uint8ptr(1)},
},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrAnonymousHeadUint8PtrOnlyOmitEmpty",
data: struct {
*structUint8PtrOmitEmpty
}{
structUint8PtrOmitEmpty: &structUint8PtrOmitEmpty{A: uint8ptr(1)},
},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrAnonymousHeadUint8PtrOnlyString",
data: struct {
*structUint8PtrString
}{
structUint8PtrString: &structUint8PtrString{A: uint8ptr(1)},
},
},
// NilPtrAnonymousHeadUint8PtrOnly
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:27:37 +03:00
name: "NilPtrAnonymousHeadUint8PtrOnly",
2021-01-16 16:16:26 +03:00
data: struct {
*structUint8Ptr
}{
structUint8Ptr: nil,
},
},
{
2021-02-15 05:27:37 +03:00
name: "NilPtrAnonymousHeadUint8PtrOnlyOmitEmpty",
data: struct {
*structUint8PtrOmitEmpty
}{
structUint8PtrOmitEmpty: nil,
},
},
{
2021-02-15 05:27:37 +03:00
name: "NilPtrAnonymousHeadUint8PtrOnlyString",
data: struct {
*structUint8PtrString
}{
structUint8PtrString: nil,
},
},
2021-01-16 16:16:26 +03:00
}
for _, test := range tests {
for _, indent := range []bool{true, false} {
for _, htmlEscape := range []bool{true, false} {
t.Run(fmt.Sprintf("%s_indent_%t_escape_%t", test.name, indent, htmlEscape), func(t *testing.T) {
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:%T): %+v: %s", test.name, htmlEscape, test.data, err)
}
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
}
}
}
}