From 42adc0a5abf951d4b6a3915141b413a14ee6fb9b Mon Sep 17 00:00:00 2001 From: IncSW Date: Mon, 12 Apr 2021 11:41:10 +0300 Subject: [PATCH] extend tests with custom types --- cover_bool_test.go | 138 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) diff --git a/cover_bool_test.go b/cover_bool_test.go index 49415fa..27954f8 100644 --- a/cover_bool_test.go +++ b/cover_bool_test.go @@ -41,10 +41,20 @@ func TestCoverBool(t *testing.T) { A customBool `json:"a,omitempty"` } + type structSecondFieldCustomBoolOmitEmpty struct { + C bool `json:"c"` + A customBool `json:"a,omitempty"` + } + type structCustomBoolWithMarshalerOmitEmpty struct { A customBoolWithMarshaler `json:"a,omitempty"` } + type structSecondFieldCustomBoolWithMarshalerOmitEmpty struct { + C bool `json:"c"` + A customBoolWithMarshaler `json:"a,omitempty"` + } + tests := []struct { name string data interface{} @@ -1437,6 +1447,26 @@ func TestCoverBool(t *testing.T) { 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", data: struct { @@ -1457,6 +1487,26 @@ func TestCoverBool(t *testing.T) { 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", data: struct { @@ -1509,6 +1559,26 @@ func TestCoverBool(t *testing.T) { 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", data: struct { @@ -1529,6 +1599,26 @@ func TestCoverBool(t *testing.T) { 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", data: struct { @@ -1745,6 +1835,14 @@ func TestCoverBool(t *testing.T) { structCustomBoolOmitEmpty: structCustomBoolOmitEmpty{A: true}, }, }, + { + name: "AnonymousHeadSecondFieldCustomBoolOnlyOmitEmpty", + data: struct { + structSecondFieldCustomBoolOmitEmpty + }{ + structSecondFieldCustomBoolOmitEmpty: structSecondFieldCustomBoolOmitEmpty{A: true}, + }, + }, { name: "AnonymousHeadCustomBoolWithMarshalerOnlyOmitEmpty", data: struct { @@ -1761,6 +1859,22 @@ func TestCoverBool(t *testing.T) { structCustomBoolWithMarshalerOmitEmpty: structCustomBoolWithMarshalerOmitEmpty{}, }, }, + { + name: "AnonymousHeadSecondFieldCustomBoolWithMarshalerOnlyOmitEmpty", + data: struct { + structSecondFieldCustomBoolWithMarshalerOmitEmpty + }{ + structSecondFieldCustomBoolWithMarshalerOmitEmpty: structSecondFieldCustomBoolWithMarshalerOmitEmpty{A: true}, + }, + }, + { + name: "AnonymousHeadSecondFieldCustomBoolWithMarshalerOnlyOmitEmptyFalse", + data: struct { + structSecondFieldCustomBoolWithMarshalerOmitEmpty + }{ + structSecondFieldCustomBoolWithMarshalerOmitEmpty: structSecondFieldCustomBoolWithMarshalerOmitEmpty{}, + }, + }, { name: "AnonymousHeadBoolOnlyString", data: struct { @@ -1795,6 +1909,14 @@ func TestCoverBool(t *testing.T) { structCustomBoolOmitEmpty: &structCustomBoolOmitEmpty{A: true}, }, }, + { + name: "PtrAnonymousHeadSecondFieldCustomBoolOnlyOmitEmpty", + data: struct { + *structSecondFieldCustomBoolOmitEmpty + }{ + structSecondFieldCustomBoolOmitEmpty: &structSecondFieldCustomBoolOmitEmpty{A: true}, + }, + }, { name: "PtrAnonymousHeadCustomBoolWithMarshalerOnlyOmitEmpty", data: struct { @@ -1811,6 +1933,22 @@ func TestCoverBool(t *testing.T) { structCustomBoolWithMarshalerOmitEmpty: &structCustomBoolWithMarshalerOmitEmpty{}, }, }, + { + name: "PtrAnonymousHeadSecondFieldCustomBoolWithMarshalerOnlyOmitEmpty", + data: struct { + *structSecondFieldCustomBoolWithMarshalerOmitEmpty + }{ + structSecondFieldCustomBoolWithMarshalerOmitEmpty: &structSecondFieldCustomBoolWithMarshalerOmitEmpty{A: true}, + }, + }, + { + name: "PtrAnonymousHeadSecondFieldCustomBoolWithMarshalerOnlyOmitEmptyFalse", + data: struct { + *structSecondFieldCustomBoolWithMarshalerOmitEmpty + }{ + structSecondFieldCustomBoolWithMarshalerOmitEmpty: &structSecondFieldCustomBoolWithMarshalerOmitEmpty{}, + }, + }, { name: "PtrAnonymousHeadBoolOnlyString", data: struct {