extend tests with custom types

This commit is contained in:
IncSW 2021-04-12 11:41:10 +03:00
parent d12ffe2c66
commit 42adc0a5ab
No known key found for this signature in database
GPG Key ID: 89876FA64BFB2D57
1 changed files with 138 additions and 0 deletions

View File

@ -41,10 +41,20 @@ func TestCoverBool(t *testing.T) {
A customBool `json:"a,omitempty"` A customBool `json:"a,omitempty"`
} }
type structSecondFieldCustomBoolOmitEmpty struct {
C bool `json:"c"`
A customBool `json:"a,omitempty"`
}
type structCustomBoolWithMarshalerOmitEmpty struct { type structCustomBoolWithMarshalerOmitEmpty struct {
A customBoolWithMarshaler `json:"a,omitempty"` A customBoolWithMarshaler `json:"a,omitempty"`
} }
type structSecondFieldCustomBoolWithMarshalerOmitEmpty struct {
C bool `json:"c"`
A customBoolWithMarshaler `json:"a,omitempty"`
}
tests := []struct { tests := []struct {
name string name string
data interface{} data interface{}
@ -1437,6 +1447,26 @@ func TestCoverBool(t *testing.T) {
B: false, B: false,
}, },
}, },
{
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", name: "AnonymousHeadCustomBoolWithMarshalerOmitEmpty",
data: struct { data: struct {
@ -1457,6 +1487,26 @@ func TestCoverBool(t *testing.T) {
B: false, B: false,
}, },
}, },
{
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,
},
},
{ {
name: "AnonymousHeadBoolString", name: "AnonymousHeadBoolString",
data: struct { data: struct {
@ -1509,6 +1559,26 @@ func TestCoverBool(t *testing.T) {
B: false, B: false,
}, },
}, },
{
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", name: "PtrAnonymousHeadCustomBoolWithMarshalerOmitEmpty",
data: struct { data: struct {
@ -1529,6 +1599,26 @@ func TestCoverBool(t *testing.T) {
B: false, B: false,
}, },
}, },
{
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,
},
},
{ {
name: "PtrAnonymousHeadBoolString", name: "PtrAnonymousHeadBoolString",
data: struct { data: struct {
@ -1745,6 +1835,14 @@ func TestCoverBool(t *testing.T) {
structCustomBoolOmitEmpty: structCustomBoolOmitEmpty{A: true}, structCustomBoolOmitEmpty: structCustomBoolOmitEmpty{A: true},
}, },
}, },
{
name: "AnonymousHeadSecondFieldCustomBoolOnlyOmitEmpty",
data: struct {
structSecondFieldCustomBoolOmitEmpty
}{
structSecondFieldCustomBoolOmitEmpty: structSecondFieldCustomBoolOmitEmpty{A: true},
},
},
{ {
name: "AnonymousHeadCustomBoolWithMarshalerOnlyOmitEmpty", name: "AnonymousHeadCustomBoolWithMarshalerOnlyOmitEmpty",
data: struct { data: struct {
@ -1761,6 +1859,22 @@ func TestCoverBool(t *testing.T) {
structCustomBoolWithMarshalerOmitEmpty: structCustomBoolWithMarshalerOmitEmpty{}, structCustomBoolWithMarshalerOmitEmpty: structCustomBoolWithMarshalerOmitEmpty{},
}, },
}, },
{
name: "AnonymousHeadSecondFieldCustomBoolWithMarshalerOnlyOmitEmpty",
data: struct {
structSecondFieldCustomBoolWithMarshalerOmitEmpty
}{
structSecondFieldCustomBoolWithMarshalerOmitEmpty: structSecondFieldCustomBoolWithMarshalerOmitEmpty{A: true},
},
},
{
name: "AnonymousHeadSecondFieldCustomBoolWithMarshalerOnlyOmitEmptyFalse",
data: struct {
structSecondFieldCustomBoolWithMarshalerOmitEmpty
}{
structSecondFieldCustomBoolWithMarshalerOmitEmpty: structSecondFieldCustomBoolWithMarshalerOmitEmpty{},
},
},
{ {
name: "AnonymousHeadBoolOnlyString", name: "AnonymousHeadBoolOnlyString",
data: struct { data: struct {
@ -1795,6 +1909,14 @@ func TestCoverBool(t *testing.T) {
structCustomBoolOmitEmpty: &structCustomBoolOmitEmpty{A: true}, structCustomBoolOmitEmpty: &structCustomBoolOmitEmpty{A: true},
}, },
}, },
{
name: "PtrAnonymousHeadSecondFieldCustomBoolOnlyOmitEmpty",
data: struct {
*structSecondFieldCustomBoolOmitEmpty
}{
structSecondFieldCustomBoolOmitEmpty: &structSecondFieldCustomBoolOmitEmpty{A: true},
},
},
{ {
name: "PtrAnonymousHeadCustomBoolWithMarshalerOnlyOmitEmpty", name: "PtrAnonymousHeadCustomBoolWithMarshalerOnlyOmitEmpty",
data: struct { data: struct {
@ -1811,6 +1933,22 @@ func TestCoverBool(t *testing.T) {
structCustomBoolWithMarshalerOmitEmpty: &structCustomBoolWithMarshalerOmitEmpty{}, structCustomBoolWithMarshalerOmitEmpty: &structCustomBoolWithMarshalerOmitEmpty{},
}, },
}, },
{
name: "PtrAnonymousHeadSecondFieldCustomBoolWithMarshalerOnlyOmitEmpty",
data: struct {
*structSecondFieldCustomBoolWithMarshalerOmitEmpty
}{
structSecondFieldCustomBoolWithMarshalerOmitEmpty: &structSecondFieldCustomBoolWithMarshalerOmitEmpty{A: true},
},
},
{
name: "PtrAnonymousHeadSecondFieldCustomBoolWithMarshalerOnlyOmitEmptyFalse",
data: struct {
*structSecondFieldCustomBoolWithMarshalerOmitEmpty
}{
structSecondFieldCustomBoolWithMarshalerOmitEmpty: &structSecondFieldCustomBoolWithMarshalerOmitEmpty{},
},
},
{ {
name: "PtrAnonymousHeadBoolOnlyString", name: "PtrAnonymousHeadBoolOnlyString",
data: struct { data: struct {