go-json/cover_bool_test.go

2673 lines
56 KiB
Go
Raw Normal View History

2021-02-15 05:48:09 +03:00
package json_test
import (
"bytes"
stdjson "encoding/json"
2021-02-15 05:48:09 +03:00
"testing"
"github.com/goccy/go-json"
)
type customBool bool
type customBoolWithMarshaler bool
func (b customBoolWithMarshaler) MarshalJSON() ([]byte, error) {
return stdjson.Marshal(bool(b))
}
2021-02-15 05:48:09 +03:00
func TestCoverBool(t *testing.T) {
type structBool struct {
A bool `json:"a"`
}
type structBoolOmitEmpty struct {
A bool `json:"a,omitempty"`
}
type structBoolString struct {
A bool `json:"a,string"`
}
2021-05-08 17:24:49 +03:00
type structBoolStringOmitEmpty struct {
A bool `json:"a,string,omitempty"`
}
2021-02-15 05:48:09 +03:00
type structBoolPtr struct {
A *bool `json:"a"`
}
type structBoolPtrOmitEmpty struct {
A *bool `json:"a,omitempty"`
}
type structBoolPtrString struct {
A *bool `json:"a,string"`
}
2021-05-08 17:24:49 +03:00
type structBoolPtrStringOmitEmpty struct {
A *bool `json:"a,string,omitempty"`
}
2021-02-15 05:48:09 +03:00
type structCustomBoolOmitEmpty struct {
A customBool `json:"a,omitempty"`
}
2021-04-12 11:41:10 +03:00
type structSecondFieldCustomBoolOmitEmpty struct {
C bool `json:"c"`
A customBool `json:"a,omitempty"`
}
type structCustomBoolWithMarshalerOmitEmpty struct {
A customBoolWithMarshaler `json:"a,omitempty"`
}
2021-04-12 11:41:10 +03:00
type structSecondFieldCustomBoolWithMarshalerOmitEmpty struct {
C bool `json:"c"`
A customBoolWithMarshaler `json:"a,omitempty"`
}
2021-02-15 05:48:09 +03:00
tests := []struct {
name string
data interface{}
}{
2021-03-19 17:31:29 +03:00
{
name: "Bool",
data: bool(true),
},
{
name: "BoolPtr",
data: boolptr(true),
},
{
name: "BoolPtr3",
data: boolptr3(true),
},
{
name: "BoolPtrNil",
data: (*bool)(nil),
},
{
name: "BoolPtr3Nil",
data: (***bool)(nil),
},
2021-02-15 05:48:09 +03:00
// HeadBoolZero
{
name: "HeadBoolZero",
data: struct {
A bool `json:"a"`
}{},
},
{
name: "HeadBoolZeroOmitEmpty",
data: struct {
A bool `json:"a,omitempty"`
}{},
},
{
name: "HeadBoolZeroString",
data: struct {
A bool `json:"a,string"`
}{},
},
2021-05-08 17:24:49 +03:00
{
name: "HeadBoolZeroStringOmitEmpty",
data: struct {
A bool `json:"a,string,omitempty"`
}{},
},
2021-02-15 05:48:09 +03:00
// HeadBool
{
name: "HeadBool",
data: struct {
A bool `json:"a"`
}{A: true},
},
{
name: "HeadBoolOmitEmpty",
data: struct {
A bool `json:"a,omitempty"`
}{A: true},
},
{
name: "HeadBoolString",
data: struct {
A bool `json:"a,string"`
}{A: true},
},
2021-05-08 17:24:49 +03:00
{
name: "HeadBoolStringOmitEmpty",
data: struct {
A bool `json:"a,string,omitempty"`
}{A: true},
},
2021-02-15 05:48:09 +03:00
// HeadBoolPtr
{
name: "HeadBoolPtr",
data: struct {
A *bool `json:"a"`
}{A: boolptr(true)},
},
{
name: "HeadBoolPtrOmitEmpty",
data: struct {
A *bool `json:"a,omitempty"`
}{A: boolptr(true)},
},
{
name: "HeadBoolPtrString",
data: struct {
A *bool `json:"a,string"`
}{A: boolptr(true)},
},
2021-05-08 17:24:49 +03:00
{
name: "HeadBoolPtrStringOmitEmpty",
data: struct {
A *bool `json:"a,string,omitempty"`
}{A: boolptr(true)},
},
2021-02-15 05:48:09 +03:00
// HeadBoolPtrNil
{
name: "HeadBoolPtrNil",
data: struct {
A *bool `json:"a"`
}{A: nil},
},
{
name: "HeadBoolPtrNilOmitEmpty",
data: struct {
A *bool `json:"a,omitempty"`
}{A: nil},
},
{
name: "HeadBoolPtrNilString",
data: struct {
A *bool `json:"a,string"`
}{A: nil},
},
2021-05-08 17:24:49 +03:00
{
name: "HeadBoolPtrNilStringOmitEmpty",
data: struct {
A *bool `json:"a,string,omitempty"`
}{A: nil},
},
2021-02-15 05:48:09 +03:00
// PtrHeadBoolZero
{
name: "PtrHeadBoolZero",
data: &struct {
A bool `json:"a"`
}{},
},
{
name: "PtrHeadBoolZeroOmitEmpty",
data: &struct {
A bool `json:"a,omitempty"`
}{},
},
{
name: "PtrHeadBoolZeroString",
data: &struct {
A bool `json:"a,string"`
}{},
},
2021-05-08 17:24:49 +03:00
{
name: "PtrHeadBoolZeroStringOmitEmpty",
data: &struct {
A bool `json:"a,string,omitempty"`
}{},
},
2021-02-15 05:48:09 +03:00
// PtrHeadBool
{
name: "PtrHeadBool",
data: &struct {
A bool `json:"a"`
}{A: true},
},
{
name: "PtrHeadBoolOmitEmpty",
data: &struct {
A bool `json:"a,omitempty"`
}{A: true},
},
{
name: "PtrHeadBoolString",
data: &struct {
A bool `json:"a,string"`
}{A: true},
},
2021-05-08 17:24:49 +03:00
{
name: "PtrHeadBoolStringOmitEmpty",
data: &struct {
A bool `json:"a,string,omitempty"`
}{A: true},
},
2021-02-15 05:48:09 +03:00
// PtrHeadBoolPtr
{
name: "PtrHeadBoolPtr",
data: &struct {
A *bool `json:"a"`
}{A: boolptr(true)},
},
{
name: "PtrHeadBoolPtrOmitEmpty",
data: &struct {
A *bool `json:"a,omitempty"`
}{A: boolptr(true)},
},
{
name: "PtrHeadBoolPtrString",
data: &struct {
A *bool `json:"a,string"`
}{A: boolptr(true)},
},
2021-05-08 17:24:49 +03:00
{
name: "PtrHeadBoolPtrStringOmitEmpty",
data: &struct {
A *bool `json:"a,string,omitempty"`
}{A: boolptr(true)},
},
2021-02-15 05:48:09 +03:00
// PtrHeadBoolPtrNil
{
name: "PtrHeadBoolPtrNil",
data: &struct {
A *bool `json:"a"`
}{A: nil},
},
{
name: "PtrHeadBoolPtrNilOmitEmpty",
data: &struct {
A *bool `json:"a,omitempty"`
}{A: nil},
},
{
name: "PtrHeadBoolPtrNilString",
data: &struct {
A *bool `json:"a,string"`
}{A: nil},
},
2021-05-08 17:24:49 +03:00
{
name: "PtrHeadBoolPtrNilStringOmitEmpty",
data: &struct {
A *bool `json:"a,string,omitempty"`
}{A: nil},
},
2021-02-15 05:48:09 +03:00
// PtrHeadBoolNil
{
name: "PtrHeadBoolNil",
data: (*struct {
A *bool `json:"a"`
})(nil),
},
{
name: "PtrHeadBoolNilOmitEmpty",
data: (*struct {
A *bool `json:"a,omitempty"`
})(nil),
},
{
name: "PtrHeadBoolNilString",
data: (*struct {
A *bool `json:"a,string"`
})(nil),
},
2021-05-08 17:24:49 +03:00
{
name: "PtrHeadBoolNilStringOmitEmpty",
data: (*struct {
A *bool `json:"a,string,omitempty"`
})(nil),
},
2021-02-15 05:48:09 +03:00
// HeadBoolZeroMultiFields
{
name: "HeadBoolZeroMultiFields",
data: struct {
A bool `json:"a"`
B bool `json:"b"`
C bool `json:"c"`
}{},
},
{
name: "HeadBoolZeroMultiFieldsOmitEmpty",
data: struct {
A bool `json:"a,omitempty"`
B bool `json:"b,omitempty"`
C bool `json:"c,omitempty"`
}{},
},
{
2021-05-08 17:24:49 +03:00
name: "HeadBoolZeroMultiFieldsString",
2021-02-15 05:48:09 +03:00
data: struct {
A bool `json:"a,string"`
B bool `json:"b,string"`
C bool `json:"c,string"`
}{},
},
2021-05-08 17:24:49 +03:00
{
name: "HeadBoolZeroMultiFieldsStringOmitEmpty",
data: struct {
A bool `json:"a,string,omitempty"`
B bool `json:"b,string,omitempty"`
C bool `json:"c,string,omitempty"`
}{},
},
2021-02-15 05:48:09 +03:00
// HeadBoolMultiFields
{
name: "HeadBoolMultiFields",
data: struct {
A bool `json:"a"`
B bool `json:"b"`
C bool `json:"c"`
}{A: true, B: false, C: true},
},
{
name: "HeadBoolMultiFieldsOmitEmpty",
data: struct {
A bool `json:"a,omitempty"`
B bool `json:"b,omitempty"`
C bool `json:"c,omitempty"`
}{A: true, B: false, C: true},
},
{
name: "HeadBoolMultiFieldsString",
data: struct {
A bool `json:"a,string"`
B bool `json:"b,string"`
C bool `json:"c,string"`
}{A: true, B: false, C: true},
},
2021-05-08 17:24:49 +03:00
{
name: "HeadBoolMultiFieldsStringOmitEmpty",
data: struct {
A bool `json:"a,string,omitempty"`
B bool `json:"b,string,omitempty"`
C bool `json:"c,string,omitempty"`
}{A: true, B: false, C: true},
},
2021-02-15 05:48:09 +03:00
// HeadBoolPtrMultiFields
{
name: "HeadBoolPtrMultiFields",
data: struct {
A *bool `json:"a"`
B *bool `json:"b"`
C *bool `json:"c"`
}{A: boolptr(true), B: boolptr(false), C: boolptr(true)},
},
{
name: "HeadBoolPtrMultiFieldsOmitEmpty",
data: struct {
A *bool `json:"a,omitempty"`
B *bool `json:"b,omitempty"`
C *bool `json:"c,omitempty"`
}{A: boolptr(true), B: boolptr(false), C: boolptr(true)},
},
{
name: "HeadBoolPtrMultiFieldsString",
data: struct {
A *bool `json:"a,string"`
B *bool `json:"b,string"`
C *bool `json:"c,string"`
}{A: boolptr(true), B: boolptr(false), C: boolptr(true)},
},
2021-05-08 17:24:49 +03:00
{
name: "HeadBoolPtrMultiFieldsStringOmitEmpty",
data: struct {
A *bool `json:"a,string,omitempty"`
B *bool `json:"b,string,omitempty"`
C *bool `json:"c,string,omitempty"`
}{A: boolptr(true), B: boolptr(false), C: boolptr(true)},
},
2021-02-15 05:48:09 +03:00
// HeadBoolPtrNilMultiFields
{
name: "HeadBoolPtrNilMultiFields",
data: struct {
A *bool `json:"a"`
B *bool `json:"b"`
C *bool `json:"c"`
}{A: nil, B: nil, C: nil},
},
{
name: "HeadBoolPtrNilMultiFieldsOmitEmpty",
data: struct {
A *bool `json:"a,omitempty"`
B *bool `json:"b,omitempty"`
C *bool `json:"c,omitempty"`
}{A: nil, B: nil, C: nil},
},
{
name: "HeadBoolPtrNilMultiFieldsString",
data: struct {
A *bool `json:"a,string"`
B *bool `json:"b,string"`
C *bool `json:"c,string"`
}{A: nil, B: nil, C: nil},
},
2021-05-08 17:24:49 +03:00
{
name: "HeadBoolPtrNilMultiFieldsStringOmitEmpty",
data: struct {
A *bool `json:"a,string,omitempty"`
B *bool `json:"b,string,omitempty"`
C *bool `json:"c,string,omitempty"`
}{A: nil, B: nil, C: nil},
},
2021-02-15 05:48:09 +03:00
// PtrHeadBoolZeroMultiFields
{
name: "PtrHeadBoolZeroMultiFields",
data: &struct {
A bool `json:"a"`
B bool `json:"b"`
}{},
},
{
name: "PtrHeadBoolZeroMultiFieldsOmitEmpty",
data: &struct {
A bool `json:"a,omitempty"`
B bool `json:"b,omitempty"`
}{},
},
{
name: "PtrHeadBoolZeroMultiFieldsString",
data: &struct {
A bool `json:"a,string"`
B bool `json:"b,string"`
}{},
},
2021-05-08 17:24:49 +03:00
{
name: "PtrHeadBoolZeroMultiFieldsStringOmitEmpty",
data: &struct {
A bool `json:"a,string,omitempty"`
B bool `json:"b,string,omitempty"`
}{},
},
2021-02-15 05:48:09 +03:00
// PtrHeadBoolMultiFields
{
name: "PtrHeadBoolMultiFields",
data: &struct {
A bool `json:"a"`
B bool `json:"b"`
}{A: true, B: false},
},
{
name: "PtrHeadBoolMultiFieldsOmitEmpty",
data: &struct {
A bool `json:"a,omitempty"`
B bool `json:"b,omitempty"`
}{A: true, B: false},
},
{
name: "PtrHeadBoolMultiFieldsString",
data: &struct {
A bool `json:"a,string"`
B bool `json:"b,string"`
}{A: true, B: false},
},
2021-05-08 17:24:49 +03:00
{
name: "PtrHeadBoolMultiFieldsStringOmitEmpty",
data: &struct {
A bool `json:"a,string,omitempty"`
B bool `json:"b,string,omitempty"`
}{A: true, B: false},
},
2021-02-15 05:48:09 +03:00
// PtrHeadBoolPtrMultiFields
{
name: "PtrHeadBoolPtrMultiFields",
data: &struct {
A *bool `json:"a"`
B *bool `json:"b"`
}{A: boolptr(true), B: boolptr(false)},
},
{
name: "PtrHeadBoolPtrMultiFieldsOmitEmpty",
data: &struct {
A *bool `json:"a,omitempty"`
B *bool `json:"b,omitempty"`
}{A: boolptr(true), B: boolptr(false)},
},
{
name: "PtrHeadBoolPtrMultiFieldsString",
data: &struct {
A *bool `json:"a,string"`
B *bool `json:"b,string"`
}{A: boolptr(true), B: boolptr(false)},
},
2021-05-08 17:24:49 +03:00
{
name: "PtrHeadBoolPtrMultiFieldsStringOmitEmpty",
data: &struct {
A *bool `json:"a,string,omitempty"`
B *bool `json:"b,string,omitempty"`
}{A: boolptr(true), B: boolptr(false)},
},
2021-02-15 05:48:09 +03:00
// PtrHeadBoolPtrNilMultiFields
{
name: "PtrHeadBoolPtrNilMultiFields",
data: &struct {
A *bool `json:"a"`
B *bool `json:"b"`
}{A: nil, B: nil},
},
{
name: "PtrHeadBoolPtrNilMultiFieldsOmitEmpty",
data: &struct {
A *bool `json:"a,omitempty"`
B *bool `json:"b,omitempty"`
}{A: nil, B: nil},
},
{
name: "PtrHeadBoolPtrNilMultiFieldsString",
data: &struct {
A *bool `json:"a,string"`
B *bool `json:"b,string"`
}{A: nil, B: nil},
},
2021-05-08 17:24:49 +03:00
{
name: "PtrHeadBoolPtrNilMultiFieldsStringOmitEmpty",
data: &struct {
A *bool `json:"a,string,omitempty"`
B *bool `json:"b,string,omitempty"`
}{A: nil, B: nil},
},
2021-02-15 05:48:09 +03:00
// PtrHeadBoolNilMultiFields
{
name: "PtrHeadBoolNilMultiFields",
data: (*struct {
A *bool `json:"a"`
B *bool `json:"b"`
})(nil),
},
{
name: "PtrHeadBoolNilMultiFieldsOmitEmpty",
data: (*struct {
A *bool `json:"a,omitempty"`
B *bool `json:"b,omitempty"`
})(nil),
},
{
name: "PtrHeadBoolNilMultiFieldsString",
data: (*struct {
A *bool `json:"a,string"`
B *bool `json:"b,string"`
})(nil),
},
2021-05-08 17:24:49 +03:00
{
name: "PtrHeadBoolNilMultiFieldsStringOmitEmpty",
data: (*struct {
A *bool `json:"a,string,omitempty"`
B *bool `json:"b,string,omitempty"`
})(nil),
},
2021-02-15 05:48:09 +03:00
// HeadBoolZeroNotRoot
{
name: "HeadBoolZeroNotRoot",
data: struct {
A struct {
A bool `json:"a"`
}
}{},
},
{
name: "HeadBoolZeroNotRootOmitEmpty",
data: struct {
A struct {
A bool `json:"a,omitempty"`
}
}{},
},
{
name: "HeadBoolZeroNotRootString",
data: struct {
A struct {
A bool `json:"a,string"`
}
}{},
},
2021-05-08 17:24:49 +03:00
{
name: "HeadBoolZeroNotRootStringOmitEmpty",
data: struct {
A struct {
A bool `json:"a,string,omitempty"`
}
}{},
},
2021-02-15 05:48:09 +03:00
// HeadBoolNotRoot
{
name: "HeadBoolNotRoot",
data: struct {
A struct {
A bool `json:"a"`
}
}{A: struct {
A bool `json:"a"`
}{A: true}},
},
{
name: "HeadBoolNotRootOmitEmpty",
data: struct {
A struct {
A bool `json:"a,omitempty"`
}
}{A: struct {
A bool `json:"a,omitempty"`
}{A: true}},
},
{
name: "HeadBoolNotRootString",
data: struct {
A struct {
A bool `json:"a,string"`
}
}{A: struct {
A bool `json:"a,string"`
}{A: true}},
},
2021-05-08 17:24:49 +03:00
{
name: "HeadBoolNotRootStringOmitEmpty",
data: struct {
A struct {
A bool `json:"a,string,omitempty"`
}
}{A: struct {
A bool `json:"a,string,omitempty"`
}{A: true}},
},
2021-02-15 05:48:09 +03:00
// HeadBoolPtrNotRoot
{
name: "HeadBoolPtrNotRoot",
data: struct {
A struct {
A *bool `json:"a"`
}
}{A: struct {
A *bool `json:"a"`
}{boolptr(true)}},
},
{
name: "HeadBoolPtrNotRootOmitEmpty",
data: struct {
A struct {
A *bool `json:"a,omitempty"`
}
}{A: struct {
A *bool `json:"a,omitempty"`
}{boolptr(true)}},
},
{
name: "HeadBoolPtrNotRootString",
data: struct {
A struct {
A *bool `json:"a,string"`
}
}{A: struct {
A *bool `json:"a,string"`
}{boolptr(true)}},
},
2021-05-08 17:24:49 +03:00
{
name: "HeadBoolPtrNotRootStringOmitEmpty",
data: struct {
A struct {
A *bool `json:"a,string,omitempty"`
}
}{A: struct {
A *bool `json:"a,string,omitempty"`
}{boolptr(true)}},
},
2021-02-15 05:48:09 +03:00
// HeadBoolPtrNilNotRoot
{
name: "HeadBoolPtrNilNotRoot",
data: struct {
A struct {
A *bool `json:"a"`
}
}{},
},
{
name: "HeadBoolPtrNilNotRootOmitEmpty",
data: struct {
A struct {
A *bool `json:"a,omitempty"`
}
}{},
},
{
name: "HeadBoolPtrNilNotRootString",
data: struct {
A struct {
A *bool `json:"a,string"`
}
}{},
},
2021-05-08 17:24:49 +03:00
{
name: "HeadBoolPtrNilNotRootStringOmitEmpty",
data: struct {
A struct {
A *bool `json:"a,string,omitempty"`
}
}{},
},
2021-02-15 05:48:09 +03:00
// PtrHeadBoolZeroNotRoot
{
name: "PtrHeadBoolZeroNotRoot",
data: struct {
A *struct {
A bool `json:"a"`
}
}{A: new(struct {
A bool `json:"a"`
})},
},
{
name: "PtrHeadBoolZeroNotRootOmitEmpty",
data: struct {
A *struct {
A bool `json:"a,omitempty"`
}
}{A: new(struct {
A bool `json:"a,omitempty"`
})},
},
{
name: "PtrHeadBoolZeroNotRootString",
data: struct {
A *struct {
A bool `json:"a,string"`
}
}{A: new(struct {
A bool `json:"a,string"`
})},
},
2021-05-08 17:24:49 +03:00
{
name: "PtrHeadBoolZeroNotRootStringOmitEmpty",
data: struct {
A *struct {
A bool `json:"a,string,omitempty"`
}
}{A: new(struct {
A bool `json:"a,string,omitempty"`
})},
},
2021-02-15 05:48:09 +03:00
// PtrHeadBoolNotRoot
{
name: "PtrHeadBoolNotRoot",
data: struct {
A *struct {
A bool `json:"a"`
}
}{A: &(struct {
A bool `json:"a"`
}{A: true})},
},
{
name: "PtrHeadBoolNotRootOmitEmpty",
data: struct {
A *struct {
A bool `json:"a,omitempty"`
}
}{A: &(struct {
A bool `json:"a,omitempty"`
}{A: true})},
},
{
name: "PtrHeadBoolNotRootString",
data: struct {
A *struct {
A bool `json:"a,string"`
}
}{A: &(struct {
A bool `json:"a,string"`
}{A: true})},
},
2021-05-08 17:24:49 +03:00
{
name: "PtrHeadBoolNotRootStringOmitEmpty",
data: struct {
A *struct {
A bool `json:"a,string,omitempty"`
}
}{A: &(struct {
A bool `json:"a,string,omitempty"`
}{A: true})},
},
2021-02-15 05:48:09 +03:00
// PtrHeadBoolPtrNotRoot
{
name: "PtrHeadBoolPtrNotRoot",
data: struct {
A *struct {
A *bool `json:"a"`
}
}{A: &(struct {
A *bool `json:"a"`
}{A: boolptr(true)})},
},
{
name: "PtrHeadBoolPtrNotRootOmitEmpty",
data: struct {
A *struct {
A *bool `json:"a,omitempty"`
}
}{A: &(struct {
A *bool `json:"a,omitempty"`
}{A: boolptr(true)})},
},
{
name: "PtrHeadBoolPtrNotRootString",
data: struct {
A *struct {
A *bool `json:"a,string"`
}
}{A: &(struct {
A *bool `json:"a,string"`
}{A: boolptr(true)})},
},
2021-05-08 17:24:49 +03:00
{
name: "PtrHeadBoolPtrNotRootStringOmitEmpty",
data: struct {
A *struct {
A *bool `json:"a,string,omitempty"`
}
}{A: &(struct {
A *bool `json:"a,string,omitempty"`
}{A: boolptr(true)})},
},
2021-02-15 05:48:09 +03:00
// PtrHeadBoolPtrNilNotRoot
{
name: "PtrHeadBoolPtrNilNotRoot",
data: struct {
A *struct {
A *bool `json:"a"`
}
}{A: &(struct {
A *bool `json:"a"`
}{A: nil})},
},
{
name: "PtrHeadBoolPtrNilNotRootOmitEmpty",
data: struct {
A *struct {
A *bool `json:"a,omitempty"`
}
}{A: &(struct {
A *bool `json:"a,omitempty"`
}{A: nil})},
},
{
name: "PtrHeadBoolPtrNilNotRootString",
data: struct {
A *struct {
A *bool `json:"a,string"`
}
}{A: &(struct {
A *bool `json:"a,string"`
}{A: nil})},
},
2021-05-08 17:24:49 +03:00
{
name: "PtrHeadBoolPtrNilNotRootStringOmitEmpty",
data: struct {
A *struct {
A *bool `json:"a,string,omitempty"`
}
}{A: &(struct {
A *bool `json:"a,string,omitempty"`
}{A: nil})},
},
2021-02-15 05:48:09 +03:00
// PtrHeadBoolNilNotRoot
{
name: "PtrHeadBoolNilNotRoot",
data: struct {
A *struct {
A *bool `json:"a"`
}
}{A: nil},
},
{
name: "PtrHeadBoolNilNotRootOmitEmpty",
data: struct {
A *struct {
A *bool `json:"a,omitempty"`
} `json:",omitempty"`
}{A: nil},
},
{
name: "PtrHeadBoolNilNotRootString",
data: struct {
A *struct {
A *bool `json:"a,string"`
} `json:",string"`
}{A: nil},
},
2021-05-08 17:24:49 +03:00
{
name: "PtrHeadBoolNilNotRootStringOmitEmpty",
data: struct {
A *struct {
A *bool `json:"a,string,omitempty"`
} `json:",string,omitempty"`
}{A: nil},
},
2021-02-15 05:48:09 +03:00
// HeadBoolZeroMultiFieldsNotRoot
{
name: "HeadBoolZeroMultiFieldsNotRoot",
data: struct {
A struct {
A bool `json:"a"`
}
B struct {
B bool `json:"b"`
}
}{},
},
{
name: "HeadBoolZeroMultiFieldsNotRootOmitEmpty",
data: struct {
A struct {
A bool `json:"a,omitempty"`
}
B struct {
B bool `json:"b,omitempty"`
}
}{},
},
{
name: "HeadBoolZeroMultiFieldsNotRootString",
data: struct {
A struct {
A bool `json:"a,string"`
}
B struct {
B bool `json:"b,string"`
}
}{},
},
2021-05-08 17:24:49 +03:00
{
name: "HeadBoolZeroMultiFieldsNotRootStringOmitEmpty",
data: struct {
A struct {
A bool `json:"a,string,omitempty"`
}
B struct {
B bool `json:"b,string,omitempty"`
}
}{},
},
2021-02-15 05:48:09 +03:00
// HeadBoolMultiFieldsNotRoot
{
name: "HeadBoolMultiFieldsNotRoot",
data: struct {
A struct {
A bool `json:"a"`
}
B struct {
B bool `json:"b"`
}
}{A: struct {
A bool `json:"a"`
}{A: true}, B: struct {
B bool `json:"b"`
}{B: false}},
},
{
name: "HeadBoolMultiFieldsNotRootOmitEmpty",
data: struct {
A struct {
A bool `json:"a,omitempty"`
}
B struct {
B bool `json:"b,omitempty"`
}
}{A: struct {
A bool `json:"a,omitempty"`
}{A: true}, B: struct {
B bool `json:"b,omitempty"`
}{B: false}},
},
{
name: "HeadBoolMultiFieldsNotRootString",
data: struct {
A struct {
A bool `json:"a,string"`
}
B struct {
B bool `json:"b,string"`
}
}{A: struct {
A bool `json:"a,string"`
}{A: true}, B: struct {
B bool `json:"b,string"`
}{B: false}},
},
2021-05-08 17:24:49 +03:00
{
name: "HeadBoolMultiFieldsNotRootStringOmitEmpty",
data: struct {
A struct {
A bool `json:"a,string,omitempty"`
}
B struct {
B bool `json:"b,string,omitempty"`
}
}{A: struct {
A bool `json:"a,string,omitempty"`
}{A: true}, B: struct {
B bool `json:"b,string,omitempty"`
}{B: false}},
},
2021-02-15 05:48:09 +03:00
// HeadBoolPtrMultiFieldsNotRoot
{
name: "HeadBoolPtrMultiFieldsNotRoot",
data: struct {
A struct {
A *bool `json:"a"`
}
B struct {
B *bool `json:"b"`
}
}{A: struct {
A *bool `json:"a"`
}{A: boolptr(true)}, B: struct {
B *bool `json:"b"`
}{B: boolptr(false)}},
},
{
name: "HeadBoolPtrMultiFieldsNotRootOmitEmpty",
data: struct {
A struct {
A *bool `json:"a,omitempty"`
}
B struct {
B *bool `json:"b,omitempty"`
}
}{A: struct {
A *bool `json:"a,omitempty"`
}{A: boolptr(true)}, B: struct {
B *bool `json:"b,omitempty"`
}{B: boolptr(false)}},
},
{
name: "HeadBoolPtrMultiFieldsNotRootString",
data: struct {
A struct {
A *bool `json:"a,string"`
}
B struct {
B *bool `json:"b,string"`
}
}{A: struct {
A *bool `json:"a,string"`
}{A: boolptr(true)}, B: struct {
B *bool `json:"b,string"`
}{B: boolptr(false)}},
},
2021-05-08 17:24:49 +03:00
{
name: "HeadBoolPtrMultiFieldsNotRootStringOmitEmpty",
data: struct {
A struct {
A *bool `json:"a,string,omitempty"`
}
B struct {
B *bool `json:"b,string,omitempty"`
}
}{A: struct {
A *bool `json:"a,string,omitempty"`
}{A: boolptr(true)}, B: struct {
B *bool `json:"b,string,omitempty"`
}{B: boolptr(false)}},
},
2021-02-15 05:48:09 +03:00
// HeadBoolPtrNilMultiFieldsNotRoot
{
name: "HeadBoolPtrNilMultiFieldsNotRoot",
data: struct {
A struct {
A *bool `json:"a"`
}
B struct {
B *bool `json:"b"`
}
}{A: struct {
A *bool `json:"a"`
}{A: nil}, B: struct {
B *bool `json:"b"`
}{B: nil}},
},
{
name: "HeadBoolPtrNilMultiFieldsNotRootOmitEmpty",
data: struct {
A struct {
A *bool `json:"a,omitempty"`
}
B struct {
B *bool `json:"b,omitempty"`
}
}{A: struct {
A *bool `json:"a,omitempty"`
}{A: nil}, B: struct {
B *bool `json:"b,omitempty"`
}{B: nil}},
},
{
name: "HeadBoolPtrNilMultiFieldsNotRootString",
data: struct {
A struct {
A *bool `json:"a,string"`
}
B struct {
B *bool `json:"b,string"`
}
}{A: struct {
A *bool `json:"a,string"`
}{A: nil}, B: struct {
B *bool `json:"b,string"`
}{B: nil}},
},
2021-05-08 17:24:49 +03:00
{
name: "HeadBoolPtrNilMultiFieldsNotRootStringOmitEmpty",
data: struct {
A struct {
A *bool `json:"a,string,omitempty"`
}
B struct {
B *bool `json:"b,string,omitempty"`
}
}{A: struct {
A *bool `json:"a,string,omitempty"`
}{A: nil}, B: struct {
B *bool `json:"b,string,omitempty"`
}{B: nil}},
},
2021-02-15 05:48:09 +03:00
// PtrHeadBoolZeroMultiFieldsNotRoot
{
name: "PtrHeadBoolZeroMultiFieldsNotRoot",
data: &struct {
A struct {
A bool `json:"a"`
}
B struct {
B bool `json:"b"`
}
}{},
},
{
name: "PtrHeadBoolZeroMultiFieldsNotRootOmitEmpty",
data: &struct {
A struct {
A bool `json:"a,omitempty"`
}
B struct {
B bool `json:"b,omitempty"`
}
}{},
},
{
name: "PtrHeadBoolZeroMultiFieldsNotRootString",
data: &struct {
A struct {
A bool `json:"a,string"`
}
B struct {
B bool `json:"b,string"`
}
}{},
},
2021-05-08 17:24:49 +03:00
{
name: "PtrHeadBoolZeroMultiFieldsNotRootStringOmitEmpty",
data: &struct {
A struct {
A bool `json:"a,string,omitempty"`
}
B struct {
B bool `json:"b,string,omitempty"`
}
}{},
},
2021-02-15 05:48:09 +03:00
// PtrHeadBoolMultiFieldsNotRoot
{
name: "PtrHeadBoolMultiFieldsNotRoot",
data: &struct {
A struct {
A bool `json:"a"`
}
B struct {
B bool `json:"b"`
}
}{A: struct {
A bool `json:"a"`
}{A: true}, B: struct {
B bool `json:"b"`
}{B: false}},
},
{
name: "PtrHeadBoolMultiFieldsNotRootOmitEmpty",
data: &struct {
A struct {
A bool `json:"a,omitempty"`
}
B struct {
B bool `json:"b,omitempty"`
}
}{A: struct {
A bool `json:"a,omitempty"`
}{A: true}, B: struct {
B bool `json:"b,omitempty"`
}{B: false}},
},
{
name: "PtrHeadBoolMultiFieldsNotRootString",
data: &struct {
A struct {
A bool `json:"a,string"`
}
B struct {
B bool `json:"b,string"`
}
}{A: struct {
A bool `json:"a,string"`
}{A: true}, B: struct {
B bool `json:"b,string"`
}{B: false}},
},
2021-05-08 17:24:49 +03:00
{
name: "PtrHeadBoolMultiFieldsNotRootStringOmitEmpty",
data: &struct {
A struct {
A bool `json:"a,string,omitempty"`
}
B struct {
B bool `json:"b,string,omitempty"`
}
}{A: struct {
A bool `json:"a,string,omitempty"`
}{A: true}, B: struct {
B bool `json:"b,string,omitempty"`
}{B: false}},
},
2021-02-15 05:48:09 +03:00
// PtrHeadBoolPtrMultiFieldsNotRoot
{
name: "PtrHeadBoolPtrMultiFieldsNotRoot",
data: &struct {
A *struct {
A *bool `json:"a"`
}
B *struct {
B *bool `json:"b"`
}
}{A: &(struct {
A *bool `json:"a"`
}{A: boolptr(true)}), B: &(struct {
B *bool `json:"b"`
}{B: boolptr(false)})},
},
{
name: "PtrHeadBoolPtrMultiFieldsNotRootOmitEmpty",
data: &struct {
A *struct {
A *bool `json:"a,omitempty"`
}
B *struct {
B *bool `json:"b,omitempty"`
}
}{A: &(struct {
A *bool `json:"a,omitempty"`
}{A: boolptr(true)}), B: &(struct {
B *bool `json:"b,omitempty"`
}{B: boolptr(false)})},
},
{
name: "PtrHeadBoolPtrMultiFieldsNotRootString",
data: &struct {
A *struct {
A *bool `json:"a,string"`
}
B *struct {
B *bool `json:"b,string"`
}
}{A: &(struct {
A *bool `json:"a,string"`
}{A: boolptr(true)}), B: &(struct {
B *bool `json:"b,string"`
}{B: boolptr(false)})},
},
2021-05-08 17:24:49 +03:00
{
name: "PtrHeadBoolPtrMultiFieldsNotRootStringOmitEmpty",
data: &struct {
A *struct {
A *bool `json:"a,string,omitempty"`
}
B *struct {
B *bool `json:"b,string,omitempty"`
}
}{A: &(struct {
A *bool `json:"a,string,omitempty"`
}{A: boolptr(true)}), B: &(struct {
B *bool `json:"b,string,omitempty"`
}{B: boolptr(false)})},
},
2021-02-15 05:48:09 +03:00
// PtrHeadBoolPtrNilMultiFieldsNotRoot
{
name: "PtrHeadBoolPtrNilMultiFieldsNotRoot",
data: &struct {
A *struct {
A *bool `json:"a"`
}
B *struct {
B *bool `json:"b"`
}
}{A: nil, B: nil},
},
{
name: "PtrHeadBoolPtrNilMultiFieldsNotRootOmitEmpty",
data: &struct {
A *struct {
A *bool `json:"a,omitempty"`
} `json:",omitempty"`
B *struct {
B *bool `json:"b,omitempty"`
} `json:",omitempty"`
}{A: nil, B: nil},
},
{
name: "PtrHeadBoolPtrNilMultiFieldsNotRootString",
data: &struct {
A *struct {
A *bool `json:"a,string"`
} `json:",string"`
B *struct {
B *bool `json:"b,string"`
} `json:",string"`
}{A: nil, B: nil},
},
2021-05-08 17:24:49 +03:00
{
name: "PtrHeadBoolPtrNilMultiFieldsNotRootStringOmitEmpty",
data: &struct {
A *struct {
A *bool `json:"a,string,omitempty"`
} `json:",string"`
B *struct {
B *bool `json:"b,string,omitempty"`
} `json:",string"`
}{A: nil, B: nil},
},
2021-02-15 05:48:09 +03:00
// PtrHeadBoolNilMultiFieldsNotRoot
{
name: "PtrHeadBoolNilMultiFieldsNotRoot",
data: (*struct {
A *struct {
A *bool `json:"a"`
}
B *struct {
B *bool `json:"b"`
}
})(nil),
},
{
name: "PtrHeadBoolNilMultiFieldsNotRootOmitEmpty",
data: (*struct {
A *struct {
A *bool `json:"a,omitempty"`
}
B *struct {
B *bool `json:"b,omitempty"`
}
})(nil),
},
{
name: "PtrHeadBoolNilMultiFieldsNotRootString",
data: (*struct {
A *struct {
A *bool `json:"a,string"`
}
B *struct {
B *bool `json:"b,string"`
}
})(nil),
},
2021-05-08 17:24:49 +03:00
{
name: "PtrHeadBoolNilMultiFieldsNotRootStringOmitEmpty",
data: (*struct {
A *struct {
A *bool `json:"a,string,omitempty"`
}
B *struct {
B *bool `json:"b,string,omitempty"`
}
})(nil),
},
2021-02-15 05:48:09 +03:00
// PtrHeadBoolDoubleMultiFieldsNotRoot
{
name: "PtrHeadBoolDoubleMultiFieldsNotRoot",
data: &struct {
A *struct {
A bool `json:"a"`
B bool `json:"b"`
}
B *struct {
A bool `json:"a"`
B bool `json:"b"`
}
}{A: &(struct {
A bool `json:"a"`
B bool `json:"b"`
}{A: true, B: false}), B: &(struct {
A bool `json:"a"`
B bool `json:"b"`
}{A: true, B: false})},
},
{
name: "PtrHeadBoolDoubleMultiFieldsNotRootOmitEmpty",
data: &struct {
A *struct {
A bool `json:"a,omitempty"`
B bool `json:"b,omitempty"`
}
B *struct {
A bool `json:"a,omitempty"`
B bool `json:"b,omitempty"`
}
}{A: &(struct {
A bool `json:"a,omitempty"`
B bool `json:"b,omitempty"`
}{A: true, B: false}), B: &(struct {
A bool `json:"a,omitempty"`
B bool `json:"b,omitempty"`
}{A: true, B: false})},
},
{
name: "PtrHeadBoolDoubleMultiFieldsNotRootString",
data: &struct {
A *struct {
A bool `json:"a,string"`
B bool `json:"b,string"`
}
B *struct {
A bool `json:"a,string"`
B bool `json:"b,string"`
}
}{A: &(struct {
A bool `json:"a,string"`
B bool `json:"b,string"`
}{A: true, B: false}), B: &(struct {
A bool `json:"a,string"`
B bool `json:"b,string"`
}{A: true, B: false})},
},
2021-05-08 17:24:49 +03:00
{
name: "PtrHeadBoolDoubleMultiFieldsNotRootStringOmitEmpty",
data: &struct {
A *struct {
A bool `json:"a,string,omitempty"`
B bool `json:"b,string,omitempty"`
}
B *struct {
A bool `json:"a,string,omitempty"`
B bool `json:"b,string,omitempty"`
}
}{A: &(struct {
A bool `json:"a,string,omitempty"`
B bool `json:"b,string,omitempty"`
}{A: true, B: false}), B: &(struct {
A bool `json:"a,string,omitempty"`
B bool `json:"b,string,omitempty"`
}{A: true, B: false})},
},
2021-02-15 05:48:09 +03:00
// PtrHeadBoolNilDoubleMultiFieldsNotRoot
{
name: "PtrHeadBoolNilDoubleMultiFieldsNotRoot",
data: &struct {
A *struct {
A bool `json:"a"`
B bool `json:"b"`
}
B *struct {
A bool `json:"a"`
B bool `json:"b"`
}
}{A: nil, B: nil},
},
{
name: "PtrHeadBoolNilDoubleMultiFieldsNotRootOmitEmpty",
data: &struct {
A *struct {
A bool `json:"a,omitempty"`
B bool `json:"b,omitempty"`
} `json:",omitempty"`
B *struct {
A bool `json:"a,omitempty"`
B bool `json:"b,omitempty"`
} `json:",omitempty"`
}{A: nil, B: nil},
},
{
name: "PtrHeadBoolNilDoubleMultiFieldsNotRootString",
data: &struct {
A *struct {
A bool `json:"a,string"`
B bool `json:"b,string"`
}
B *struct {
A bool `json:"a,string"`
B bool `json:"b,string"`
}
}{A: nil, B: nil},
},
2021-05-08 17:24:49 +03:00
{
name: "PtrHeadBoolNilDoubleMultiFieldsNotRootStringOmitEmpty",
data: &struct {
A *struct {
A bool `json:"a,string,omitempty"`
B bool `json:"b,string,omitempty"`
}
B *struct {
A bool `json:"a,string,omitempty"`
B bool `json:"b,string,omitempty"`
}
}{A: nil, B: nil},
},
2021-02-15 05:48:09 +03:00
// PtrHeadBoolNilDoubleMultiFieldsNotRoot
{
name: "PtrHeadBoolNilDoubleMultiFieldsNotRoot",
data: (*struct {
A *struct {
A bool `json:"a"`
B bool `json:"b"`
}
B *struct {
A bool `json:"a"`
B bool `json:"b"`
}
})(nil),
},
{
name: "PtrHeadBoolNilDoubleMultiFieldsNotRootOmitEmpty",
data: (*struct {
A *struct {
A bool `json:"a,omitempty"`
B bool `json:"b,omitempty"`
}
B *struct {
A bool `json:"a,omitempty"`
B bool `json:"b,omitempty"`
}
})(nil),
},
{
name: "PtrHeadBoolNilDoubleMultiFieldsNotRootString",
data: (*struct {
A *struct {
A bool `json:"a,string"`
B bool `json:"b,string"`
}
B *struct {
A bool `json:"a,string"`
B bool `json:"b,string"`
}
})(nil),
},
2021-05-08 17:24:49 +03:00
{
name: "PtrHeadBoolNilDoubleMultiFieldsNotRootStringOmitEmpty",
data: (*struct {
A *struct {
A bool `json:"a,string,omitempty"`
B bool `json:"b,string,omitempty"`
}
B *struct {
A bool `json:"a,string,omitempty"`
B bool `json:"b,string,omitempty"`
}
})(nil),
},
2021-02-15 05:48:09 +03:00
// PtrHeadBoolPtrDoubleMultiFieldsNotRoot
{
name: "PtrHeadBoolPtrDoubleMultiFieldsNotRoot",
data: &struct {
A *struct {
A *bool `json:"a"`
B *bool `json:"b"`
}
B *struct {
A *bool `json:"a"`
B *bool `json:"b"`
}
}{A: &(struct {
A *bool `json:"a"`
B *bool `json:"b"`
}{A: boolptr(true), B: boolptr(false)}), B: &(struct {
A *bool `json:"a"`
B *bool `json:"b"`
}{A: boolptr(true), B: boolptr(false)})},
},
{
name: "PtrHeadBoolPtrDoubleMultiFieldsNotRootOmitEmpty",
data: &struct {
A *struct {
A *bool `json:"a,omitempty"`
B *bool `json:"b,omitempty"`
}
B *struct {
A *bool `json:"a,omitempty"`
B *bool `json:"b,omitempty"`
}
}{A: &(struct {
A *bool `json:"a,omitempty"`
B *bool `json:"b,omitempty"`
}{A: boolptr(true), B: boolptr(false)}), B: &(struct {
A *bool `json:"a,omitempty"`
B *bool `json:"b,omitempty"`
}{A: boolptr(true), B: boolptr(false)})},
},
{
name: "PtrHeadBoolPtrDoubleMultiFieldsNotRootString",
data: &struct {
A *struct {
A *bool `json:"a,string"`
B *bool `json:"b,string"`
}
B *struct {
A *bool `json:"a,string"`
B *bool `json:"b,string"`
}
}{A: &(struct {
A *bool `json:"a,string"`
B *bool `json:"b,string"`
}{A: boolptr(true), B: boolptr(false)}), B: &(struct {
A *bool `json:"a,string"`
B *bool `json:"b,string"`
}{A: boolptr(true), B: boolptr(false)})},
},
2021-05-08 17:24:49 +03:00
{
name: "PtrHeadBoolPtrDoubleMultiFieldsNotRootStringOmitEmpty",
data: &struct {
A *struct {
A *bool `json:"a,string,omitempty"`
B *bool `json:"b,string,omitempty"`
}
B *struct {
A *bool `json:"a,string,omitempty"`
B *bool `json:"b,string,omitempty"`
}
}{A: &(struct {
A *bool `json:"a,string,omitempty"`
B *bool `json:"b,string,omitempty"`
}{A: boolptr(true), B: boolptr(false)}), B: &(struct {
A *bool `json:"a,string,omitempty"`
B *bool `json:"b,string,omitempty"`
}{A: boolptr(true), B: boolptr(false)})},
},
2021-02-15 05:48:09 +03:00
// PtrHeadBoolPtrNilDoubleMultiFieldsNotRoot
{
name: "PtrHeadBoolPtrNilDoubleMultiFieldsNotRoot",
data: &struct {
A *struct {
A *bool `json:"a"`
B *bool `json:"b"`
}
B *struct {
A *bool `json:"a"`
B *bool `json:"b"`
}
}{A: nil, B: nil},
},
{
name: "PtrHeadBoolPtrNilDoubleMultiFieldsNotRootOmitEmpty",
data: &struct {
A *struct {
A *bool `json:"a,omitempty"`
B *bool `json:"b,omitempty"`
} `json:",omitempty"`
B *struct {
A *bool `json:"a,omitempty"`
B *bool `json:"b,omitempty"`
} `json:",omitempty"`
}{A: nil, B: nil},
},
{
name: "PtrHeadBoolPtrNilDoubleMultiFieldsNotRootString",
data: &struct {
A *struct {
A *bool `json:"a,string"`
B *bool `json:"b,string"`
}
B *struct {
A *bool `json:"a,string"`
B *bool `json:"b,string"`
}
}{A: nil, B: nil},
},
2021-05-08 17:24:49 +03:00
{
name: "PtrHeadBoolPtrNilDoubleMultiFieldsNotRootStringOmitEmpty",
data: &struct {
A *struct {
A *bool `json:"a,string,omitempty"`
B *bool `json:"b,string,omitempty"`
}
B *struct {
A *bool `json:"a,string,omitempty"`
B *bool `json:"b,string,omitempty"`
}
}{A: nil, B: nil},
},
2021-02-15 05:48:09 +03:00
// PtrHeadBoolPtrNilDoubleMultiFieldsNotRoot
{
name: "PtrHeadBoolPtrNilDoubleMultiFieldsNotRoot",
data: (*struct {
A *struct {
A *bool `json:"a"`
B *bool `json:"b"`
}
B *struct {
A *bool `json:"a"`
B *bool `json:"b"`
}
})(nil),
},
{
name: "PtrHeadBoolPtrNilDoubleMultiFieldsNotRootOmitEmpty",
data: (*struct {
A *struct {
A *bool `json:"a,omitempty"`
B *bool `json:"b,omitempty"`
}
B *struct {
A *bool `json:"a,omitempty"`
B *bool `json:"b,omitempty"`
}
})(nil),
},
{
name: "PtrHeadBoolPtrNilDoubleMultiFieldsNotRootString",
data: (*struct {
A *struct {
A *bool `json:"a,string"`
B *bool `json:"b,string"`
}
B *struct {
A *bool `json:"a,string"`
B *bool `json:"b,string"`
}
})(nil),
},
2021-05-08 17:24:49 +03:00
{
name: "PtrHeadBoolPtrNilDoubleMultiFieldsNotRootStringOmitEmpty",
data: (*struct {
A *struct {
A *bool `json:"a,string,omitempty"`
B *bool `json:"b,string,omitempty"`
}
B *struct {
A *bool `json:"a,string,omitempty"`
B *bool `json:"b,string,omitempty"`
}
})(nil),
},
2021-02-15 05:48:09 +03:00
// AnonymousHeadBool
{
name: "AnonymousHeadBool",
data: struct {
structBool
B bool `json:"b"`
}{
structBool: structBool{A: true},
B: false,
},
},
{
name: "AnonymousHeadBoolOmitEmpty",
data: struct {
structBoolOmitEmpty
B bool `json:"b,omitempty"`
}{
structBoolOmitEmpty: structBoolOmitEmpty{A: true},
B: false,
},
},
{
name: "AnonymousHeadCustomBoolOmitEmpty",
data: struct {
structCustomBoolOmitEmpty
B bool `json:"b,omitempty"`
}{
structCustomBoolOmitEmpty: structCustomBoolOmitEmpty{A: true},
B: false,
},
},
{
name: "AnonymousHeadCustomBoolOmitEmptyFalse",
data: struct {
structCustomBoolOmitEmpty
B bool `json:"b,omitempty"`
}{
structCustomBoolOmitEmpty: structCustomBoolOmitEmpty{},
B: false,
},
},
2021-04-12 11:41:10 +03:00
{
name: "AnonymousHeadSecondFieldCustomBoolOmitEmpty",
data: struct {
structSecondFieldCustomBoolOmitEmpty
B bool `json:"b,omitempty"`
}{
structSecondFieldCustomBoolOmitEmpty: structSecondFieldCustomBoolOmitEmpty{A: true},
B: false,
},
},
{
name: "AnonymousHeadSecondFieldCustomBoolOmitEmptyFalse",
data: struct {
structSecondFieldCustomBoolOmitEmpty
B bool `json:"b,omitempty"`
}{
structSecondFieldCustomBoolOmitEmpty: structSecondFieldCustomBoolOmitEmpty{},
B: false,
},
},
{
name: "AnonymousHeadCustomBoolWithMarshalerOmitEmpty",
data: struct {
structCustomBoolWithMarshalerOmitEmpty
B bool `json:"b,omitempty"`
}{
structCustomBoolWithMarshalerOmitEmpty: structCustomBoolWithMarshalerOmitEmpty{A: true},
B: false,
},
},
{
name: "AnonymousHeadCustomBoolWithMarshalerOmitEmptyFalse",
data: struct {
structCustomBoolWithMarshalerOmitEmpty
B bool `json:"b,omitempty"`
}{
structCustomBoolWithMarshalerOmitEmpty: structCustomBoolWithMarshalerOmitEmpty{},
B: false,
},
},
2021-04-12 11:41:10 +03:00
{
name: "AnonymousHeadSecondFieldCustomBoolWithMarshalerOmitEmpty",
data: struct {
structSecondFieldCustomBoolWithMarshalerOmitEmpty
B bool `json:"b,omitempty"`
}{
structSecondFieldCustomBoolWithMarshalerOmitEmpty: structSecondFieldCustomBoolWithMarshalerOmitEmpty{A: true},
B: false,
},
},
{
name: "AnonymousHeadSecondFieldCustomBoolWithMarshalerOmitEmptyFalse",
data: struct {
structSecondFieldCustomBoolWithMarshalerOmitEmpty
B bool `json:"b,omitempty"`
}{
structSecondFieldCustomBoolWithMarshalerOmitEmpty: structSecondFieldCustomBoolWithMarshalerOmitEmpty{},
B: false,
},
},
2021-02-15 05:48:09 +03:00
{
name: "AnonymousHeadBoolString",
data: struct {
structBoolString
B bool `json:"b,string"`
}{
structBoolString: structBoolString{A: true},
B: false,
},
},
2021-05-08 17:24:49 +03:00
{
name: "AnonymousHeadBoolStringOmitEmpty",
data: struct {
structBoolStringOmitEmpty
B bool `json:"b,string,omitempty"`
}{
structBoolStringOmitEmpty: structBoolStringOmitEmpty{A: true},
B: false,
},
},
2021-02-15 05:48:09 +03:00
// PtrAnonymousHeadBool
{
name: "PtrAnonymousHeadBool",
data: struct {
*structBool
B bool `json:"b"`
}{
structBool: &structBool{A: true},
B: false,
},
},
{
name: "PtrAnonymousHeadBoolOmitEmpty",
data: struct {
*structBoolOmitEmpty
B bool `json:"b,omitempty"`
}{
structBoolOmitEmpty: &structBoolOmitEmpty{A: true},
B: false,
},
},
{
name: "PtrAnonymousHeadCustomBoolOmitEmpty",
data: struct {
*structCustomBoolOmitEmpty
B bool `json:"b,omitempty"`
}{
structCustomBoolOmitEmpty: &structCustomBoolOmitEmpty{A: true},
B: false,
},
},
{
name: "PtrAnonymousHeadCustomBoolOmitEmptyFalse",
data: struct {
*structCustomBoolOmitEmpty
B bool `json:"b,omitempty"`
}{
structCustomBoolOmitEmpty: &structCustomBoolOmitEmpty{},
B: false,
},
},
2021-04-12 11:41:10 +03:00
{
name: "PtrAnonymousHeadSecondFieldCustomBoolOmitEmpty",
data: struct {
*structSecondFieldCustomBoolOmitEmpty
B bool `json:"b,omitempty"`
}{
structSecondFieldCustomBoolOmitEmpty: &structSecondFieldCustomBoolOmitEmpty{A: true},
B: false,
},
},
{
name: "PtrAnonymousHeadSecondFieldCustomBoolOmitEmptyFalse",
data: struct {
*structSecondFieldCustomBoolOmitEmpty
B bool `json:"b,omitempty"`
}{
structSecondFieldCustomBoolOmitEmpty: &structSecondFieldCustomBoolOmitEmpty{},
B: false,
},
},
{
name: "PtrAnonymousHeadCustomBoolWithMarshalerOmitEmpty",
data: struct {
*structCustomBoolWithMarshalerOmitEmpty
B bool `json:"b,omitempty"`
}{
structCustomBoolWithMarshalerOmitEmpty: &structCustomBoolWithMarshalerOmitEmpty{A: true},
B: false,
},
},
{
name: "PtrAnonymousHeadCustomBoolWithMarshalerOmitEmptyFalse",
data: struct {
*structCustomBoolWithMarshalerOmitEmpty
B bool `json:"b,omitempty"`
}{
structCustomBoolWithMarshalerOmitEmpty: &structCustomBoolWithMarshalerOmitEmpty{},
B: false,
},
},
2021-04-12 11:41:10 +03:00
{
name: "PtrAnonymousHeadSecondFieldCustomBoolWithMarshalerOmitEmpty",
data: struct {
*structSecondFieldCustomBoolWithMarshalerOmitEmpty
B bool `json:"b,omitempty"`
}{
structSecondFieldCustomBoolWithMarshalerOmitEmpty: &structSecondFieldCustomBoolWithMarshalerOmitEmpty{A: true},
B: false,
},
},
{
name: "PtrAnonymousHeadSecondFieldCustomBoolWithMarshalerOmitEmptyFalse",
data: struct {
*structSecondFieldCustomBoolWithMarshalerOmitEmpty
B bool `json:"b,omitempty"`
}{
structSecondFieldCustomBoolWithMarshalerOmitEmpty: &structSecondFieldCustomBoolWithMarshalerOmitEmpty{},
B: false,
},
},
2021-02-15 05:48:09 +03:00
{
name: "PtrAnonymousHeadBoolString",
data: struct {
*structBoolString
B bool `json:"b,string"`
}{
structBoolString: &structBoolString{A: true},
B: false,
},
},
2021-05-08 17:24:49 +03:00
{
name: "PtrAnonymousHeadBoolStringOmitEmpty",
data: struct {
*structBoolStringOmitEmpty
B bool `json:"b,string,omitempty"`
}{
structBoolStringOmitEmpty: &structBoolStringOmitEmpty{A: true},
B: false,
},
},
2021-02-15 05:48:09 +03:00
// NilPtrAnonymousHeadBool
{
name: "NilPtrAnonymousHeadBool",
data: struct {
*structBool
B bool `json:"b"`
}{
structBool: nil,
B: true,
},
},
{
name: "NilPtrAnonymousHeadBoolOmitEmpty",
data: struct {
*structBoolOmitEmpty
B bool `json:"b,omitempty"`
}{
structBoolOmitEmpty: nil,
B: true,
},
},
{
name: "NilPtrAnonymousHeadCustomBoolOmitEmpty",
data: struct {
*structCustomBoolOmitEmpty
B bool `json:"b,omitempty"`
}{
structCustomBoolOmitEmpty: nil,
B: true,
},
},
{
name: "NilPtrAnonymousHeadCustomBoolWithMarshalerOmitEmpty",
data: struct {
*structCustomBoolWithMarshalerOmitEmpty
B bool `json:"b,omitempty"`
}{
structCustomBoolWithMarshalerOmitEmpty: nil,
B: true,
},
},
2021-02-15 05:48:09 +03:00
{
name: "NilPtrAnonymousHeadBoolString",
data: struct {
*structBoolString
B bool `json:"b,string"`
}{
structBoolString: nil,
B: true,
},
},
2021-05-08 17:24:49 +03:00
{
name: "NilPtrAnonymousHeadBoolStringOmitEmpty",
data: struct {
*structBoolStringOmitEmpty
B bool `json:"b,string,omitempty"`
}{
structBoolStringOmitEmpty: nil,
B: true,
},
},
2021-02-15 05:48:09 +03:00
// AnonymousHeadBoolPtr
{
name: "AnonymousHeadBoolPtr",
data: struct {
structBoolPtr
B *bool `json:"b"`
}{
structBoolPtr: structBoolPtr{A: boolptr(true)},
B: boolptr(false),
},
},
{
name: "AnonymousHeadBoolPtrOmitEmpty",
data: struct {
structBoolPtrOmitEmpty
B *bool `json:"b,omitempty"`
}{
structBoolPtrOmitEmpty: structBoolPtrOmitEmpty{A: boolptr(true)},
B: boolptr(false),
},
},
{
name: "AnonymousHeadBoolPtrString",
data: struct {
structBoolPtrString
B *bool `json:"b,string"`
}{
structBoolPtrString: structBoolPtrString{A: boolptr(true)},
B: boolptr(false),
},
},
2021-05-08 17:24:49 +03:00
{
name: "AnonymousHeadBoolPtrStringOmitEmpty",
data: struct {
structBoolPtrStringOmitEmpty
B *bool `json:"b,string,omitempty"`
}{
structBoolPtrStringOmitEmpty: structBoolPtrStringOmitEmpty{A: boolptr(true)},
B: boolptr(false),
},
},
2021-02-15 05:48:09 +03:00
// AnonymousHeadBoolPtrNil
{
name: "AnonymousHeadBoolPtrNil",
data: struct {
structBoolPtr
B *bool `json:"b"`
}{
structBoolPtr: structBoolPtr{A: nil},
B: boolptr(true),
},
},
{
name: "AnonymousHeadBoolPtrNilOmitEmpty",
data: struct {
structBoolPtrOmitEmpty
B *bool `json:"b,omitempty"`
}{
structBoolPtrOmitEmpty: structBoolPtrOmitEmpty{A: nil},
B: boolptr(true),
},
},
{
name: "AnonymousHeadBoolPtrNilString",
data: struct {
structBoolPtrString
B *bool `json:"b,string"`
}{
structBoolPtrString: structBoolPtrString{A: nil},
B: boolptr(true),
},
},
2021-05-08 17:24:49 +03:00
{
name: "AnonymousHeadBoolPtrNilStringOmitEmpty",
data: struct {
structBoolPtrStringOmitEmpty
B *bool `json:"b,string,omitempty"`
}{
structBoolPtrStringOmitEmpty: structBoolPtrStringOmitEmpty{A: nil},
B: boolptr(true),
},
},
2021-02-15 05:48:09 +03:00
// PtrAnonymousHeadBoolPtr
{
name: "PtrAnonymousHeadBoolPtr",
data: struct {
*structBoolPtr
B *bool `json:"b"`
}{
structBoolPtr: &structBoolPtr{A: boolptr(true)},
B: boolptr(false),
},
},
{
name: "PtrAnonymousHeadBoolPtrOmitEmpty",
data: struct {
*structBoolPtrOmitEmpty
B *bool `json:"b,omitempty"`
}{
structBoolPtrOmitEmpty: &structBoolPtrOmitEmpty{A: boolptr(true)},
B: boolptr(false),
},
},
{
name: "PtrAnonymousHeadBoolPtrString",
data: struct {
*structBoolPtrString
B *bool `json:"b,string"`
}{
structBoolPtrString: &structBoolPtrString{A: boolptr(true)},
B: boolptr(false),
},
},
2021-05-08 17:24:49 +03:00
{
name: "PtrAnonymousHeadBoolPtrStringOmitEmpty",
data: struct {
*structBoolPtrStringOmitEmpty
B *bool `json:"b,string,omitempty"`
}{
structBoolPtrStringOmitEmpty: &structBoolPtrStringOmitEmpty{A: boolptr(true)},
B: boolptr(false),
},
},
2021-02-15 05:48:09 +03:00
// NilPtrAnonymousHeadBoolPtr
{
name: "NilPtrAnonymousHeadBoolPtr",
data: struct {
*structBoolPtr
B *bool `json:"b"`
}{
structBoolPtr: nil,
B: boolptr(true),
},
},
{
name: "NilPtrAnonymousHeadBoolPtrOmitEmpty",
data: struct {
*structBoolPtrOmitEmpty
B *bool `json:"b,omitempty"`
}{
structBoolPtrOmitEmpty: nil,
B: boolptr(true),
},
},
{
name: "NilPtrAnonymousHeadBoolPtrString",
data: struct {
*structBoolPtrString
B *bool `json:"b,string"`
}{
structBoolPtrString: nil,
B: boolptr(true),
},
},
2021-05-08 17:24:49 +03:00
{
name: "NilPtrAnonymousHeadBoolPtrStringOmitEmpty",
data: struct {
*structBoolPtrStringOmitEmpty
B *bool `json:"b,string,omitempty"`
}{
structBoolPtrStringOmitEmpty: nil,
B: boolptr(true),
},
},
2021-02-15 05:48:09 +03:00
// AnonymousHeadBoolOnly
{
name: "AnonymousHeadBoolOnly",
data: struct {
structBool
}{
structBool: structBool{A: true},
},
},
{
name: "AnonymousHeadBoolOnlyOmitEmpty",
data: struct {
structBoolOmitEmpty
}{
structBoolOmitEmpty: structBoolOmitEmpty{A: true},
},
},
{
name: "AnonymousHeadCustomBoolOnlyOmitEmpty",
data: struct {
structCustomBoolOmitEmpty
}{
structCustomBoolOmitEmpty: structCustomBoolOmitEmpty{A: true},
},
},
2021-04-12 11:41:10 +03:00
{
name: "AnonymousHeadSecondFieldCustomBoolOnlyOmitEmpty",
data: struct {
structSecondFieldCustomBoolOmitEmpty
}{
structSecondFieldCustomBoolOmitEmpty: structSecondFieldCustomBoolOmitEmpty{A: true},
},
},
{
name: "AnonymousHeadCustomBoolWithMarshalerOnlyOmitEmpty",
data: struct {
structCustomBoolWithMarshalerOmitEmpty
}{
structCustomBoolWithMarshalerOmitEmpty: structCustomBoolWithMarshalerOmitEmpty{A: true},
},
},
{
name: "AnonymousHeadCustomBoolWithMarshalerOnlyOmitEmptyFalse",
data: struct {
structCustomBoolWithMarshalerOmitEmpty
}{
structCustomBoolWithMarshalerOmitEmpty: structCustomBoolWithMarshalerOmitEmpty{},
},
},
2021-04-12 11:41:10 +03:00
{
name: "AnonymousHeadSecondFieldCustomBoolWithMarshalerOnlyOmitEmpty",
data: struct {
structSecondFieldCustomBoolWithMarshalerOmitEmpty
}{
structSecondFieldCustomBoolWithMarshalerOmitEmpty: structSecondFieldCustomBoolWithMarshalerOmitEmpty{A: true},
},
},
{
name: "AnonymousHeadSecondFieldCustomBoolWithMarshalerOnlyOmitEmptyFalse",
data: struct {
structSecondFieldCustomBoolWithMarshalerOmitEmpty
}{
structSecondFieldCustomBoolWithMarshalerOmitEmpty: structSecondFieldCustomBoolWithMarshalerOmitEmpty{},
},
},
2021-02-15 05:48:09 +03:00
{
name: "AnonymousHeadBoolOnlyString",
data: struct {
structBoolString
}{
structBoolString: structBoolString{A: true},
},
},
2021-05-08 17:24:49 +03:00
{
name: "AnonymousHeadBoolOnlyStringOmitEmpty",
data: struct {
structBoolStringOmitEmpty
}{
structBoolStringOmitEmpty: structBoolStringOmitEmpty{A: true},
},
},
2021-02-15 05:48:09 +03:00
// PtrAnonymousHeadBoolOnly
{
name: "PtrAnonymousHeadBoolOnly",
data: struct {
*structBool
}{
structBool: &structBool{A: true},
},
},
{
name: "PtrAnonymousHeadBoolOnlyOmitEmpty",
data: struct {
*structBoolOmitEmpty
}{
structBoolOmitEmpty: &structBoolOmitEmpty{A: true},
},
},
{
name: "PtrAnonymousHeadCustomBoolOnlyOmitEmpty",
data: struct {
*structCustomBoolOmitEmpty
}{
structCustomBoolOmitEmpty: &structCustomBoolOmitEmpty{A: true},
},
},
2021-04-12 11:41:10 +03:00
{
name: "PtrAnonymousHeadSecondFieldCustomBoolOnlyOmitEmpty",
data: struct {
*structSecondFieldCustomBoolOmitEmpty
}{
structSecondFieldCustomBoolOmitEmpty: &structSecondFieldCustomBoolOmitEmpty{A: true},
},
},
{
name: "PtrAnonymousHeadCustomBoolWithMarshalerOnlyOmitEmpty",
data: struct {
*structCustomBoolWithMarshalerOmitEmpty
}{
structCustomBoolWithMarshalerOmitEmpty: &structCustomBoolWithMarshalerOmitEmpty{A: true},
},
},
{
name: "PtrAnonymousHeadCustomBoolWithMarshalerOnlyOmitEmptyFalse",
data: struct {
*structCustomBoolWithMarshalerOmitEmpty
}{
structCustomBoolWithMarshalerOmitEmpty: &structCustomBoolWithMarshalerOmitEmpty{},
},
},
2021-04-12 11:41:10 +03:00
{
name: "PtrAnonymousHeadSecondFieldCustomBoolWithMarshalerOnlyOmitEmpty",
data: struct {
*structSecondFieldCustomBoolWithMarshalerOmitEmpty
}{
structSecondFieldCustomBoolWithMarshalerOmitEmpty: &structSecondFieldCustomBoolWithMarshalerOmitEmpty{A: true},
},
},
{
name: "PtrAnonymousHeadSecondFieldCustomBoolWithMarshalerOnlyOmitEmptyFalse",
data: struct {
*structSecondFieldCustomBoolWithMarshalerOmitEmpty
}{
structSecondFieldCustomBoolWithMarshalerOmitEmpty: &structSecondFieldCustomBoolWithMarshalerOmitEmpty{},
},
},
2021-02-15 05:48:09 +03:00
{
name: "PtrAnonymousHeadBoolOnlyString",
data: struct {
*structBoolString
}{
structBoolString: &structBoolString{A: true},
},
},
2021-05-08 17:24:49 +03:00
{
name: "PtrAnonymousHeadBoolOnlyStringOmitEmpty",
data: struct {
*structBoolStringOmitEmpty
}{
structBoolStringOmitEmpty: &structBoolStringOmitEmpty{A: true},
},
},
2021-02-15 05:48:09 +03:00
// NilPtrAnonymousHeadBoolOnly
{
name: "NilPtrAnonymousHeadBoolOnly",
data: struct {
*structBool
}{
structBool: nil,
},
},
{
name: "NilPtrAnonymousHeadBoolOnlyOmitEmpty",
data: struct {
*structBoolOmitEmpty
}{
structBoolOmitEmpty: nil,
},
},
{
name: "NilPtrAnonymousHeadCustomBoolOnlyOmitEmpty",
data: struct {
*structCustomBoolOmitEmpty
}{
structCustomBoolOmitEmpty: nil,
},
},
{
name: "NilPtrAnonymousHeadCustomBoolWithMarshalerOnlyOmitEmpty",
data: struct {
*structCustomBoolWithMarshalerOmitEmpty
}{
structCustomBoolWithMarshalerOmitEmpty: nil,
},
},
2021-02-15 05:48:09 +03:00
{
name: "NilPtrAnonymousHeadBoolOnlyString",
data: struct {
*structBoolString
}{
structBoolString: nil,
},
},
2021-05-08 17:24:49 +03:00
{
name: "NilPtrAnonymousHeadBoolOnlyStringOmitEmpty",
data: struct {
*structBoolStringOmitEmpty
}{
structBoolStringOmitEmpty: nil,
},
},
2021-02-15 05:48:09 +03:00
// AnonymousHeadBoolPtrOnly
{
name: "AnonymousHeadBoolPtrOnly",
data: struct {
structBoolPtr
}{
structBoolPtr: structBoolPtr{A: boolptr(true)},
},
},
{
name: "AnonymousHeadBoolPtrOnlyOmitEmpty",
data: struct {
structBoolPtrOmitEmpty
}{
structBoolPtrOmitEmpty: structBoolPtrOmitEmpty{A: boolptr(true)},
},
},
{
name: "AnonymousHeadBoolPtrOnlyString",
data: struct {
structBoolPtrString
}{
structBoolPtrString: structBoolPtrString{A: boolptr(true)},
},
},
2021-05-08 17:24:49 +03:00
{
name: "AnonymousHeadBoolPtrOnlyStringOmitEmpty",
data: struct {
structBoolPtrStringOmitEmpty
}{
structBoolPtrStringOmitEmpty: structBoolPtrStringOmitEmpty{A: boolptr(true)},
},
},
2021-02-15 05:48:09 +03:00
// AnonymousHeadBoolPtrNilOnly
{
name: "AnonymousHeadBoolPtrNilOnly",
data: struct {
structBoolPtr
}{
structBoolPtr: structBoolPtr{A: nil},
},
},
{
name: "AnonymousHeadBoolPtrNilOnlyOmitEmpty",
data: struct {
structBoolPtrOmitEmpty
}{
structBoolPtrOmitEmpty: structBoolPtrOmitEmpty{A: nil},
},
},
{
name: "AnonymousHeadBoolPtrNilOnlyString",
data: struct {
structBoolPtrString
}{
structBoolPtrString: structBoolPtrString{A: nil},
},
},
2021-05-08 17:24:49 +03:00
{
name: "AnonymousHeadBoolPtrNilOnlyStringOmitEmpty",
data: struct {
structBoolPtrStringOmitEmpty
}{
structBoolPtrStringOmitEmpty: structBoolPtrStringOmitEmpty{A: nil},
},
},
2021-02-15 05:48:09 +03:00
// PtrAnonymousHeadBoolPtrOnly
{
name: "PtrAnonymousHeadBoolPtrOnly",
data: struct {
*structBoolPtr
}{
structBoolPtr: &structBoolPtr{A: boolptr(true)},
},
},
{
name: "PtrAnonymousHeadBoolPtrOnlyOmitEmpty",
data: struct {
*structBoolPtrOmitEmpty
}{
structBoolPtrOmitEmpty: &structBoolPtrOmitEmpty{A: boolptr(true)},
},
},
{
name: "PtrAnonymousHeadBoolPtrOnlyString",
data: struct {
*structBoolPtrString
}{
structBoolPtrString: &structBoolPtrString{A: boolptr(true)},
},
},
2021-05-08 17:24:49 +03:00
{
name: "PtrAnonymousHeadBoolPtrOnlyStringOmitEmpty",
data: struct {
*structBoolPtrStringOmitEmpty
}{
structBoolPtrStringOmitEmpty: &structBoolPtrStringOmitEmpty{A: boolptr(true)},
},
},
2021-02-15 05:48:09 +03:00
// NilPtrAnonymousHeadBoolPtrOnly
{
name: "NilPtrAnonymousHeadBoolPtrOnly",
data: struct {
*structBoolPtr
}{
structBoolPtr: nil,
},
},
{
name: "NilPtrAnonymousHeadBoolPtrOnlyOmitEmpty",
data: struct {
*structBoolPtrOmitEmpty
}{
structBoolPtrOmitEmpty: nil,
},
},
{
name: "NilPtrAnonymousHeadBoolPtrOnlyString",
data: struct {
*structBoolPtrString
}{
structBoolPtrString: nil,
},
},
2021-05-08 17:24:49 +03:00
{
name: "NilPtrAnonymousHeadBoolPtrOnlyStringOmitEmpty",
data: struct {
*structBoolPtrStringOmitEmpty
}{
structBoolPtrStringOmitEmpty: nil,
},
},
2021-02-15 05:48:09 +03:00
}
for _, test := range tests {
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 {
t.Fatalf("%s(htmlEscape:%v,indent:%v): %+v: %s", test.name, htmlEscape, indent, test.data, err)
2021-02-15 05:48:09 +03:00
}
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())
2021-02-15 05:48:09 +03:00
}
}
}
}
}