diff --git a/cover_int_test.go b/cover_int_test.go index 71189cb..e76abb9 100644 --- a/cover_int_test.go +++ b/cover_int_test.go @@ -184,6 +184,12 @@ func TestCoverInt(t *testing.T) { A int `json:"a,string"` }{A: -1}, }, + { + name: "PtrHeadIntStringOmitEmpty", + data: &struct { + A int `json:"a,string,omitempty"` + }{A: -1}, + }, // PtrHeadIntPtr { @@ -204,6 +210,12 @@ func TestCoverInt(t *testing.T) { A *int `json:"a,string"` }{A: intptr(-1)}, }, + { + name: "PtrHeadIntPtrStringOmitEmpty", + data: &struct { + A *int `json:"a,string,omitempty"` + }{A: intptr(-1)}, + }, // PtrHeadIntPtrNil { @@ -224,6 +236,12 @@ func TestCoverInt(t *testing.T) { A *int `json:"a,string"` }{A: nil}, }, + { + name: "PtrHeadIntPtrNilStringOmitEmpty", + data: &struct { + A *int `json:"a,string,omitempty"` + }{A: nil}, + }, // PtrHeadIntNil { @@ -244,6 +262,12 @@ func TestCoverInt(t *testing.T) { A *int `json:"a,string"` })(nil), }, + { + name: "PtrHeadIntNilStringOmitEmpty", + data: (*struct { + A *int `json:"a,string,omitempty"` + })(nil), + }, // HeadIntZeroMultiFields { @@ -263,13 +287,21 @@ func TestCoverInt(t *testing.T) { }{}, }, { - name: "HeadIntZeroMultiFields", + name: "HeadIntZeroMultiFieldsString", data: struct { A int `json:"a,string"` B int `json:"b,string"` C int `json:"c,string"` }{}, }, + { + name: "HeadIntZeroMultiFieldsStringOmitEmpty", + data: struct { + A int `json:"a,string,omitempty"` + B int `json:"b,string,omitempty"` + C int `json:"c,string,omitempty"` + }{}, + }, // HeadIntMultiFields { @@ -296,6 +328,14 @@ func TestCoverInt(t *testing.T) { C int `json:"c,string"` }{A: -1, B: 2, C: 3}, }, + { + name: "HeadIntMultiFieldsStringOmitEmpty", + data: struct { + A int `json:"a,string,omitempty"` + B int `json:"b,string,omitempty"` + C int `json:"c,string,omitempty"` + }{A: -1, B: 2, C: 3}, + }, // HeadIntPtrMultiFields { @@ -322,6 +362,14 @@ func TestCoverInt(t *testing.T) { C *int `json:"c,string"` }{A: intptr(-1), B: intptr(2), C: intptr(3)}, }, + { + name: "HeadIntPtrMultiFieldsStringOmitEmpty", + data: struct { + A *int `json:"a,string,omitempty"` + B *int `json:"b,string,omitempty"` + C *int `json:"c,string,omitempty"` + }{A: intptr(-1), B: intptr(2), C: intptr(3)}, + }, // HeadIntPtrNilMultiFields { @@ -348,6 +396,14 @@ func TestCoverInt(t *testing.T) { C *int `json:"c,string"` }{A: nil, B: nil, C: nil}, }, + { + name: "HeadIntPtrNilMultiFieldsStringOmitEmpty", + data: struct { + A *int `json:"a,string,omitempty"` + B *int `json:"b,string,omitempty"` + C *int `json:"c,string,omitempty"` + }{A: nil, B: nil, C: nil}, + }, // PtrHeadIntZeroMultiFields { @@ -371,6 +427,13 @@ func TestCoverInt(t *testing.T) { B int `json:"b,string"` }{}, }, + { + name: "PtrHeadIntZeroMultiFieldsStringOmitEmpty", + data: &struct { + A int `json:"a,string,omitempty"` + B int `json:"b,string,omitempty"` + }{}, + }, // PtrHeadIntMultiFields { @@ -394,6 +457,13 @@ func TestCoverInt(t *testing.T) { B int `json:"b,string"` }{A: -1, B: 2}, }, + { + name: "PtrHeadIntMultiFieldsStringOmitEmpty", + data: &struct { + A int `json:"a,string,omitempty"` + B int `json:"b,string,omitempty"` + }{A: -1, B: 2}, + }, // PtrHeadIntPtrMultiFields { @@ -417,6 +487,13 @@ func TestCoverInt(t *testing.T) { B *int `json:"b,string"` }{A: intptr(-1), B: intptr(2)}, }, + { + name: "PtrHeadIntPtrMultiFieldsStringOmitEmpty", + data: &struct { + A *int `json:"a,string,omitempty"` + B *int `json:"b,string,omitempty"` + }{A: intptr(-1), B: intptr(2)}, + }, // PtrHeadIntPtrNilMultiFields { @@ -440,6 +517,13 @@ func TestCoverInt(t *testing.T) { B *int `json:"b,string"` }{A: nil, B: nil}, }, + { + name: "PtrHeadIntPtrNilMultiFieldsStringOmitEmpty", + data: &struct { + A *int `json:"a,string,omitempty"` + B *int `json:"b,string,omitempty"` + }{A: nil, B: nil}, + }, // PtrHeadIntNilMultiFields { @@ -463,6 +547,13 @@ func TestCoverInt(t *testing.T) { B *int `json:"b,string"` })(nil), }, + { + name: "PtrHeadIntNilMultiFieldsStringOmitEmpty", + data: (*struct { + A *int `json:"a,string,omitempty"` + B *int `json:"b,string,omitempty"` + })(nil), + }, // HeadIntZeroNotRoot { @@ -489,6 +580,14 @@ func TestCoverInt(t *testing.T) { } }{}, }, + { + name: "HeadIntZeroNotRootStringOmitEmpty", + data: struct { + A struct { + A int `json:"a,string,omitempty"` + } + }{}, + }, // HeadIntNotRoot { @@ -521,6 +620,16 @@ func TestCoverInt(t *testing.T) { A int `json:"a,string"` }{A: -1}}, }, + { + name: "HeadIntNotRootStringOmitEmpty", + data: struct { + A struct { + A int `json:"a,string,omitempty"` + } + }{A: struct { + A int `json:"a,string,omitempty"` + }{A: -1}}, + }, // HeadIntPtrNotRoot { @@ -553,6 +662,16 @@ func TestCoverInt(t *testing.T) { A *int `json:"a,string"` }{intptr(-1)}}, }, + { + name: "HeadIntPtrNotRootStringOmitEmpty", + data: struct { + A struct { + A *int `json:"a,string,omitempty"` + } + }{A: struct { + A *int `json:"a,string,omitempty"` + }{intptr(-1)}}, + }, // HeadIntPtrNilNotRoot { @@ -579,6 +698,14 @@ func TestCoverInt(t *testing.T) { } }{}, }, + { + name: "HeadIntPtrNilNotRootStringOmitEmpty", + data: struct { + A struct { + A *int `json:"a,string,omitempty"` + } + }{}, + }, // PtrHeadIntZeroNotRoot { @@ -611,6 +738,16 @@ func TestCoverInt(t *testing.T) { A int `json:"a,string"` })}, }, + { + name: "PtrHeadIntZeroNotRootStringOmitEmpty", + data: struct { + A *struct { + A int `json:"a,string,omitempty"` + } + }{A: new(struct { + A int `json:"a,string,omitempty"` + })}, + }, // PtrHeadIntNotRoot { @@ -643,6 +780,16 @@ func TestCoverInt(t *testing.T) { A int `json:"a,string"` }{A: -1})}, }, + { + name: "PtrHeadIntNotRootStringOmitEmpty", + data: struct { + A *struct { + A int `json:"a,string,omitempty"` + } + }{A: &(struct { + A int `json:"a,string,omitempty"` + }{A: -1})}, + }, // PtrHeadIntPtrNotRoot { @@ -675,6 +822,16 @@ func TestCoverInt(t *testing.T) { A *int `json:"a,string"` }{A: intptr(-1)})}, }, + { + name: "PtrHeadIntPtrNotRootStringOmitEmpty", + data: struct { + A *struct { + A *int `json:"a,string,omitempty"` + } + }{A: &(struct { + A *int `json:"a,string,omitempty"` + }{A: intptr(-1)})}, + }, // PtrHeadIntPtrNilNotRoot { @@ -707,6 +864,16 @@ func TestCoverInt(t *testing.T) { A *int `json:"a,string"` }{A: nil})}, }, + { + name: "PtrHeadIntPtrNilNotRootStringOmitEmpty", + data: struct { + A *struct { + A *int `json:"a,string,omitempty"` + } + }{A: &(struct { + A *int `json:"a,string,omitempty"` + }{A: nil})}, + }, // PtrHeadIntNilNotRoot { @@ -733,6 +900,14 @@ func TestCoverInt(t *testing.T) { } `json:",string"` }{A: nil}, }, + { + name: "PtrHeadIntNilNotRootStringOmitEmpty", + data: struct { + A *struct { + A *int `json:"a,string,omitempty"` + } `json:",string,omitempty"` + }{A: nil}, + }, // HeadIntZeroMultiFieldsNotRoot { @@ -768,6 +943,17 @@ func TestCoverInt(t *testing.T) { } }{}, }, + { + name: "HeadIntZeroMultiFieldsNotRootStringOmitEmpty", + data: struct { + A struct { + A int `json:"a,string,omitempty"` + } + B struct { + B int `json:"b,string,omitempty"` + } + }{}, + }, // HeadIntMultiFieldsNotRoot { @@ -815,6 +1001,21 @@ func TestCoverInt(t *testing.T) { B int `json:"b,string"` }{B: 2}}, }, + { + name: "HeadIntMultiFieldsNotRootStringOmitEmpty", + data: struct { + A struct { + A int `json:"a,string,omitempty"` + } + B struct { + B int `json:"b,string,omitempty"` + } + }{A: struct { + A int `json:"a,string,omitempty"` + }{A: -1}, B: struct { + B int `json:"b,string,omitempty"` + }{B: 2}}, + }, // HeadIntPtrMultiFieldsNotRoot { @@ -862,6 +1063,21 @@ func TestCoverInt(t *testing.T) { B *int `json:"b,string"` }{B: intptr(2)}}, }, + { + name: "HeadIntPtrMultiFieldsNotRootStringOmitEmpty", + data: struct { + A struct { + A *int `json:"a,string,omitempty"` + } + B struct { + B *int `json:"b,string,omitempty"` + } + }{A: struct { + A *int `json:"a,string,omitempty"` + }{A: intptr(-1)}, B: struct { + B *int `json:"b,string,omitempty"` + }{B: intptr(2)}}, + }, // HeadIntPtrNilMultiFieldsNotRoot { @@ -909,6 +1125,21 @@ func TestCoverInt(t *testing.T) { B *int `json:"b,string"` }{B: nil}}, }, + { + name: "HeadIntPtrNilMultiFieldsNotRootStringOmitEmpty", + data: struct { + A struct { + A *int `json:"a,string,omitempty"` + } + B struct { + B *int `json:"b,string,omitempty"` + } + }{A: struct { + A *int `json:"a,string,omitempty"` + }{A: nil}, B: struct { + B *int `json:"b,string,omitempty"` + }{B: nil}}, + }, // PtrHeadIntZeroMultiFieldsNotRoot { @@ -944,6 +1175,17 @@ func TestCoverInt(t *testing.T) { } }{}, }, + { + name: "PtrHeadIntZeroMultiFieldsNotRootStringOmitEmpty", + data: &struct { + A struct { + A int `json:"a,string,omitempty"` + } + B struct { + B int `json:"b,string,omitempty"` + } + }{}, + }, // PtrHeadIntMultiFieldsNotRoot { @@ -991,6 +1233,21 @@ func TestCoverInt(t *testing.T) { B int `json:"b,string"` }{B: 2}}, }, + { + name: "PtrHeadIntMultiFieldsNotRootStringOmitEmpty", + data: &struct { + A struct { + A int `json:"a,string,omitempty"` + } + B struct { + B int `json:"b,string,omitempty"` + } + }{A: struct { + A int `json:"a,string,omitempty"` + }{A: -1}, B: struct { + B int `json:"b,string,omitempty"` + }{B: 2}}, + }, // PtrHeadIntPtrMultiFieldsNotRoot { @@ -1038,6 +1295,21 @@ func TestCoverInt(t *testing.T) { B *int `json:"b,string"` }{B: intptr(2)})}, }, + { + name: "PtrHeadIntPtrMultiFieldsNotRootStringOmitEmpty", + data: &struct { + A *struct { + A *int `json:"a,string,omitempty"` + } + B *struct { + B *int `json:"b,string,omitempty"` + } + }{A: &(struct { + A *int `json:"a,string,omitempty"` + }{A: intptr(-1)}), B: &(struct { + B *int `json:"b,string,omitempty"` + }{B: intptr(2)})}, + }, // PtrHeadIntPtrNilMultiFieldsNotRoot { @@ -1073,6 +1345,17 @@ func TestCoverInt(t *testing.T) { } `json:",string"` }{A: nil, B: nil}, }, + { + name: "PtrHeadIntPtrNilMultiFieldsNotRootStringOmitEmpty", + data: &struct { + A *struct { + A *int `json:"a,string,omitempty"` + } `json:",string,omitempty"` + B *struct { + B *int `json:"b,string,omitempty"` + } `json:",string,omitempty"` + }{A: nil, B: nil}, + }, // PtrHeadIntNilMultiFieldsNotRoot { @@ -1108,6 +1391,17 @@ func TestCoverInt(t *testing.T) { } })(nil), }, + { + name: "PtrHeadIntNilMultiFieldsNotRootStringOmitEmpty", + data: (*struct { + A *struct { + A *int `json:"a,string,omitempty"` + } + B *struct { + B *int `json:"b,string,omitempty"` + } + })(nil), + }, // PtrHeadIntDoubleMultiFieldsNotRoot { @@ -1167,6 +1461,25 @@ func TestCoverInt(t *testing.T) { B int `json:"b,string"` }{A: 3, B: 4})}, }, + { + name: "PtrHeadIntDoubleMultiFieldsNotRootStringOmitEmpty", + data: &struct { + A *struct { + A int `json:"a,string,omitempty"` + B int `json:"b,string,omitempty"` + } + B *struct { + A int `json:"a,string,omitempty"` + B int `json:"b,string,omitempty"` + } + }{A: &(struct { + A int `json:"a,string,omitempty"` + B int `json:"b,string,omitempty"` + }{A: -1, B: 2}), B: &(struct { + A int `json:"a,string,omitempty"` + B int `json:"b,string,omitempty"` + }{A: 3, B: 4})}, + }, // PtrHeadIntNilDoubleMultiFieldsNotRoot { @@ -1208,6 +1521,19 @@ func TestCoverInt(t *testing.T) { } }{A: nil, B: nil}, }, + { + name: "PtrHeadIntNilDoubleMultiFieldsNotRootStringOmitEmpty", + data: &struct { + A *struct { + A int `json:"a,string,omitempty"` + B int `json:"b,string,omitempty"` + } + B *struct { + A int `json:"a,string,omitempty"` + B int `json:"b,string,omitempty"` + } + }{A: nil, B: nil}, + }, // PtrHeadIntNilDoubleMultiFieldsNotRoot { @@ -1249,6 +1575,19 @@ func TestCoverInt(t *testing.T) { } })(nil), }, + { + name: "PtrHeadIntNilDoubleMultiFieldsNotRootStringOmitEmpty", + data: (*struct { + A *struct { + A int `json:"a,string,omitempty"` + B int `json:"b,string,omitempty"` + } + B *struct { + A int `json:"a,string,omitempty"` + B int `json:"b,string,omitempty"` + } + })(nil), + }, // PtrHeadIntPtrDoubleMultiFieldsNotRoot { @@ -1308,6 +1647,25 @@ func TestCoverInt(t *testing.T) { B *int `json:"b,string"` }{A: intptr(3), B: intptr(4)})}, }, + { + name: "PtrHeadIntPtrDoubleMultiFieldsNotRootStringOmitEmpty", + data: &struct { + A *struct { + A *int `json:"a,string,omitempty"` + B *int `json:"b,string,omitempty"` + } + B *struct { + A *int `json:"a,string,omitempty"` + B *int `json:"b,string,omitempty"` + } + }{A: &(struct { + A *int `json:"a,string,omitempty"` + B *int `json:"b,string,omitempty"` + }{A: intptr(-1), B: intptr(2)}), B: &(struct { + A *int `json:"a,string,omitempty"` + B *int `json:"b,string,omitempty"` + }{A: intptr(3), B: intptr(4)})}, + }, // PtrHeadIntPtrNilDoubleMultiFieldsNotRoot { @@ -1349,6 +1707,19 @@ func TestCoverInt(t *testing.T) { } }{A: nil, B: nil}, }, + { + name: "PtrHeadIntPtrNilDoubleMultiFieldsNotRootStringOmitEmpty", + data: &struct { + A *struct { + A *int `json:"a,string,omitempty"` + B *int `json:"b,string,omitempty"` + } + B *struct { + A *int `json:"a,string,omitempty"` + B *int `json:"b,string,omitempty"` + } + }{A: nil, B: nil}, + }, // PtrHeadIntPtrNilDoubleMultiFieldsNotRoot { @@ -1390,6 +1761,19 @@ func TestCoverInt(t *testing.T) { } })(nil), }, + { + name: "PtrHeadIntPtrNilDoubleMultiFieldsNotRootStringOmitEmpty", + data: (*struct { + A *struct { + A *int `json:"a,string,omitempty"` + B *int `json:"b,string,omitempty"` + } + B *struct { + A *int `json:"a,string,omitempty"` + B *int `json:"b,string,omitempty"` + } + })(nil), + }, // AnonymousHeadInt { @@ -1422,6 +1806,16 @@ func TestCoverInt(t *testing.T) { B: 2, }, }, + { + name: "AnonymousHeadIntStringOmitEmpty", + data: struct { + structIntStringOmitEmpty + B int `json:"b,string,omitempty"` + }{ + structIntStringOmitEmpty: structIntStringOmitEmpty{A: -1}, + B: 2, + }, + }, // PtrAnonymousHeadInt { @@ -1454,6 +1848,16 @@ func TestCoverInt(t *testing.T) { B: 2, }, }, + { + name: "PtrAnonymousHeadIntStringOmitEmpty", + data: struct { + *structIntStringOmitEmpty + B int `json:"b,string,omitempty"` + }{ + structIntStringOmitEmpty: &structIntStringOmitEmpty{A: -1}, + B: 2, + }, + }, // NilPtrAnonymousHeadInt { @@ -1486,6 +1890,16 @@ func TestCoverInt(t *testing.T) { B: 2, }, }, + { + name: "NilPtrAnonymousHeadIntStringOmitEmpty", + data: struct { + *structIntStringOmitEmpty + B int `json:"b,string,omitempty"` + }{ + structIntStringOmitEmpty: nil, + B: 2, + }, + }, // AnonymousHeadIntPtr { @@ -1518,6 +1932,16 @@ func TestCoverInt(t *testing.T) { B: intptr(2), }, }, + { + name: "AnonymousHeadIntPtrStringOmitEmpty", + data: struct { + structIntPtrStringOmitEmpty + B *int `json:"b,string,omitempty"` + }{ + structIntPtrStringOmitEmpty: structIntPtrStringOmitEmpty{A: intptr(-1)}, + B: intptr(2), + }, + }, // AnonymousHeadIntPtrNil { @@ -1550,6 +1974,16 @@ func TestCoverInt(t *testing.T) { B: intptr(2), }, }, + { + name: "AnonymousHeadIntPtrNilStringOmitEmpty", + data: struct { + structIntPtrStringOmitEmpty + B *int `json:"b,string,omitempty"` + }{ + structIntPtrStringOmitEmpty: structIntPtrStringOmitEmpty{A: nil}, + B: intptr(2), + }, + }, // PtrAnonymousHeadIntPtr { @@ -1582,6 +2016,16 @@ func TestCoverInt(t *testing.T) { B: intptr(2), }, }, + { + name: "PtrAnonymousHeadIntPtrStringOmitEmpty", + data: struct { + *structIntPtrStringOmitEmpty + B *int `json:"b,string,omitempty"` + }{ + structIntPtrStringOmitEmpty: &structIntPtrStringOmitEmpty{A: intptr(-1)}, + B: intptr(2), + }, + }, // NilPtrAnonymousHeadIntPtr { @@ -1614,6 +2058,16 @@ func TestCoverInt(t *testing.T) { B: intptr(2), }, }, + { + name: "NilPtrAnonymousHeadIntPtrStringOmitEmpty", + data: struct { + *structIntPtrStringOmitEmpty + B *int `json:"b,string,omitempty"` + }{ + structIntPtrStringOmitEmpty: nil, + B: intptr(2), + }, + }, // AnonymousHeadIntOnly { @@ -1640,6 +2094,14 @@ func TestCoverInt(t *testing.T) { structIntString: structIntString{A: -1}, }, }, + { + name: "AnonymousHeadIntOnlyStringOmitEmpty", + data: struct { + structIntStringOmitEmpty + }{ + structIntStringOmitEmpty: structIntStringOmitEmpty{A: -1}, + }, + }, // PtrAnonymousHeadIntOnly { @@ -1666,6 +2128,14 @@ func TestCoverInt(t *testing.T) { structIntString: &structIntString{A: -1}, }, }, + { + name: "PtrAnonymousHeadIntOnlyStringOmitEmpty", + data: struct { + *structIntStringOmitEmpty + }{ + structIntStringOmitEmpty: &structIntStringOmitEmpty{A: -1}, + }, + }, // NilPtrAnonymousHeadIntOnly { @@ -1692,6 +2162,14 @@ func TestCoverInt(t *testing.T) { structIntString: nil, }, }, + { + name: "NilPtrAnonymousHeadIntOnlyStringOmitEmpty", + data: struct { + *structIntStringOmitEmpty + }{ + structIntStringOmitEmpty: nil, + }, + }, // AnonymousHeadIntPtrOnly { @@ -1718,6 +2196,14 @@ func TestCoverInt(t *testing.T) { structIntPtrString: structIntPtrString{A: intptr(-1)}, }, }, + { + name: "AnonymousHeadIntPtrOnlyStringOmitEmpty", + data: struct { + structIntPtrStringOmitEmpty + }{ + structIntPtrStringOmitEmpty: structIntPtrStringOmitEmpty{A: intptr(-1)}, + }, + }, // AnonymousHeadIntPtrNilOnly { @@ -1744,6 +2230,14 @@ func TestCoverInt(t *testing.T) { structIntPtrString: structIntPtrString{A: nil}, }, }, + { + name: "AnonymousHeadIntPtrNilOnlyStringOmitEmpty", + data: struct { + structIntPtrStringOmitEmpty + }{ + structIntPtrStringOmitEmpty: structIntPtrStringOmitEmpty{A: nil}, + }, + }, // PtrAnonymousHeadIntPtrOnly { @@ -1770,6 +2264,14 @@ func TestCoverInt(t *testing.T) { structIntPtrString: &structIntPtrString{A: intptr(-1)}, }, }, + { + name: "PtrAnonymousHeadIntPtrOnlyStringOmitEmpty", + data: struct { + *structIntPtrStringOmitEmpty + }{ + structIntPtrStringOmitEmpty: &structIntPtrStringOmitEmpty{A: intptr(-1)}, + }, + }, // NilPtrAnonymousHeadIntPtrOnly { @@ -1796,6 +2298,14 @@ func TestCoverInt(t *testing.T) { structIntPtrString: nil, }, }, + { + name: "NilPtrAnonymousHeadIntPtrOnlyStringOmitEmpty", + data: struct { + *structIntPtrStringOmitEmpty + }{ + structIntPtrStringOmitEmpty: nil, + }, + }, } for _, test := range tests { for _, indent := range []bool{true, false} {