Merge pull request #216 from goccy/feature/support-omitempty-and-string

Supports using omitempty and string tags at the same time
This commit is contained in:
Masaaki Goshima 2021-05-09 01:12:28 +09:00 committed by GitHub
commit 7d6401a797
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 9496 additions and 2966 deletions

View File

@ -26,6 +26,9 @@ func TestCoverBool(t *testing.T) {
type structBoolString struct { type structBoolString struct {
A bool `json:"a,string"` A bool `json:"a,string"`
} }
type structBoolStringOmitEmpty struct {
A bool `json:"a,string,omitempty"`
}
type structBoolPtr struct { type structBoolPtr struct {
A *bool `json:"a"` A *bool `json:"a"`
@ -36,6 +39,9 @@ func TestCoverBool(t *testing.T) {
type structBoolPtrString struct { type structBoolPtrString struct {
A *bool `json:"a,string"` A *bool `json:"a,string"`
} }
type structBoolPtrStringOmitEmpty struct {
A *bool `json:"a,string,omitempty"`
}
type structCustomBoolOmitEmpty struct { type structCustomBoolOmitEmpty struct {
A customBool `json:"a,omitempty"` A customBool `json:"a,omitempty"`
@ -99,6 +105,12 @@ func TestCoverBool(t *testing.T) {
A bool `json:"a,string"` A bool `json:"a,string"`
}{}, }{},
}, },
{
name: "HeadBoolZeroStringOmitEmpty",
data: struct {
A bool `json:"a,string,omitempty"`
}{},
},
// HeadBool // HeadBool
{ {
@ -119,6 +131,12 @@ func TestCoverBool(t *testing.T) {
A bool `json:"a,string"` A bool `json:"a,string"`
}{A: true}, }{A: true},
}, },
{
name: "HeadBoolStringOmitEmpty",
data: struct {
A bool `json:"a,string,omitempty"`
}{A: true},
},
// HeadBoolPtr // HeadBoolPtr
{ {
@ -139,6 +157,12 @@ func TestCoverBool(t *testing.T) {
A *bool `json:"a,string"` A *bool `json:"a,string"`
}{A: boolptr(true)}, }{A: boolptr(true)},
}, },
{
name: "HeadBoolPtrStringOmitEmpty",
data: struct {
A *bool `json:"a,string,omitempty"`
}{A: boolptr(true)},
},
// HeadBoolPtrNil // HeadBoolPtrNil
{ {
@ -159,6 +183,12 @@ func TestCoverBool(t *testing.T) {
A *bool `json:"a,string"` A *bool `json:"a,string"`
}{A: nil}, }{A: nil},
}, },
{
name: "HeadBoolPtrNilStringOmitEmpty",
data: struct {
A *bool `json:"a,string,omitempty"`
}{A: nil},
},
// PtrHeadBoolZero // PtrHeadBoolZero
{ {
@ -179,6 +209,12 @@ func TestCoverBool(t *testing.T) {
A bool `json:"a,string"` A bool `json:"a,string"`
}{}, }{},
}, },
{
name: "PtrHeadBoolZeroStringOmitEmpty",
data: &struct {
A bool `json:"a,string,omitempty"`
}{},
},
// PtrHeadBool // PtrHeadBool
{ {
@ -199,6 +235,12 @@ func TestCoverBool(t *testing.T) {
A bool `json:"a,string"` A bool `json:"a,string"`
}{A: true}, }{A: true},
}, },
{
name: "PtrHeadBoolStringOmitEmpty",
data: &struct {
A bool `json:"a,string,omitempty"`
}{A: true},
},
// PtrHeadBoolPtr // PtrHeadBoolPtr
{ {
@ -219,6 +261,12 @@ func TestCoverBool(t *testing.T) {
A *bool `json:"a,string"` A *bool `json:"a,string"`
}{A: boolptr(true)}, }{A: boolptr(true)},
}, },
{
name: "PtrHeadBoolPtrStringOmitEmpty",
data: &struct {
A *bool `json:"a,string,omitempty"`
}{A: boolptr(true)},
},
// PtrHeadBoolPtrNil // PtrHeadBoolPtrNil
{ {
@ -239,6 +287,12 @@ func TestCoverBool(t *testing.T) {
A *bool `json:"a,string"` A *bool `json:"a,string"`
}{A: nil}, }{A: nil},
}, },
{
name: "PtrHeadBoolPtrNilStringOmitEmpty",
data: &struct {
A *bool `json:"a,string,omitempty"`
}{A: nil},
},
// PtrHeadBoolNil // PtrHeadBoolNil
{ {
@ -259,6 +313,12 @@ func TestCoverBool(t *testing.T) {
A *bool `json:"a,string"` A *bool `json:"a,string"`
})(nil), })(nil),
}, },
{
name: "PtrHeadBoolNilStringOmitEmpty",
data: (*struct {
A *bool `json:"a,string,omitempty"`
})(nil),
},
// HeadBoolZeroMultiFields // HeadBoolZeroMultiFields
{ {
@ -278,13 +338,21 @@ func TestCoverBool(t *testing.T) {
}{}, }{},
}, },
{ {
name: "HeadBoolZeroMultiFields", name: "HeadBoolZeroMultiFieldsString",
data: struct { data: struct {
A bool `json:"a,string"` A bool `json:"a,string"`
B bool `json:"b,string"` B bool `json:"b,string"`
C bool `json:"c,string"` C bool `json:"c,string"`
}{}, }{},
}, },
{
name: "HeadBoolZeroMultiFieldsStringOmitEmpty",
data: struct {
A bool `json:"a,string,omitempty"`
B bool `json:"b,string,omitempty"`
C bool `json:"c,string,omitempty"`
}{},
},
// HeadBoolMultiFields // HeadBoolMultiFields
{ {
@ -311,6 +379,14 @@ func TestCoverBool(t *testing.T) {
C bool `json:"c,string"` C bool `json:"c,string"`
}{A: true, B: false, C: true}, }{A: true, B: false, C: true},
}, },
{
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},
},
// HeadBoolPtrMultiFields // HeadBoolPtrMultiFields
{ {
@ -337,6 +413,14 @@ func TestCoverBool(t *testing.T) {
C *bool `json:"c,string"` C *bool `json:"c,string"`
}{A: boolptr(true), B: boolptr(false), C: boolptr(true)}, }{A: boolptr(true), B: boolptr(false), C: boolptr(true)},
}, },
{
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)},
},
// HeadBoolPtrNilMultiFields // HeadBoolPtrNilMultiFields
{ {
@ -363,6 +447,14 @@ func TestCoverBool(t *testing.T) {
C *bool `json:"c,string"` C *bool `json:"c,string"`
}{A: nil, B: nil, C: nil}, }{A: nil, B: nil, C: nil},
}, },
{
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},
},
// PtrHeadBoolZeroMultiFields // PtrHeadBoolZeroMultiFields
{ {
@ -386,6 +478,13 @@ func TestCoverBool(t *testing.T) {
B bool `json:"b,string"` B bool `json:"b,string"`
}{}, }{},
}, },
{
name: "PtrHeadBoolZeroMultiFieldsStringOmitEmpty",
data: &struct {
A bool `json:"a,string,omitempty"`
B bool `json:"b,string,omitempty"`
}{},
},
// PtrHeadBoolMultiFields // PtrHeadBoolMultiFields
{ {
@ -409,6 +508,13 @@ func TestCoverBool(t *testing.T) {
B bool `json:"b,string"` B bool `json:"b,string"`
}{A: true, B: false}, }{A: true, B: false},
}, },
{
name: "PtrHeadBoolMultiFieldsStringOmitEmpty",
data: &struct {
A bool `json:"a,string,omitempty"`
B bool `json:"b,string,omitempty"`
}{A: true, B: false},
},
// PtrHeadBoolPtrMultiFields // PtrHeadBoolPtrMultiFields
{ {
@ -432,6 +538,13 @@ func TestCoverBool(t *testing.T) {
B *bool `json:"b,string"` B *bool `json:"b,string"`
}{A: boolptr(true), B: boolptr(false)}, }{A: boolptr(true), B: boolptr(false)},
}, },
{
name: "PtrHeadBoolPtrMultiFieldsStringOmitEmpty",
data: &struct {
A *bool `json:"a,string,omitempty"`
B *bool `json:"b,string,omitempty"`
}{A: boolptr(true), B: boolptr(false)},
},
// PtrHeadBoolPtrNilMultiFields // PtrHeadBoolPtrNilMultiFields
{ {
@ -455,6 +568,13 @@ func TestCoverBool(t *testing.T) {
B *bool `json:"b,string"` B *bool `json:"b,string"`
}{A: nil, B: nil}, }{A: nil, B: nil},
}, },
{
name: "PtrHeadBoolPtrNilMultiFieldsStringOmitEmpty",
data: &struct {
A *bool `json:"a,string,omitempty"`
B *bool `json:"b,string,omitempty"`
}{A: nil, B: nil},
},
// PtrHeadBoolNilMultiFields // PtrHeadBoolNilMultiFields
{ {
@ -478,6 +598,13 @@ func TestCoverBool(t *testing.T) {
B *bool `json:"b,string"` B *bool `json:"b,string"`
})(nil), })(nil),
}, },
{
name: "PtrHeadBoolNilMultiFieldsStringOmitEmpty",
data: (*struct {
A *bool `json:"a,string,omitempty"`
B *bool `json:"b,string,omitempty"`
})(nil),
},
// HeadBoolZeroNotRoot // HeadBoolZeroNotRoot
{ {
@ -504,6 +631,14 @@ func TestCoverBool(t *testing.T) {
} }
}{}, }{},
}, },
{
name: "HeadBoolZeroNotRootStringOmitEmpty",
data: struct {
A struct {
A bool `json:"a,string,omitempty"`
}
}{},
},
// HeadBoolNotRoot // HeadBoolNotRoot
{ {
@ -536,6 +671,16 @@ func TestCoverBool(t *testing.T) {
A bool `json:"a,string"` A bool `json:"a,string"`
}{A: true}}, }{A: true}},
}, },
{
name: "HeadBoolNotRootStringOmitEmpty",
data: struct {
A struct {
A bool `json:"a,string,omitempty"`
}
}{A: struct {
A bool `json:"a,string,omitempty"`
}{A: true}},
},
// HeadBoolPtrNotRoot // HeadBoolPtrNotRoot
{ {
@ -568,6 +713,16 @@ func TestCoverBool(t *testing.T) {
A *bool `json:"a,string"` A *bool `json:"a,string"`
}{boolptr(true)}}, }{boolptr(true)}},
}, },
{
name: "HeadBoolPtrNotRootStringOmitEmpty",
data: struct {
A struct {
A *bool `json:"a,string,omitempty"`
}
}{A: struct {
A *bool `json:"a,string,omitempty"`
}{boolptr(true)}},
},
// HeadBoolPtrNilNotRoot // HeadBoolPtrNilNotRoot
{ {
@ -594,6 +749,14 @@ func TestCoverBool(t *testing.T) {
} }
}{}, }{},
}, },
{
name: "HeadBoolPtrNilNotRootStringOmitEmpty",
data: struct {
A struct {
A *bool `json:"a,string,omitempty"`
}
}{},
},
// PtrHeadBoolZeroNotRoot // PtrHeadBoolZeroNotRoot
{ {
@ -626,6 +789,16 @@ func TestCoverBool(t *testing.T) {
A bool `json:"a,string"` A bool `json:"a,string"`
})}, })},
}, },
{
name: "PtrHeadBoolZeroNotRootStringOmitEmpty",
data: struct {
A *struct {
A bool `json:"a,string,omitempty"`
}
}{A: new(struct {
A bool `json:"a,string,omitempty"`
})},
},
// PtrHeadBoolNotRoot // PtrHeadBoolNotRoot
{ {
@ -658,6 +831,16 @@ func TestCoverBool(t *testing.T) {
A bool `json:"a,string"` A bool `json:"a,string"`
}{A: true})}, }{A: true})},
}, },
{
name: "PtrHeadBoolNotRootStringOmitEmpty",
data: struct {
A *struct {
A bool `json:"a,string,omitempty"`
}
}{A: &(struct {
A bool `json:"a,string,omitempty"`
}{A: true})},
},
// PtrHeadBoolPtrNotRoot // PtrHeadBoolPtrNotRoot
{ {
@ -690,6 +873,16 @@ func TestCoverBool(t *testing.T) {
A *bool `json:"a,string"` A *bool `json:"a,string"`
}{A: boolptr(true)})}, }{A: boolptr(true)})},
}, },
{
name: "PtrHeadBoolPtrNotRootStringOmitEmpty",
data: struct {
A *struct {
A *bool `json:"a,string,omitempty"`
}
}{A: &(struct {
A *bool `json:"a,string,omitempty"`
}{A: boolptr(true)})},
},
// PtrHeadBoolPtrNilNotRoot // PtrHeadBoolPtrNilNotRoot
{ {
@ -722,6 +915,16 @@ func TestCoverBool(t *testing.T) {
A *bool `json:"a,string"` A *bool `json:"a,string"`
}{A: nil})}, }{A: nil})},
}, },
{
name: "PtrHeadBoolPtrNilNotRootStringOmitEmpty",
data: struct {
A *struct {
A *bool `json:"a,string,omitempty"`
}
}{A: &(struct {
A *bool `json:"a,string,omitempty"`
}{A: nil})},
},
// PtrHeadBoolNilNotRoot // PtrHeadBoolNilNotRoot
{ {
@ -748,6 +951,14 @@ func TestCoverBool(t *testing.T) {
} `json:",string"` } `json:",string"`
}{A: nil}, }{A: nil},
}, },
{
name: "PtrHeadBoolNilNotRootStringOmitEmpty",
data: struct {
A *struct {
A *bool `json:"a,string,omitempty"`
} `json:",string,omitempty"`
}{A: nil},
},
// HeadBoolZeroMultiFieldsNotRoot // HeadBoolZeroMultiFieldsNotRoot
{ {
@ -783,6 +994,17 @@ func TestCoverBool(t *testing.T) {
} }
}{}, }{},
}, },
{
name: "HeadBoolZeroMultiFieldsNotRootStringOmitEmpty",
data: struct {
A struct {
A bool `json:"a,string,omitempty"`
}
B struct {
B bool `json:"b,string,omitempty"`
}
}{},
},
// HeadBoolMultiFieldsNotRoot // HeadBoolMultiFieldsNotRoot
{ {
@ -830,6 +1052,21 @@ func TestCoverBool(t *testing.T) {
B bool `json:"b,string"` B bool `json:"b,string"`
}{B: false}}, }{B: false}},
}, },
{
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}},
},
// HeadBoolPtrMultiFieldsNotRoot // HeadBoolPtrMultiFieldsNotRoot
{ {
@ -877,6 +1114,21 @@ func TestCoverBool(t *testing.T) {
B *bool `json:"b,string"` B *bool `json:"b,string"`
}{B: boolptr(false)}}, }{B: boolptr(false)}},
}, },
{
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)}},
},
// HeadBoolPtrNilMultiFieldsNotRoot // HeadBoolPtrNilMultiFieldsNotRoot
{ {
@ -924,6 +1176,21 @@ func TestCoverBool(t *testing.T) {
B *bool `json:"b,string"` B *bool `json:"b,string"`
}{B: nil}}, }{B: nil}},
}, },
{
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}},
},
// PtrHeadBoolZeroMultiFieldsNotRoot // PtrHeadBoolZeroMultiFieldsNotRoot
{ {
@ -959,6 +1226,17 @@ func TestCoverBool(t *testing.T) {
} }
}{}, }{},
}, },
{
name: "PtrHeadBoolZeroMultiFieldsNotRootStringOmitEmpty",
data: &struct {
A struct {
A bool `json:"a,string,omitempty"`
}
B struct {
B bool `json:"b,string,omitempty"`
}
}{},
},
// PtrHeadBoolMultiFieldsNotRoot // PtrHeadBoolMultiFieldsNotRoot
{ {
@ -1006,6 +1284,21 @@ func TestCoverBool(t *testing.T) {
B bool `json:"b,string"` B bool `json:"b,string"`
}{B: false}}, }{B: false}},
}, },
{
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}},
},
// PtrHeadBoolPtrMultiFieldsNotRoot // PtrHeadBoolPtrMultiFieldsNotRoot
{ {
@ -1053,6 +1346,21 @@ func TestCoverBool(t *testing.T) {
B *bool `json:"b,string"` B *bool `json:"b,string"`
}{B: boolptr(false)})}, }{B: boolptr(false)})},
}, },
{
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)})},
},
// PtrHeadBoolPtrNilMultiFieldsNotRoot // PtrHeadBoolPtrNilMultiFieldsNotRoot
{ {
@ -1088,6 +1396,17 @@ func TestCoverBool(t *testing.T) {
} `json:",string"` } `json:",string"`
}{A: nil, B: nil}, }{A: nil, B: nil},
}, },
{
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},
},
// PtrHeadBoolNilMultiFieldsNotRoot // PtrHeadBoolNilMultiFieldsNotRoot
{ {
@ -1123,6 +1442,17 @@ func TestCoverBool(t *testing.T) {
} }
})(nil), })(nil),
}, },
{
name: "PtrHeadBoolNilMultiFieldsNotRootStringOmitEmpty",
data: (*struct {
A *struct {
A *bool `json:"a,string,omitempty"`
}
B *struct {
B *bool `json:"b,string,omitempty"`
}
})(nil),
},
// PtrHeadBoolDoubleMultiFieldsNotRoot // PtrHeadBoolDoubleMultiFieldsNotRoot
{ {
@ -1182,6 +1512,25 @@ func TestCoverBool(t *testing.T) {
B bool `json:"b,string"` B bool `json:"b,string"`
}{A: true, B: false})}, }{A: true, B: false})},
}, },
{
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})},
},
// PtrHeadBoolNilDoubleMultiFieldsNotRoot // PtrHeadBoolNilDoubleMultiFieldsNotRoot
{ {
@ -1223,6 +1572,19 @@ func TestCoverBool(t *testing.T) {
} }
}{A: nil, B: nil}, }{A: nil, B: nil},
}, },
{
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},
},
// PtrHeadBoolNilDoubleMultiFieldsNotRoot // PtrHeadBoolNilDoubleMultiFieldsNotRoot
{ {
@ -1264,6 +1626,19 @@ func TestCoverBool(t *testing.T) {
} }
})(nil), })(nil),
}, },
{
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),
},
// PtrHeadBoolPtrDoubleMultiFieldsNotRoot // PtrHeadBoolPtrDoubleMultiFieldsNotRoot
{ {
@ -1323,6 +1698,25 @@ func TestCoverBool(t *testing.T) {
B *bool `json:"b,string"` B *bool `json:"b,string"`
}{A: boolptr(true), B: boolptr(false)})}, }{A: boolptr(true), B: boolptr(false)})},
}, },
{
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)})},
},
// PtrHeadBoolPtrNilDoubleMultiFieldsNotRoot // PtrHeadBoolPtrNilDoubleMultiFieldsNotRoot
{ {
@ -1364,6 +1758,19 @@ func TestCoverBool(t *testing.T) {
} }
}{A: nil, B: nil}, }{A: nil, B: nil},
}, },
{
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},
},
// PtrHeadBoolPtrNilDoubleMultiFieldsNotRoot // PtrHeadBoolPtrNilDoubleMultiFieldsNotRoot
{ {
@ -1405,6 +1812,19 @@ func TestCoverBool(t *testing.T) {
} }
})(nil), })(nil),
}, },
{
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),
},
// AnonymousHeadBool // AnonymousHeadBool
{ {
@ -1517,6 +1937,16 @@ func TestCoverBool(t *testing.T) {
B: false, B: false,
}, },
}, },
{
name: "AnonymousHeadBoolStringOmitEmpty",
data: struct {
structBoolStringOmitEmpty
B bool `json:"b,string,omitempty"`
}{
structBoolStringOmitEmpty: structBoolStringOmitEmpty{A: true},
B: false,
},
},
// PtrAnonymousHeadBool // PtrAnonymousHeadBool
{ {
@ -1629,6 +2059,16 @@ func TestCoverBool(t *testing.T) {
B: false, B: false,
}, },
}, },
{
name: "PtrAnonymousHeadBoolStringOmitEmpty",
data: struct {
*structBoolStringOmitEmpty
B bool `json:"b,string,omitempty"`
}{
structBoolStringOmitEmpty: &structBoolStringOmitEmpty{A: true},
B: false,
},
},
// NilPtrAnonymousHeadBool // NilPtrAnonymousHeadBool
{ {
@ -1681,6 +2121,16 @@ func TestCoverBool(t *testing.T) {
B: true, B: true,
}, },
}, },
{
name: "NilPtrAnonymousHeadBoolStringOmitEmpty",
data: struct {
*structBoolStringOmitEmpty
B bool `json:"b,string,omitempty"`
}{
structBoolStringOmitEmpty: nil,
B: true,
},
},
// AnonymousHeadBoolPtr // AnonymousHeadBoolPtr
{ {
@ -1713,6 +2163,16 @@ func TestCoverBool(t *testing.T) {
B: boolptr(false), B: boolptr(false),
}, },
}, },
{
name: "AnonymousHeadBoolPtrStringOmitEmpty",
data: struct {
structBoolPtrStringOmitEmpty
B *bool `json:"b,string,omitempty"`
}{
structBoolPtrStringOmitEmpty: structBoolPtrStringOmitEmpty{A: boolptr(true)},
B: boolptr(false),
},
},
// AnonymousHeadBoolPtrNil // AnonymousHeadBoolPtrNil
{ {
@ -1745,6 +2205,16 @@ func TestCoverBool(t *testing.T) {
B: boolptr(true), B: boolptr(true),
}, },
}, },
{
name: "AnonymousHeadBoolPtrNilStringOmitEmpty",
data: struct {
structBoolPtrStringOmitEmpty
B *bool `json:"b,string,omitempty"`
}{
structBoolPtrStringOmitEmpty: structBoolPtrStringOmitEmpty{A: nil},
B: boolptr(true),
},
},
// PtrAnonymousHeadBoolPtr // PtrAnonymousHeadBoolPtr
{ {
@ -1777,6 +2247,16 @@ func TestCoverBool(t *testing.T) {
B: boolptr(false), B: boolptr(false),
}, },
}, },
{
name: "PtrAnonymousHeadBoolPtrStringOmitEmpty",
data: struct {
*structBoolPtrStringOmitEmpty
B *bool `json:"b,string,omitempty"`
}{
structBoolPtrStringOmitEmpty: &structBoolPtrStringOmitEmpty{A: boolptr(true)},
B: boolptr(false),
},
},
// NilPtrAnonymousHeadBoolPtr // NilPtrAnonymousHeadBoolPtr
{ {
@ -1809,6 +2289,16 @@ func TestCoverBool(t *testing.T) {
B: boolptr(true), B: boolptr(true),
}, },
}, },
{
name: "NilPtrAnonymousHeadBoolPtrStringOmitEmpty",
data: struct {
*structBoolPtrStringOmitEmpty
B *bool `json:"b,string,omitempty"`
}{
structBoolPtrStringOmitEmpty: nil,
B: boolptr(true),
},
},
// AnonymousHeadBoolOnly // AnonymousHeadBoolOnly
{ {
@ -1883,6 +2373,14 @@ func TestCoverBool(t *testing.T) {
structBoolString: structBoolString{A: true}, structBoolString: structBoolString{A: true},
}, },
}, },
{
name: "AnonymousHeadBoolOnlyStringOmitEmpty",
data: struct {
structBoolStringOmitEmpty
}{
structBoolStringOmitEmpty: structBoolStringOmitEmpty{A: true},
},
},
// PtrAnonymousHeadBoolOnly // PtrAnonymousHeadBoolOnly
{ {
@ -1957,6 +2455,14 @@ func TestCoverBool(t *testing.T) {
structBoolString: &structBoolString{A: true}, structBoolString: &structBoolString{A: true},
}, },
}, },
{
name: "PtrAnonymousHeadBoolOnlyStringOmitEmpty",
data: struct {
*structBoolStringOmitEmpty
}{
structBoolStringOmitEmpty: &structBoolStringOmitEmpty{A: true},
},
},
// NilPtrAnonymousHeadBoolOnly // NilPtrAnonymousHeadBoolOnly
{ {
@ -1999,6 +2505,14 @@ func TestCoverBool(t *testing.T) {
structBoolString: nil, structBoolString: nil,
}, },
}, },
{
name: "NilPtrAnonymousHeadBoolOnlyStringOmitEmpty",
data: struct {
*structBoolStringOmitEmpty
}{
structBoolStringOmitEmpty: nil,
},
},
// AnonymousHeadBoolPtrOnly // AnonymousHeadBoolPtrOnly
{ {
@ -2025,6 +2539,14 @@ func TestCoverBool(t *testing.T) {
structBoolPtrString: structBoolPtrString{A: boolptr(true)}, structBoolPtrString: structBoolPtrString{A: boolptr(true)},
}, },
}, },
{
name: "AnonymousHeadBoolPtrOnlyStringOmitEmpty",
data: struct {
structBoolPtrStringOmitEmpty
}{
structBoolPtrStringOmitEmpty: structBoolPtrStringOmitEmpty{A: boolptr(true)},
},
},
// AnonymousHeadBoolPtrNilOnly // AnonymousHeadBoolPtrNilOnly
{ {
@ -2051,6 +2573,14 @@ func TestCoverBool(t *testing.T) {
structBoolPtrString: structBoolPtrString{A: nil}, structBoolPtrString: structBoolPtrString{A: nil},
}, },
}, },
{
name: "AnonymousHeadBoolPtrNilOnlyStringOmitEmpty",
data: struct {
structBoolPtrStringOmitEmpty
}{
structBoolPtrStringOmitEmpty: structBoolPtrStringOmitEmpty{A: nil},
},
},
// PtrAnonymousHeadBoolPtrOnly // PtrAnonymousHeadBoolPtrOnly
{ {
@ -2077,6 +2607,14 @@ func TestCoverBool(t *testing.T) {
structBoolPtrString: &structBoolPtrString{A: boolptr(true)}, structBoolPtrString: &structBoolPtrString{A: boolptr(true)},
}, },
}, },
{
name: "PtrAnonymousHeadBoolPtrOnlyStringOmitEmpty",
data: struct {
*structBoolPtrStringOmitEmpty
}{
structBoolPtrStringOmitEmpty: &structBoolPtrStringOmitEmpty{A: boolptr(true)},
},
},
// NilPtrAnonymousHeadBoolPtrOnly // NilPtrAnonymousHeadBoolPtrOnly
{ {
@ -2103,6 +2641,14 @@ func TestCoverBool(t *testing.T) {
structBoolPtrString: nil, structBoolPtrString: nil,
}, },
}, },
{
name: "NilPtrAnonymousHeadBoolPtrOnlyStringOmitEmpty",
data: struct {
*structBoolPtrStringOmitEmpty
}{
structBoolPtrStringOmitEmpty: nil,
},
},
} }
for _, test := range tests { for _, test := range tests {
for _, indent := range []bool{true, false} { for _, indent := range []bool{true, false} {

View File

@ -17,6 +17,9 @@ func TestCoverFloat32(t *testing.T) {
type structFloat32String struct { type structFloat32String struct {
A float32 `json:"a,string"` A float32 `json:"a,string"`
} }
type structFloat32StringOmitEmpty struct {
A float32 `json:"a,string,omitempty"`
}
type structFloat32Ptr struct { type structFloat32Ptr struct {
A *float32 `json:"a"` A *float32 `json:"a"`
@ -27,6 +30,9 @@ func TestCoverFloat32(t *testing.T) {
type structFloat32PtrString struct { type structFloat32PtrString struct {
A *float32 `json:"a,string"` A *float32 `json:"a,string"`
} }
type structFloat32PtrStringOmitEmpty struct {
A *float32 `json:"a,string,omitempty"`
}
tests := []struct { tests := []struct {
name string name string
@ -72,6 +78,12 @@ func TestCoverFloat32(t *testing.T) {
A float32 `json:"a,string"` A float32 `json:"a,string"`
}{}, }{},
}, },
{
name: "HeadFloat32ZeroStringOmitEmpty",
data: struct {
A float32 `json:"a,string,omitempty"`
}{},
},
// HeadFloat32 // HeadFloat32
{ {
@ -92,6 +104,12 @@ func TestCoverFloat32(t *testing.T) {
A float32 `json:"a,string"` A float32 `json:"a,string"`
}{A: 1}, }{A: 1},
}, },
{
name: "HeadFloat32StringOmitEmpty",
data: struct {
A float32 `json:"a,string,omitempty"`
}{A: 1},
},
// HeadFloat32Ptr // HeadFloat32Ptr
{ {
@ -112,6 +130,12 @@ func TestCoverFloat32(t *testing.T) {
A *float32 `json:"a,string"` A *float32 `json:"a,string"`
}{A: float32ptr(1)}, }{A: float32ptr(1)},
}, },
{
name: "HeadFloat32PtrStringOmitEmpty",
data: struct {
A *float32 `json:"a,string,omitempty"`
}{A: float32ptr(1)},
},
// HeadFloat32PtrNil // HeadFloat32PtrNil
{ {
@ -132,6 +156,12 @@ func TestCoverFloat32(t *testing.T) {
A *float32 `json:"a,string"` A *float32 `json:"a,string"`
}{A: nil}, }{A: nil},
}, },
{
name: "HeadFloat32PtrNilStringOmitEmpty",
data: struct {
A *float32 `json:"a,string,omitempty"`
}{A: nil},
},
// PtrHeadFloat32Zero // PtrHeadFloat32Zero
{ {
@ -152,6 +182,12 @@ func TestCoverFloat32(t *testing.T) {
A float32 `json:"a,string"` A float32 `json:"a,string"`
}{}, }{},
}, },
{
name: "PtrHeadFloat32ZeroStringOmitEmpty",
data: &struct {
A float32 `json:"a,string,omitempty"`
}{},
},
// PtrHeadFloat32 // PtrHeadFloat32
{ {
@ -172,6 +208,12 @@ func TestCoverFloat32(t *testing.T) {
A float32 `json:"a,string"` A float32 `json:"a,string"`
}{A: 1}, }{A: 1},
}, },
{
name: "PtrHeadFloat32StringOmitEmpty",
data: &struct {
A float32 `json:"a,string,omitempty"`
}{A: 1},
},
// PtrHeadFloat32Ptr // PtrHeadFloat32Ptr
{ {
@ -192,6 +234,12 @@ func TestCoverFloat32(t *testing.T) {
A *float32 `json:"a,string"` A *float32 `json:"a,string"`
}{A: float32ptr(1)}, }{A: float32ptr(1)},
}, },
{
name: "PtrHeadFloat32PtrStringOmitEmpty",
data: &struct {
A *float32 `json:"a,string,omitempty"`
}{A: float32ptr(1)},
},
// PtrHeadFloat32PtrNil // PtrHeadFloat32PtrNil
{ {
@ -212,6 +260,12 @@ func TestCoverFloat32(t *testing.T) {
A *float32 `json:"a,string"` A *float32 `json:"a,string"`
}{A: nil}, }{A: nil},
}, },
{
name: "PtrHeadFloat32PtrNilStringOmitEmpty",
data: &struct {
A *float32 `json:"a,string,omitempty"`
}{A: nil},
},
// PtrHeadFloat32Nil // PtrHeadFloat32Nil
{ {
@ -232,6 +286,12 @@ func TestCoverFloat32(t *testing.T) {
A *float32 `json:"a,string"` A *float32 `json:"a,string"`
})(nil), })(nil),
}, },
{
name: "PtrHeadFloat32NilStringOmitEmpty",
data: (*struct {
A *float32 `json:"a,string,omitempty"`
})(nil),
},
// HeadFloat32ZeroMultiFields // HeadFloat32ZeroMultiFields
{ {
@ -251,13 +311,21 @@ func TestCoverFloat32(t *testing.T) {
}{}, }{},
}, },
{ {
name: "HeadFloat32ZeroMultiFields", name: "HeadFloat32ZeroMultiFieldsString",
data: struct { data: struct {
A float32 `json:"a,string"` A float32 `json:"a,string"`
B float32 `json:"b,string"` B float32 `json:"b,string"`
C float32 `json:"c,string"` C float32 `json:"c,string"`
}{}, }{},
}, },
{
name: "HeadFloat32ZeroMultiFieldsStringOmitEmpty",
data: struct {
A float32 `json:"a,string,omitempty"`
B float32 `json:"b,string,omitempty"`
C float32 `json:"c,string,omitempty"`
}{},
},
// HeadFloat32MultiFields // HeadFloat32MultiFields
{ {
@ -284,6 +352,14 @@ func TestCoverFloat32(t *testing.T) {
C float32 `json:"c,string"` C float32 `json:"c,string"`
}{A: 1, B: 2, C: 3}, }{A: 1, B: 2, C: 3},
}, },
{
name: "HeadFloat32MultiFieldsStringOmitEmpty",
data: struct {
A float32 `json:"a,string,omitempty"`
B float32 `json:"b,string,omitempty"`
C float32 `json:"c,string,omitempty"`
}{A: 1, B: 2, C: 3},
},
// HeadFloat32PtrMultiFields // HeadFloat32PtrMultiFields
{ {
@ -310,6 +386,14 @@ func TestCoverFloat32(t *testing.T) {
C *float32 `json:"c,string"` C *float32 `json:"c,string"`
}{A: float32ptr(1), B: float32ptr(2), C: float32ptr(3)}, }{A: float32ptr(1), B: float32ptr(2), C: float32ptr(3)},
}, },
{
name: "HeadFloat32PtrMultiFieldsStringOmitEmpty",
data: struct {
A *float32 `json:"a,string,omitempty"`
B *float32 `json:"b,string,omitempty"`
C *float32 `json:"c,string,omitempty"`
}{A: float32ptr(1), B: float32ptr(2), C: float32ptr(3)},
},
// HeadFloat32PtrNilMultiFields // HeadFloat32PtrNilMultiFields
{ {
@ -336,6 +420,14 @@ func TestCoverFloat32(t *testing.T) {
C *float32 `json:"c,string"` C *float32 `json:"c,string"`
}{A: nil, B: nil, C: nil}, }{A: nil, B: nil, C: nil},
}, },
{
name: "HeadFloat32PtrNilMultiFieldsStringOmitEmpty",
data: struct {
A *float32 `json:"a,string,omitempty"`
B *float32 `json:"b,string,omitempty"`
C *float32 `json:"c,string,omitempty"`
}{A: nil, B: nil, C: nil},
},
// PtrHeadFloat32ZeroMultiFields // PtrHeadFloat32ZeroMultiFields
{ {
@ -359,6 +451,13 @@ func TestCoverFloat32(t *testing.T) {
B float32 `json:"b,string"` B float32 `json:"b,string"`
}{}, }{},
}, },
{
name: "PtrHeadFloat32ZeroMultiFieldsStringOmitEmpty",
data: &struct {
A float32 `json:"a,string,omitempty"`
B float32 `json:"b,string,omitempty"`
}{},
},
// PtrHeadFloat32MultiFields // PtrHeadFloat32MultiFields
{ {
@ -382,6 +481,13 @@ func TestCoverFloat32(t *testing.T) {
B float32 `json:"b,string"` B float32 `json:"b,string"`
}{A: 1, B: 2}, }{A: 1, B: 2},
}, },
{
name: "PtrHeadFloat32MultiFieldsStringOmitEmpty",
data: &struct {
A float32 `json:"a,string,omitempty"`
B float32 `json:"b,string,omitempty"`
}{A: 1, B: 2},
},
// PtrHeadFloat32PtrMultiFields // PtrHeadFloat32PtrMultiFields
{ {
@ -405,6 +511,13 @@ func TestCoverFloat32(t *testing.T) {
B *float32 `json:"b,string"` B *float32 `json:"b,string"`
}{A: float32ptr(1), B: float32ptr(2)}, }{A: float32ptr(1), B: float32ptr(2)},
}, },
{
name: "PtrHeadFloat32PtrMultiFieldsStringOmitEmpty",
data: &struct {
A *float32 `json:"a,string,omitempty"`
B *float32 `json:"b,string,omitempty"`
}{A: float32ptr(1), B: float32ptr(2)},
},
// PtrHeadFloat32PtrNilMultiFields // PtrHeadFloat32PtrNilMultiFields
{ {
@ -428,6 +541,13 @@ func TestCoverFloat32(t *testing.T) {
B *float32 `json:"b,string"` B *float32 `json:"b,string"`
}{A: nil, B: nil}, }{A: nil, B: nil},
}, },
{
name: "PtrHeadFloat32PtrNilMultiFieldsStringOmitEmpty",
data: &struct {
A *float32 `json:"a,string,omitempty"`
B *float32 `json:"b,string,omitempty"`
}{A: nil, B: nil},
},
// PtrHeadFloat32NilMultiFields // PtrHeadFloat32NilMultiFields
{ {
@ -451,6 +571,13 @@ func TestCoverFloat32(t *testing.T) {
B *float32 `json:"b,string"` B *float32 `json:"b,string"`
})(nil), })(nil),
}, },
{
name: "PtrHeadFloat32NilMultiFieldsStringOmitEmpty",
data: (*struct {
A *float32 `json:"a,string,omitempty"`
B *float32 `json:"b,string,omitempty"`
})(nil),
},
// HeadFloat32ZeroNotRoot // HeadFloat32ZeroNotRoot
{ {
@ -477,6 +604,14 @@ func TestCoverFloat32(t *testing.T) {
} }
}{}, }{},
}, },
{
name: "HeadFloat32ZeroNotRootStringOmitEmpty",
data: struct {
A struct {
A float32 `json:"a,string,omitempty"`
}
}{},
},
// HeadFloat32NotRoot // HeadFloat32NotRoot
{ {
@ -509,6 +644,16 @@ func TestCoverFloat32(t *testing.T) {
A float32 `json:"a,string"` A float32 `json:"a,string"`
}{A: 1}}, }{A: 1}},
}, },
{
name: "HeadFloat32NotRootStringOmitEmpty",
data: struct {
A struct {
A float32 `json:"a,string,omitempty"`
}
}{A: struct {
A float32 `json:"a,string,omitempty"`
}{A: 1}},
},
// HeadFloat32PtrNotRoot // HeadFloat32PtrNotRoot
{ {
@ -541,6 +686,16 @@ func TestCoverFloat32(t *testing.T) {
A *float32 `json:"a,string"` A *float32 `json:"a,string"`
}{float32ptr(1)}}, }{float32ptr(1)}},
}, },
{
name: "HeadFloat32PtrNotRootStringOmitEmpty",
data: struct {
A struct {
A *float32 `json:"a,string,omitempty"`
}
}{A: struct {
A *float32 `json:"a,string,omitempty"`
}{float32ptr(1)}},
},
// HeadFloat32PtrNilNotRoot // HeadFloat32PtrNilNotRoot
{ {
@ -567,6 +722,14 @@ func TestCoverFloat32(t *testing.T) {
} }
}{}, }{},
}, },
{
name: "HeadFloat32PtrNilNotRootStringOmitEmpty",
data: struct {
A struct {
A *float32 `json:"a,string,omitempty"`
}
}{},
},
// PtrHeadFloat32ZeroNotRoot // PtrHeadFloat32ZeroNotRoot
{ {
@ -599,6 +762,16 @@ func TestCoverFloat32(t *testing.T) {
A float32 `json:"a,string"` A float32 `json:"a,string"`
})}, })},
}, },
{
name: "PtrHeadFloat32ZeroNotRootStringOmitEmpty",
data: struct {
A *struct {
A float32 `json:"a,string,omitempty"`
}
}{A: new(struct {
A float32 `json:"a,string,omitempty"`
})},
},
// PtrHeadFloat32NotRoot // PtrHeadFloat32NotRoot
{ {
@ -631,6 +804,16 @@ func TestCoverFloat32(t *testing.T) {
A float32 `json:"a,string"` A float32 `json:"a,string"`
}{A: 1})}, }{A: 1})},
}, },
{
name: "PtrHeadFloat32NotRootStringOmitEmpty",
data: struct {
A *struct {
A float32 `json:"a,string,omitempty"`
}
}{A: &(struct {
A float32 `json:"a,string,omitempty"`
}{A: 1})},
},
// PtrHeadFloat32PtrNotRoot // PtrHeadFloat32PtrNotRoot
{ {
@ -663,6 +846,16 @@ func TestCoverFloat32(t *testing.T) {
A *float32 `json:"a,string"` A *float32 `json:"a,string"`
}{A: float32ptr(1)})}, }{A: float32ptr(1)})},
}, },
{
name: "PtrHeadFloat32PtrNotRootStringOmitEmpty",
data: struct {
A *struct {
A *float32 `json:"a,string,omitempty"`
}
}{A: &(struct {
A *float32 `json:"a,string,omitempty"`
}{A: float32ptr(1)})},
},
// PtrHeadFloat32PtrNilNotRoot // PtrHeadFloat32PtrNilNotRoot
{ {
@ -695,6 +888,16 @@ func TestCoverFloat32(t *testing.T) {
A *float32 `json:"a,string"` A *float32 `json:"a,string"`
}{A: nil})}, }{A: nil})},
}, },
{
name: "PtrHeadFloat32PtrNilNotRootStringOmitEmpty",
data: struct {
A *struct {
A *float32 `json:"a,string,omitempty"`
}
}{A: &(struct {
A *float32 `json:"a,string,omitempty"`
}{A: nil})},
},
// PtrHeadFloat32NilNotRoot // PtrHeadFloat32NilNotRoot
{ {
@ -721,6 +924,14 @@ func TestCoverFloat32(t *testing.T) {
} `json:",string"` } `json:",string"`
}{A: nil}, }{A: nil},
}, },
{
name: "PtrHeadFloat32NilNotRootStringOmitEmpty",
data: struct {
A *struct {
A *float32 `json:"a,string,omitempty"`
} `json:",string,omitempty"`
}{A: nil},
},
// HeadFloat32ZeroMultiFieldsNotRoot // HeadFloat32ZeroMultiFieldsNotRoot
{ {
@ -756,6 +967,17 @@ func TestCoverFloat32(t *testing.T) {
} }
}{}, }{},
}, },
{
name: "HeadFloat32ZeroMultiFieldsNotRootStringOmitEmpty",
data: struct {
A struct {
A float32 `json:"a,string,omitempty"`
}
B struct {
B float32 `json:"b,string,omitempty"`
}
}{},
},
// HeadFloat32MultiFieldsNotRoot // HeadFloat32MultiFieldsNotRoot
{ {
@ -803,6 +1025,21 @@ func TestCoverFloat32(t *testing.T) {
B float32 `json:"b,string"` B float32 `json:"b,string"`
}{B: 2}}, }{B: 2}},
}, },
{
name: "HeadFloat32MultiFieldsNotRootStringOmitEmpty",
data: struct {
A struct {
A float32 `json:"a,string,omitempty"`
}
B struct {
B float32 `json:"b,string,omitempty"`
}
}{A: struct {
A float32 `json:"a,string,omitempty"`
}{A: 1}, B: struct {
B float32 `json:"b,string,omitempty"`
}{B: 2}},
},
// HeadFloat32PtrMultiFieldsNotRoot // HeadFloat32PtrMultiFieldsNotRoot
{ {
@ -850,6 +1087,21 @@ func TestCoverFloat32(t *testing.T) {
B *float32 `json:"b,string"` B *float32 `json:"b,string"`
}{B: float32ptr(2)}}, }{B: float32ptr(2)}},
}, },
{
name: "HeadFloat32PtrMultiFieldsNotRootStringOmitEmpty",
data: struct {
A struct {
A *float32 `json:"a,string,omitempty"`
}
B struct {
B *float32 `json:"b,string,omitempty"`
}
}{A: struct {
A *float32 `json:"a,string,omitempty"`
}{A: float32ptr(1)}, B: struct {
B *float32 `json:"b,string,omitempty"`
}{B: float32ptr(2)}},
},
// HeadFloat32PtrNilMultiFieldsNotRoot // HeadFloat32PtrNilMultiFieldsNotRoot
{ {
@ -897,6 +1149,21 @@ func TestCoverFloat32(t *testing.T) {
B *float32 `json:"b,string"` B *float32 `json:"b,string"`
}{B: nil}}, }{B: nil}},
}, },
{
name: "HeadFloat32PtrNilMultiFieldsNotRootStringOmitEmpty",
data: struct {
A struct {
A *float32 `json:"a,string,omitempty"`
}
B struct {
B *float32 `json:"b,string,omitempty"`
}
}{A: struct {
A *float32 `json:"a,string,omitempty"`
}{A: nil}, B: struct {
B *float32 `json:"b,string,omitempty"`
}{B: nil}},
},
// PtrHeadFloat32ZeroMultiFieldsNotRoot // PtrHeadFloat32ZeroMultiFieldsNotRoot
{ {
@ -932,6 +1199,17 @@ func TestCoverFloat32(t *testing.T) {
} }
}{}, }{},
}, },
{
name: "PtrHeadFloat32ZeroMultiFieldsNotRootStringOmitEmpty",
data: &struct {
A struct {
A float32 `json:"a,string,omitempty"`
}
B struct {
B float32 `json:"b,string,omitempty"`
}
}{},
},
// PtrHeadFloat32MultiFieldsNotRoot // PtrHeadFloat32MultiFieldsNotRoot
{ {
@ -979,6 +1257,21 @@ func TestCoverFloat32(t *testing.T) {
B float32 `json:"b,string"` B float32 `json:"b,string"`
}{B: 2}}, }{B: 2}},
}, },
{
name: "PtrHeadFloat32MultiFieldsNotRootStringOmitEmpty",
data: &struct {
A struct {
A float32 `json:"a,string,omitempty"`
}
B struct {
B float32 `json:"b,string,omitempty"`
}
}{A: struct {
A float32 `json:"a,string,omitempty"`
}{A: 1}, B: struct {
B float32 `json:"b,string,omitempty"`
}{B: 2}},
},
// PtrHeadFloat32PtrMultiFieldsNotRoot // PtrHeadFloat32PtrMultiFieldsNotRoot
{ {
@ -1026,6 +1319,21 @@ func TestCoverFloat32(t *testing.T) {
B *float32 `json:"b,string"` B *float32 `json:"b,string"`
}{B: float32ptr(2)})}, }{B: float32ptr(2)})},
}, },
{
name: "PtrHeadFloat32PtrMultiFieldsNotRootStringOmitEmpty",
data: &struct {
A *struct {
A *float32 `json:"a,string,omitempty"`
}
B *struct {
B *float32 `json:"b,string,omitempty"`
}
}{A: &(struct {
A *float32 `json:"a,string,omitempty"`
}{A: float32ptr(1)}), B: &(struct {
B *float32 `json:"b,string,omitempty"`
}{B: float32ptr(2)})},
},
// PtrHeadFloat32PtrNilMultiFieldsNotRoot // PtrHeadFloat32PtrNilMultiFieldsNotRoot
{ {
@ -1061,6 +1369,17 @@ func TestCoverFloat32(t *testing.T) {
} `json:",string"` } `json:",string"`
}{A: nil, B: nil}, }{A: nil, B: nil},
}, },
{
name: "PtrHeadFloat32PtrNilMultiFieldsNotRootStringOmitEmpty",
data: &struct {
A *struct {
A *float32 `json:"a,string,omitempty"`
} `json:",string,omitempty"`
B *struct {
B *float32 `json:"b,string,omitempty"`
} `json:",string,omitempty"`
}{A: nil, B: nil},
},
// PtrHeadFloat32NilMultiFieldsNotRoot // PtrHeadFloat32NilMultiFieldsNotRoot
{ {
@ -1096,6 +1415,17 @@ func TestCoverFloat32(t *testing.T) {
} }
})(nil), })(nil),
}, },
{
name: "PtrHeadFloat32NilMultiFieldsNotRootStringOmitEmpty",
data: (*struct {
A *struct {
A *float32 `json:"a,string,omitempty"`
}
B *struct {
B *float32 `json:"b,string,omitempty"`
}
})(nil),
},
// PtrHeadFloat32DoubleMultiFieldsNotRoot // PtrHeadFloat32DoubleMultiFieldsNotRoot
{ {
@ -1155,6 +1485,25 @@ func TestCoverFloat32(t *testing.T) {
B float32 `json:"b,string"` B float32 `json:"b,string"`
}{A: 3, B: 4})}, }{A: 3, B: 4})},
}, },
{
name: "PtrHeadFloat32DoubleMultiFieldsNotRootStringOmitEmpty",
data: &struct {
A *struct {
A float32 `json:"a,string,omitempty"`
B float32 `json:"b,string,omitempty"`
}
B *struct {
A float32 `json:"a,string,omitempty"`
B float32 `json:"b,string,omitempty"`
}
}{A: &(struct {
A float32 `json:"a,string,omitempty"`
B float32 `json:"b,string,omitempty"`
}{A: 1, B: 2}), B: &(struct {
A float32 `json:"a,string,omitempty"`
B float32 `json:"b,string,omitempty"`
}{A: 3, B: 4})},
},
// PtrHeadFloat32NilDoubleMultiFieldsNotRoot // PtrHeadFloat32NilDoubleMultiFieldsNotRoot
{ {
@ -1196,6 +1545,19 @@ func TestCoverFloat32(t *testing.T) {
} }
}{A: nil, B: nil}, }{A: nil, B: nil},
}, },
{
name: "PtrHeadFloat32NilDoubleMultiFieldsNotRootStringOmitEmpty",
data: &struct {
A *struct {
A float32 `json:"a,string,omitempty"`
B float32 `json:"b,string,omitempty"`
}
B *struct {
A float32 `json:"a,string,omitempty"`
B float32 `json:"b,string,omitempty"`
}
}{A: nil, B: nil},
},
// PtrHeadFloat32NilDoubleMultiFieldsNotRoot // PtrHeadFloat32NilDoubleMultiFieldsNotRoot
{ {
@ -1237,6 +1599,19 @@ func TestCoverFloat32(t *testing.T) {
} }
})(nil), })(nil),
}, },
{
name: "PtrHeadFloat32NilDoubleMultiFieldsNotRootStringOmitEmpty",
data: (*struct {
A *struct {
A float32 `json:"a,string,omitempty"`
B float32 `json:"b,string,omitempty"`
}
B *struct {
A float32 `json:"a,string,omitempty"`
B float32 `json:"b,string,omitempty"`
}
})(nil),
},
// PtrHeadFloat32PtrDoubleMultiFieldsNotRoot // PtrHeadFloat32PtrDoubleMultiFieldsNotRoot
{ {
@ -1296,6 +1671,25 @@ func TestCoverFloat32(t *testing.T) {
B *float32 `json:"b,string"` B *float32 `json:"b,string"`
}{A: float32ptr(3), B: float32ptr(4)})}, }{A: float32ptr(3), B: float32ptr(4)})},
}, },
{
name: "PtrHeadFloat32PtrDoubleMultiFieldsNotRootStringOmitEmpty",
data: &struct {
A *struct {
A *float32 `json:"a,string,omitempty"`
B *float32 `json:"b,string,omitempty"`
}
B *struct {
A *float32 `json:"a,string,omitempty"`
B *float32 `json:"b,string,omitempty"`
}
}{A: &(struct {
A *float32 `json:"a,string,omitempty"`
B *float32 `json:"b,string,omitempty"`
}{A: float32ptr(1), B: float32ptr(2)}), B: &(struct {
A *float32 `json:"a,string,omitempty"`
B *float32 `json:"b,string,omitempty"`
}{A: float32ptr(3), B: float32ptr(4)})},
},
// PtrHeadFloat32PtrNilDoubleMultiFieldsNotRoot // PtrHeadFloat32PtrNilDoubleMultiFieldsNotRoot
{ {
@ -1337,6 +1731,19 @@ func TestCoverFloat32(t *testing.T) {
} }
}{A: nil, B: nil}, }{A: nil, B: nil},
}, },
{
name: "PtrHeadFloat32PtrNilDoubleMultiFieldsNotRootStringOmitEmpty",
data: &struct {
A *struct {
A *float32 `json:"a,string,omitempty"`
B *float32 `json:"b,string,omitempty"`
}
B *struct {
A *float32 `json:"a,string,omitempty"`
B *float32 `json:"b,string,omitempty"`
}
}{A: nil, B: nil},
},
// PtrHeadFloat32PtrNilDoubleMultiFieldsNotRoot // PtrHeadFloat32PtrNilDoubleMultiFieldsNotRoot
{ {
@ -1378,6 +1785,19 @@ func TestCoverFloat32(t *testing.T) {
} }
})(nil), })(nil),
}, },
{
name: "PtrHeadFloat32PtrNilDoubleMultiFieldsNotRootStringOmitEmpty",
data: (*struct {
A *struct {
A *float32 `json:"a,string,omitempty"`
B *float32 `json:"b,string,omitempty"`
}
B *struct {
A *float32 `json:"a,string,omitempty"`
B *float32 `json:"b,string,omitempty"`
}
})(nil),
},
// AnonymousHeadFloat32 // AnonymousHeadFloat32
{ {
@ -1410,6 +1830,16 @@ func TestCoverFloat32(t *testing.T) {
B: 2, B: 2,
}, },
}, },
{
name: "AnonymousHeadFloat32StringOmitEmpty",
data: struct {
structFloat32StringOmitEmpty
B float32 `json:"b,string,omitempty"`
}{
structFloat32StringOmitEmpty: structFloat32StringOmitEmpty{A: 1},
B: 2,
},
},
// PtrAnonymousHeadFloat32 // PtrAnonymousHeadFloat32
{ {
@ -1442,6 +1872,16 @@ func TestCoverFloat32(t *testing.T) {
B: 2, B: 2,
}, },
}, },
{
name: "PtrAnonymousHeadFloat32StringOmitEmpty",
data: struct {
*structFloat32StringOmitEmpty
B float32 `json:"b,string,omitempty"`
}{
structFloat32StringOmitEmpty: &structFloat32StringOmitEmpty{A: 1},
B: 2,
},
},
// NilPtrAnonymousHeadFloat32 // NilPtrAnonymousHeadFloat32
{ {
@ -1474,6 +1914,16 @@ func TestCoverFloat32(t *testing.T) {
B: 2, B: 2,
}, },
}, },
{
name: "NilPtrAnonymousHeadFloat32StringOmitEmpty",
data: struct {
*structFloat32StringOmitEmpty
B float32 `json:"b,string,omitempty"`
}{
structFloat32StringOmitEmpty: nil,
B: 2,
},
},
// AnonymousHeadFloat32Ptr // AnonymousHeadFloat32Ptr
{ {
@ -1506,6 +1956,16 @@ func TestCoverFloat32(t *testing.T) {
B: float32ptr(2), B: float32ptr(2),
}, },
}, },
{
name: "AnonymousHeadFloat32PtrStringOmitEmpty",
data: struct {
structFloat32PtrStringOmitEmpty
B *float32 `json:"b,string,omitempty"`
}{
structFloat32PtrStringOmitEmpty: structFloat32PtrStringOmitEmpty{A: float32ptr(1)},
B: float32ptr(2),
},
},
// AnonymousHeadFloat32PtrNil // AnonymousHeadFloat32PtrNil
{ {
@ -1538,6 +1998,16 @@ func TestCoverFloat32(t *testing.T) {
B: float32ptr(2), B: float32ptr(2),
}, },
}, },
{
name: "AnonymousHeadFloat32PtrNilStringOmitEmpty",
data: struct {
structFloat32PtrStringOmitEmpty
B *float32 `json:"b,string,omitempty"`
}{
structFloat32PtrStringOmitEmpty: structFloat32PtrStringOmitEmpty{A: nil},
B: float32ptr(2),
},
},
// PtrAnonymousHeadFloat32Ptr // PtrAnonymousHeadFloat32Ptr
{ {
@ -1570,6 +2040,16 @@ func TestCoverFloat32(t *testing.T) {
B: float32ptr(2), B: float32ptr(2),
}, },
}, },
{
name: "PtrAnonymousHeadFloat32PtrStringOmitEmpty",
data: struct {
*structFloat32PtrStringOmitEmpty
B *float32 `json:"b,string,omitempty"`
}{
structFloat32PtrStringOmitEmpty: &structFloat32PtrStringOmitEmpty{A: float32ptr(1)},
B: float32ptr(2),
},
},
// NilPtrAnonymousHeadFloat32Ptr // NilPtrAnonymousHeadFloat32Ptr
{ {
@ -1602,6 +2082,16 @@ func TestCoverFloat32(t *testing.T) {
B: float32ptr(2), B: float32ptr(2),
}, },
}, },
{
name: "NilPtrAnonymousHeadFloat32PtrStringOmitEmpty",
data: struct {
*structFloat32PtrStringOmitEmpty
B *float32 `json:"b,string,omitempty"`
}{
structFloat32PtrStringOmitEmpty: nil,
B: float32ptr(2),
},
},
// AnonymousHeadFloat32Only // AnonymousHeadFloat32Only
{ {
@ -1628,6 +2118,14 @@ func TestCoverFloat32(t *testing.T) {
structFloat32String: structFloat32String{A: 1}, structFloat32String: structFloat32String{A: 1},
}, },
}, },
{
name: "AnonymousHeadFloat32OnlyStringOmitEmpty",
data: struct {
structFloat32StringOmitEmpty
}{
structFloat32StringOmitEmpty: structFloat32StringOmitEmpty{A: 1},
},
},
// PtrAnonymousHeadFloat32Only // PtrAnonymousHeadFloat32Only
{ {
@ -1654,6 +2152,14 @@ func TestCoverFloat32(t *testing.T) {
structFloat32String: &structFloat32String{A: 1}, structFloat32String: &structFloat32String{A: 1},
}, },
}, },
{
name: "PtrAnonymousHeadFloat32OnlyStringOmitEmpty",
data: struct {
*structFloat32StringOmitEmpty
}{
structFloat32StringOmitEmpty: &structFloat32StringOmitEmpty{A: 1},
},
},
// NilPtrAnonymousHeadFloat32Only // NilPtrAnonymousHeadFloat32Only
{ {
@ -1680,6 +2186,14 @@ func TestCoverFloat32(t *testing.T) {
structFloat32String: nil, structFloat32String: nil,
}, },
}, },
{
name: "NilPtrAnonymousHeadFloat32OnlyStringOmitEmpty",
data: struct {
*structFloat32StringOmitEmpty
}{
structFloat32StringOmitEmpty: nil,
},
},
// AnonymousHeadFloat32PtrOnly // AnonymousHeadFloat32PtrOnly
{ {
@ -1706,6 +2220,14 @@ func TestCoverFloat32(t *testing.T) {
structFloat32PtrString: structFloat32PtrString{A: float32ptr(1)}, structFloat32PtrString: structFloat32PtrString{A: float32ptr(1)},
}, },
}, },
{
name: "AnonymousHeadFloat32PtrOnlyStringOmitEmpty",
data: struct {
structFloat32PtrStringOmitEmpty
}{
structFloat32PtrStringOmitEmpty: structFloat32PtrStringOmitEmpty{A: float32ptr(1)},
},
},
// AnonymousHeadFloat32PtrNilOnly // AnonymousHeadFloat32PtrNilOnly
{ {
@ -1732,6 +2254,14 @@ func TestCoverFloat32(t *testing.T) {
structFloat32PtrString: structFloat32PtrString{A: nil}, structFloat32PtrString: structFloat32PtrString{A: nil},
}, },
}, },
{
name: "AnonymousHeadFloat32PtrNilOnlyStringOmitEmpty",
data: struct {
structFloat32PtrStringOmitEmpty
}{
structFloat32PtrStringOmitEmpty: structFloat32PtrStringOmitEmpty{A: nil},
},
},
// PtrAnonymousHeadFloat32PtrOnly // PtrAnonymousHeadFloat32PtrOnly
{ {
@ -1758,6 +2288,14 @@ func TestCoverFloat32(t *testing.T) {
structFloat32PtrString: &structFloat32PtrString{A: float32ptr(1)}, structFloat32PtrString: &structFloat32PtrString{A: float32ptr(1)},
}, },
}, },
{
name: "PtrAnonymousHeadFloat32PtrOnlyStringOmitEmpty",
data: struct {
*structFloat32PtrStringOmitEmpty
}{
structFloat32PtrStringOmitEmpty: &structFloat32PtrStringOmitEmpty{A: float32ptr(1)},
},
},
// NilPtrAnonymousHeadFloat32PtrOnly // NilPtrAnonymousHeadFloat32PtrOnly
{ {
@ -1784,6 +2322,14 @@ func TestCoverFloat32(t *testing.T) {
structFloat32PtrString: nil, structFloat32PtrString: nil,
}, },
}, },
{
name: "NilPtrAnonymousHeadFloat32PtrOnlyStringOmitEmpty",
data: struct {
*structFloat32PtrStringOmitEmpty
}{
structFloat32PtrStringOmitEmpty: nil,
},
},
} }
for _, test := range tests { for _, test := range tests {
for _, indent := range []bool{true, false} { for _, indent := range []bool{true, false} {

View File

@ -17,6 +17,9 @@ func TestCoverFloat64(t *testing.T) {
type structFloat64String struct { type structFloat64String struct {
A float64 `json:"a,string"` A float64 `json:"a,string"`
} }
type structFloat64StringOmitEmpty struct {
A float64 `json:"a,string,omitempty"`
}
type structFloat64Ptr struct { type structFloat64Ptr struct {
A *float64 `json:"a"` A *float64 `json:"a"`
@ -27,6 +30,9 @@ func TestCoverFloat64(t *testing.T) {
type structFloat64PtrString struct { type structFloat64PtrString struct {
A *float64 `json:"a,string"` A *float64 `json:"a,string"`
} }
type structFloat64PtrStringOmitEmpty struct {
A *float64 `json:"a,string,omitempty"`
}
tests := []struct { tests := []struct {
name string name string
@ -72,6 +78,12 @@ func TestCoverFloat64(t *testing.T) {
A float64 `json:"a,string"` A float64 `json:"a,string"`
}{}, }{},
}, },
{
name: "HeadFloat64ZeroStringOmitEmpty",
data: struct {
A float64 `json:"a,string,omitempty"`
}{},
},
// HeadFloat64 // HeadFloat64
{ {
@ -92,6 +104,12 @@ func TestCoverFloat64(t *testing.T) {
A float64 `json:"a,string"` A float64 `json:"a,string"`
}{A: 1}, }{A: 1},
}, },
{
name: "HeadFloat64StringOmitEmpty",
data: struct {
A float64 `json:"a,string,omitempty"`
}{A: 1},
},
// HeadFloat64Ptr // HeadFloat64Ptr
{ {
@ -112,6 +130,12 @@ func TestCoverFloat64(t *testing.T) {
A *float64 `json:"a,string"` A *float64 `json:"a,string"`
}{A: float64ptr(1)}, }{A: float64ptr(1)},
}, },
{
name: "HeadFloat64PtrStringOmitEmpty",
data: struct {
A *float64 `json:"a,string,omitempty"`
}{A: float64ptr(1)},
},
// HeadFloat64PtrNil // HeadFloat64PtrNil
{ {
@ -132,6 +156,12 @@ func TestCoverFloat64(t *testing.T) {
A *float64 `json:"a,string"` A *float64 `json:"a,string"`
}{A: nil}, }{A: nil},
}, },
{
name: "HeadFloat64PtrNilStringOmitEmpty",
data: struct {
A *float64 `json:"a,string,omitempty"`
}{A: nil},
},
// PtrHeadFloat64Zero // PtrHeadFloat64Zero
{ {
@ -152,6 +182,12 @@ func TestCoverFloat64(t *testing.T) {
A float64 `json:"a,string"` A float64 `json:"a,string"`
}{}, }{},
}, },
{
name: "PtrHeadFloat64ZeroStringOmitEmpty",
data: &struct {
A float64 `json:"a,string,omitempty"`
}{},
},
// PtrHeadFloat64 // PtrHeadFloat64
{ {
@ -172,6 +208,12 @@ func TestCoverFloat64(t *testing.T) {
A float64 `json:"a,string"` A float64 `json:"a,string"`
}{A: 1}, }{A: 1},
}, },
{
name: "PtrHeadFloat64StringOmitEmpty",
data: &struct {
A float64 `json:"a,string,omitempty"`
}{A: 1},
},
// PtrHeadFloat64Ptr // PtrHeadFloat64Ptr
{ {
@ -192,6 +234,12 @@ func TestCoverFloat64(t *testing.T) {
A *float64 `json:"a,string"` A *float64 `json:"a,string"`
}{A: float64ptr(1)}, }{A: float64ptr(1)},
}, },
{
name: "PtrHeadFloat64PtrStringOmitEmpty",
data: &struct {
A *float64 `json:"a,string,omitempty"`
}{A: float64ptr(1)},
},
// PtrHeadFloat64PtrNil // PtrHeadFloat64PtrNil
{ {
@ -212,6 +260,12 @@ func TestCoverFloat64(t *testing.T) {
A *float64 `json:"a,string"` A *float64 `json:"a,string"`
}{A: nil}, }{A: nil},
}, },
{
name: "PtrHeadFloat64PtrNilStringOmitEmpty",
data: &struct {
A *float64 `json:"a,string,omitempty"`
}{A: nil},
},
// PtrHeadFloat64Nil // PtrHeadFloat64Nil
{ {
@ -232,6 +286,12 @@ func TestCoverFloat64(t *testing.T) {
A *float64 `json:"a,string"` A *float64 `json:"a,string"`
})(nil), })(nil),
}, },
{
name: "PtrHeadFloat64NilStringOmitEmpty",
data: (*struct {
A *float64 `json:"a,string,omitempty"`
})(nil),
},
// HeadFloat64ZeroMultiFields // HeadFloat64ZeroMultiFields
{ {
@ -251,13 +311,21 @@ func TestCoverFloat64(t *testing.T) {
}{}, }{},
}, },
{ {
name: "HeadFloat64ZeroMultiFields", name: "HeadFloat64ZeroMultiFieldsString",
data: struct { data: struct {
A float64 `json:"a,string"` A float64 `json:"a,string"`
B float64 `json:"b,string"` B float64 `json:"b,string"`
C float64 `json:"c,string"` C float64 `json:"c,string"`
}{}, }{},
}, },
{
name: "HeadFloat64ZeroMultiFieldsStringOmitEmpty",
data: struct {
A float64 `json:"a,string,omitempty"`
B float64 `json:"b,string,omitempty"`
C float64 `json:"c,string,omitempty"`
}{},
},
// HeadFloat64MultiFields // HeadFloat64MultiFields
{ {
@ -284,6 +352,14 @@ func TestCoverFloat64(t *testing.T) {
C float64 `json:"c,string"` C float64 `json:"c,string"`
}{A: 1, B: 2, C: 3}, }{A: 1, B: 2, C: 3},
}, },
{
name: "HeadFloat64MultiFieldsStringOmitEmpty",
data: struct {
A float64 `json:"a,string,omitempty"`
B float64 `json:"b,string,omitempty"`
C float64 `json:"c,string,omitempty"`
}{A: 1, B: 2, C: 3},
},
// HeadFloat64PtrMultiFields // HeadFloat64PtrMultiFields
{ {
@ -310,6 +386,14 @@ func TestCoverFloat64(t *testing.T) {
C *float64 `json:"c,string"` C *float64 `json:"c,string"`
}{A: float64ptr(1), B: float64ptr(2), C: float64ptr(3)}, }{A: float64ptr(1), B: float64ptr(2), C: float64ptr(3)},
}, },
{
name: "HeadFloat64PtrMultiFieldsStringOmitEmpty",
data: struct {
A *float64 `json:"a,string,omitempty"`
B *float64 `json:"b,string,omitempty"`
C *float64 `json:"c,string,omitempty"`
}{A: float64ptr(1), B: float64ptr(2), C: float64ptr(3)},
},
// HeadFloat64PtrNilMultiFields // HeadFloat64PtrNilMultiFields
{ {
@ -336,6 +420,14 @@ func TestCoverFloat64(t *testing.T) {
C *float64 `json:"c,string"` C *float64 `json:"c,string"`
}{A: nil, B: nil, C: nil}, }{A: nil, B: nil, C: nil},
}, },
{
name: "HeadFloat64PtrNilMultiFieldsStringOmitEmpty",
data: struct {
A *float64 `json:"a,string,omitempty"`
B *float64 `json:"b,string,omitempty"`
C *float64 `json:"c,string,omitempty"`
}{A: nil, B: nil, C: nil},
},
// PtrHeadFloat64ZeroMultiFields // PtrHeadFloat64ZeroMultiFields
{ {
@ -359,6 +451,13 @@ func TestCoverFloat64(t *testing.T) {
B float64 `json:"b,string"` B float64 `json:"b,string"`
}{}, }{},
}, },
{
name: "PtrHeadFloat64ZeroMultiFieldsStringOmitEmpty",
data: &struct {
A float64 `json:"a,string,omitempty"`
B float64 `json:"b,string,omitempty"`
}{},
},
// PtrHeadFloat64MultiFields // PtrHeadFloat64MultiFields
{ {
@ -382,6 +481,13 @@ func TestCoverFloat64(t *testing.T) {
B float64 `json:"b,string"` B float64 `json:"b,string"`
}{A: 1, B: 2}, }{A: 1, B: 2},
}, },
{
name: "PtrHeadFloat64MultiFieldsStringOmitEmpty",
data: &struct {
A float64 `json:"a,string,omitempty"`
B float64 `json:"b,string,omitempty"`
}{A: 1, B: 2},
},
// PtrHeadFloat64PtrMultiFields // PtrHeadFloat64PtrMultiFields
{ {
@ -405,6 +511,13 @@ func TestCoverFloat64(t *testing.T) {
B *float64 `json:"b,string"` B *float64 `json:"b,string"`
}{A: float64ptr(1), B: float64ptr(2)}, }{A: float64ptr(1), B: float64ptr(2)},
}, },
{
name: "PtrHeadFloat64PtrMultiFieldsStringOmitEmpty",
data: &struct {
A *float64 `json:"a,string,omitempty"`
B *float64 `json:"b,string,omitempty"`
}{A: float64ptr(1), B: float64ptr(2)},
},
// PtrHeadFloat64PtrNilMultiFields // PtrHeadFloat64PtrNilMultiFields
{ {
@ -428,6 +541,13 @@ func TestCoverFloat64(t *testing.T) {
B *float64 `json:"b,string"` B *float64 `json:"b,string"`
}{A: nil, B: nil}, }{A: nil, B: nil},
}, },
{
name: "PtrHeadFloat64PtrNilMultiFieldsStringOmitEmpty",
data: &struct {
A *float64 `json:"a,string,omitempty"`
B *float64 `json:"b,string,omitempty"`
}{A: nil, B: nil},
},
// PtrHeadFloat64NilMultiFields // PtrHeadFloat64NilMultiFields
{ {
@ -451,6 +571,13 @@ func TestCoverFloat64(t *testing.T) {
B *float64 `json:"b,string"` B *float64 `json:"b,string"`
})(nil), })(nil),
}, },
{
name: "PtrHeadFloat64NilMultiFieldsStringOmitEmpty",
data: (*struct {
A *float64 `json:"a,string,omitempty"`
B *float64 `json:"b,string,omitempty"`
})(nil),
},
// HeadFloat64ZeroNotRoot // HeadFloat64ZeroNotRoot
{ {
@ -477,6 +604,14 @@ func TestCoverFloat64(t *testing.T) {
} }
}{}, }{},
}, },
{
name: "HeadFloat64ZeroNotRootStringOmitEmpty",
data: struct {
A struct {
A float64 `json:"a,string,omitempty"`
}
}{},
},
// HeadFloat64NotRoot // HeadFloat64NotRoot
{ {
@ -509,6 +644,16 @@ func TestCoverFloat64(t *testing.T) {
A float64 `json:"a,string"` A float64 `json:"a,string"`
}{A: 1}}, }{A: 1}},
}, },
{
name: "HeadFloat64NotRootStringOmitEmpty",
data: struct {
A struct {
A float64 `json:"a,string,omitempty"`
}
}{A: struct {
A float64 `json:"a,string,omitempty"`
}{A: 1}},
},
// HeadFloat64PtrNotRoot // HeadFloat64PtrNotRoot
{ {
@ -541,6 +686,16 @@ func TestCoverFloat64(t *testing.T) {
A *float64 `json:"a,string"` A *float64 `json:"a,string"`
}{float64ptr(1)}}, }{float64ptr(1)}},
}, },
{
name: "HeadFloat64PtrNotRootStringOmitEmpty",
data: struct {
A struct {
A *float64 `json:"a,string,omitempty"`
}
}{A: struct {
A *float64 `json:"a,string,omitempty"`
}{float64ptr(1)}},
},
// HeadFloat64PtrNilNotRoot // HeadFloat64PtrNilNotRoot
{ {
@ -567,6 +722,14 @@ func TestCoverFloat64(t *testing.T) {
} }
}{}, }{},
}, },
{
name: "HeadFloat64PtrNilNotRootStringOmitEmpty",
data: struct {
A struct {
A *float64 `json:"a,string,omitempty"`
}
}{},
},
// PtrHeadFloat64ZeroNotRoot // PtrHeadFloat64ZeroNotRoot
{ {
@ -599,6 +762,16 @@ func TestCoverFloat64(t *testing.T) {
A float64 `json:"a,string"` A float64 `json:"a,string"`
})}, })},
}, },
{
name: "PtrHeadFloat64ZeroNotRootStringOmitEmpty",
data: struct {
A *struct {
A float64 `json:"a,string,omitempty"`
}
}{A: new(struct {
A float64 `json:"a,string,omitempty"`
})},
},
// PtrHeadFloat64NotRoot // PtrHeadFloat64NotRoot
{ {
@ -631,6 +804,16 @@ func TestCoverFloat64(t *testing.T) {
A float64 `json:"a,string"` A float64 `json:"a,string"`
}{A: 1})}, }{A: 1})},
}, },
{
name: "PtrHeadFloat64NotRootStringOmitEmpty",
data: struct {
A *struct {
A float64 `json:"a,string,omitempty"`
}
}{A: &(struct {
A float64 `json:"a,string,omitempty"`
}{A: 1})},
},
// PtrHeadFloat64PtrNotRoot // PtrHeadFloat64PtrNotRoot
{ {
@ -663,6 +846,16 @@ func TestCoverFloat64(t *testing.T) {
A *float64 `json:"a,string"` A *float64 `json:"a,string"`
}{A: float64ptr(1)})}, }{A: float64ptr(1)})},
}, },
{
name: "PtrHeadFloat64PtrNotRootStringOmitEmpty",
data: struct {
A *struct {
A *float64 `json:"a,string,omitempty"`
}
}{A: &(struct {
A *float64 `json:"a,string,omitempty"`
}{A: float64ptr(1)})},
},
// PtrHeadFloat64PtrNilNotRoot // PtrHeadFloat64PtrNilNotRoot
{ {
@ -695,6 +888,16 @@ func TestCoverFloat64(t *testing.T) {
A *float64 `json:"a,string"` A *float64 `json:"a,string"`
}{A: nil})}, }{A: nil})},
}, },
{
name: "PtrHeadFloat64PtrNilNotRootStringOmitEmpty",
data: struct {
A *struct {
A *float64 `json:"a,string,omitempty"`
}
}{A: &(struct {
A *float64 `json:"a,string,omitempty"`
}{A: nil})},
},
// PtrHeadFloat64NilNotRoot // PtrHeadFloat64NilNotRoot
{ {
@ -721,6 +924,14 @@ func TestCoverFloat64(t *testing.T) {
} `json:",string"` } `json:",string"`
}{A: nil}, }{A: nil},
}, },
{
name: "PtrHeadFloat64NilNotRootStringOmitEmpty",
data: struct {
A *struct {
A *float64 `json:"a,string,omitempty"`
} `json:",string,omitempty"`
}{A: nil},
},
// HeadFloat64ZeroMultiFieldsNotRoot // HeadFloat64ZeroMultiFieldsNotRoot
{ {
@ -756,6 +967,17 @@ func TestCoverFloat64(t *testing.T) {
} }
}{}, }{},
}, },
{
name: "HeadFloat64ZeroMultiFieldsNotRootStringOmitEmpty",
data: struct {
A struct {
A float64 `json:"a,string,omitempty"`
}
B struct {
B float64 `json:"b,string,omitempty"`
}
}{},
},
// HeadFloat64MultiFieldsNotRoot // HeadFloat64MultiFieldsNotRoot
{ {
@ -803,6 +1025,21 @@ func TestCoverFloat64(t *testing.T) {
B float64 `json:"b,string"` B float64 `json:"b,string"`
}{B: 2}}, }{B: 2}},
}, },
{
name: "HeadFloat64MultiFieldsNotRootStringOmitEmpty",
data: struct {
A struct {
A float64 `json:"a,string,omitempty"`
}
B struct {
B float64 `json:"b,string,omitempty"`
}
}{A: struct {
A float64 `json:"a,string,omitempty"`
}{A: 1}, B: struct {
B float64 `json:"b,string,omitempty"`
}{B: 2}},
},
// HeadFloat64PtrMultiFieldsNotRoot // HeadFloat64PtrMultiFieldsNotRoot
{ {
@ -850,6 +1087,21 @@ func TestCoverFloat64(t *testing.T) {
B *float64 `json:"b,string"` B *float64 `json:"b,string"`
}{B: float64ptr(2)}}, }{B: float64ptr(2)}},
}, },
{
name: "HeadFloat64PtrMultiFieldsNotRootStringOmitEmpty",
data: struct {
A struct {
A *float64 `json:"a,string,omitempty"`
}
B struct {
B *float64 `json:"b,string,omitempty"`
}
}{A: struct {
A *float64 `json:"a,string,omitempty"`
}{A: float64ptr(1)}, B: struct {
B *float64 `json:"b,string,omitempty"`
}{B: float64ptr(2)}},
},
// HeadFloat64PtrNilMultiFieldsNotRoot // HeadFloat64PtrNilMultiFieldsNotRoot
{ {
@ -897,6 +1149,21 @@ func TestCoverFloat64(t *testing.T) {
B *float64 `json:"b,string"` B *float64 `json:"b,string"`
}{B: nil}}, }{B: nil}},
}, },
{
name: "HeadFloat64PtrNilMultiFieldsNotRootStringOmitEmpty",
data: struct {
A struct {
A *float64 `json:"a,string,omitempty"`
}
B struct {
B *float64 `json:"b,string,omitempty"`
}
}{A: struct {
A *float64 `json:"a,string,omitempty"`
}{A: nil}, B: struct {
B *float64 `json:"b,string,omitempty"`
}{B: nil}},
},
// PtrHeadFloat64ZeroMultiFieldsNotRoot // PtrHeadFloat64ZeroMultiFieldsNotRoot
{ {
@ -932,6 +1199,17 @@ func TestCoverFloat64(t *testing.T) {
} }
}{}, }{},
}, },
{
name: "PtrHeadFloat64ZeroMultiFieldsNotRootStringOmitEmpty",
data: &struct {
A struct {
A float64 `json:"a,string,omitempty"`
}
B struct {
B float64 `json:"b,string,omitempty"`
}
}{},
},
// PtrHeadFloat64MultiFieldsNotRoot // PtrHeadFloat64MultiFieldsNotRoot
{ {
@ -979,6 +1257,21 @@ func TestCoverFloat64(t *testing.T) {
B float64 `json:"b,string"` B float64 `json:"b,string"`
}{B: 2}}, }{B: 2}},
}, },
{
name: "PtrHeadFloat64MultiFieldsNotRootStringOmitEmpty",
data: &struct {
A struct {
A float64 `json:"a,string,omitempty"`
}
B struct {
B float64 `json:"b,string,omitempty"`
}
}{A: struct {
A float64 `json:"a,string,omitempty"`
}{A: 1}, B: struct {
B float64 `json:"b,string,omitempty"`
}{B: 2}},
},
// PtrHeadFloat64PtrMultiFieldsNotRoot // PtrHeadFloat64PtrMultiFieldsNotRoot
{ {
@ -1026,6 +1319,21 @@ func TestCoverFloat64(t *testing.T) {
B *float64 `json:"b,string"` B *float64 `json:"b,string"`
}{B: float64ptr(2)})}, }{B: float64ptr(2)})},
}, },
{
name: "PtrHeadFloat64PtrMultiFieldsNotRootStringOmitEmpty",
data: &struct {
A *struct {
A *float64 `json:"a,string,omitempty"`
}
B *struct {
B *float64 `json:"b,string,omitempty"`
}
}{A: &(struct {
A *float64 `json:"a,string,omitempty"`
}{A: float64ptr(1)}), B: &(struct {
B *float64 `json:"b,string,omitempty"`
}{B: float64ptr(2)})},
},
// PtrHeadFloat64PtrNilMultiFieldsNotRoot // PtrHeadFloat64PtrNilMultiFieldsNotRoot
{ {
@ -1061,6 +1369,17 @@ func TestCoverFloat64(t *testing.T) {
} `json:",string"` } `json:",string"`
}{A: nil, B: nil}, }{A: nil, B: nil},
}, },
{
name: "PtrHeadFloat64PtrNilMultiFieldsNotRootStringOmitEmpty",
data: &struct {
A *struct {
A *float64 `json:"a,string,omitempty"`
} `json:",string,omitempty"`
B *struct {
B *float64 `json:"b,string,omitempty"`
} `json:",string,omitempty"`
}{A: nil, B: nil},
},
// PtrHeadFloat64NilMultiFieldsNotRoot // PtrHeadFloat64NilMultiFieldsNotRoot
{ {
@ -1096,6 +1415,17 @@ func TestCoverFloat64(t *testing.T) {
} }
})(nil), })(nil),
}, },
{
name: "PtrHeadFloat64NilMultiFieldsNotRootStringOmitEmpty",
data: (*struct {
A *struct {
A *float64 `json:"a,string,omitempty"`
}
B *struct {
B *float64 `json:"b,string,omitempty"`
}
})(nil),
},
// PtrHeadFloat64DoubleMultiFieldsNotRoot // PtrHeadFloat64DoubleMultiFieldsNotRoot
{ {
@ -1155,6 +1485,25 @@ func TestCoverFloat64(t *testing.T) {
B float64 `json:"b,string"` B float64 `json:"b,string"`
}{A: 3, B: 4})}, }{A: 3, B: 4})},
}, },
{
name: "PtrHeadFloat64DoubleMultiFieldsNotRootStringOmitEmpty",
data: &struct {
A *struct {
A float64 `json:"a,string,omitempty"`
B float64 `json:"b,string,omitempty"`
}
B *struct {
A float64 `json:"a,string,omitempty"`
B float64 `json:"b,string,omitempty"`
}
}{A: &(struct {
A float64 `json:"a,string,omitempty"`
B float64 `json:"b,string,omitempty"`
}{A: 1, B: 2}), B: &(struct {
A float64 `json:"a,string,omitempty"`
B float64 `json:"b,string,omitempty"`
}{A: 3, B: 4})},
},
// PtrHeadFloat64NilDoubleMultiFieldsNotRoot // PtrHeadFloat64NilDoubleMultiFieldsNotRoot
{ {
@ -1196,6 +1545,19 @@ func TestCoverFloat64(t *testing.T) {
} }
}{A: nil, B: nil}, }{A: nil, B: nil},
}, },
{
name: "PtrHeadFloat64NilDoubleMultiFieldsNotRootStringOmitEmpty",
data: &struct {
A *struct {
A float64 `json:"a,string,omitempty"`
B float64 `json:"b,string,omitempty"`
}
B *struct {
A float64 `json:"a,string,omitempty"`
B float64 `json:"b,string,omitempty"`
}
}{A: nil, B: nil},
},
// PtrHeadFloat64NilDoubleMultiFieldsNotRoot // PtrHeadFloat64NilDoubleMultiFieldsNotRoot
{ {
@ -1237,6 +1599,19 @@ func TestCoverFloat64(t *testing.T) {
} }
})(nil), })(nil),
}, },
{
name: "PtrHeadFloat64NilDoubleMultiFieldsNotRootStringOmitEmpty",
data: (*struct {
A *struct {
A float64 `json:"a,string,omitempty"`
B float64 `json:"b,string,omitempty"`
}
B *struct {
A float64 `json:"a,string,omitempty"`
B float64 `json:"b,string,omitempty"`
}
})(nil),
},
// PtrHeadFloat64PtrDoubleMultiFieldsNotRoot // PtrHeadFloat64PtrDoubleMultiFieldsNotRoot
{ {
@ -1296,6 +1671,25 @@ func TestCoverFloat64(t *testing.T) {
B *float64 `json:"b,string"` B *float64 `json:"b,string"`
}{A: float64ptr(3), B: float64ptr(4)})}, }{A: float64ptr(3), B: float64ptr(4)})},
}, },
{
name: "PtrHeadFloat64PtrDoubleMultiFieldsNotRootStringOmitEmpty",
data: &struct {
A *struct {
A *float64 `json:"a,string,omitempty"`
B *float64 `json:"b,string,omitempty"`
}
B *struct {
A *float64 `json:"a,string,omitempty"`
B *float64 `json:"b,string,omitempty"`
}
}{A: &(struct {
A *float64 `json:"a,string,omitempty"`
B *float64 `json:"b,string,omitempty"`
}{A: float64ptr(1), B: float64ptr(2)}), B: &(struct {
A *float64 `json:"a,string,omitempty"`
B *float64 `json:"b,string,omitempty"`
}{A: float64ptr(3), B: float64ptr(4)})},
},
// PtrHeadFloat64PtrNilDoubleMultiFieldsNotRoot // PtrHeadFloat64PtrNilDoubleMultiFieldsNotRoot
{ {
@ -1337,6 +1731,19 @@ func TestCoverFloat64(t *testing.T) {
} }
}{A: nil, B: nil}, }{A: nil, B: nil},
}, },
{
name: "PtrHeadFloat64PtrNilDoubleMultiFieldsNotRootStringOmitEmpty",
data: &struct {
A *struct {
A *float64 `json:"a,string,omitempty"`
B *float64 `json:"b,string,omitempty"`
}
B *struct {
A *float64 `json:"a,string,omitempty"`
B *float64 `json:"b,string,omitempty"`
}
}{A: nil, B: nil},
},
// PtrHeadFloat64PtrNilDoubleMultiFieldsNotRoot // PtrHeadFloat64PtrNilDoubleMultiFieldsNotRoot
{ {
@ -1378,6 +1785,19 @@ func TestCoverFloat64(t *testing.T) {
} }
})(nil), })(nil),
}, },
{
name: "PtrHeadFloat64PtrNilDoubleMultiFieldsNotRootStringOmitEmpty",
data: (*struct {
A *struct {
A *float64 `json:"a,string,omitempty"`
B *float64 `json:"b,string,omitempty"`
}
B *struct {
A *float64 `json:"a,string,omitempty"`
B *float64 `json:"b,string,omitempty"`
}
})(nil),
},
// AnonymousHeadFloat64 // AnonymousHeadFloat64
{ {
@ -1410,6 +1830,16 @@ func TestCoverFloat64(t *testing.T) {
B: 2, B: 2,
}, },
}, },
{
name: "AnonymousHeadFloat64StringOmitEmpty",
data: struct {
structFloat64StringOmitEmpty
B float64 `json:"b,string,omitempty"`
}{
structFloat64StringOmitEmpty: structFloat64StringOmitEmpty{A: 1},
B: 2,
},
},
// PtrAnonymousHeadFloat64 // PtrAnonymousHeadFloat64
{ {
@ -1442,6 +1872,16 @@ func TestCoverFloat64(t *testing.T) {
B: 2, B: 2,
}, },
}, },
{
name: "PtrAnonymousHeadFloat64StringOmitEmpty",
data: struct {
*structFloat64StringOmitEmpty
B float64 `json:"b,string,omitempty"`
}{
structFloat64StringOmitEmpty: &structFloat64StringOmitEmpty{A: 1},
B: 2,
},
},
// NilPtrAnonymousHeadFloat64 // NilPtrAnonymousHeadFloat64
{ {
@ -1474,6 +1914,16 @@ func TestCoverFloat64(t *testing.T) {
B: 2, B: 2,
}, },
}, },
{
name: "NilPtrAnonymousHeadFloat64StringOmitEmpty",
data: struct {
*structFloat64StringOmitEmpty
B float64 `json:"b,string,omitempty"`
}{
structFloat64StringOmitEmpty: nil,
B: 2,
},
},
// AnonymousHeadFloat64Ptr // AnonymousHeadFloat64Ptr
{ {
@ -1506,6 +1956,16 @@ func TestCoverFloat64(t *testing.T) {
B: float64ptr(2), B: float64ptr(2),
}, },
}, },
{
name: "AnonymousHeadFloat64PtrStringOmitEmpty",
data: struct {
structFloat64PtrStringOmitEmpty
B *float64 `json:"b,string,omitempty"`
}{
structFloat64PtrStringOmitEmpty: structFloat64PtrStringOmitEmpty{A: float64ptr(1)},
B: float64ptr(2),
},
},
// AnonymousHeadFloat64PtrNil // AnonymousHeadFloat64PtrNil
{ {
@ -1538,6 +1998,16 @@ func TestCoverFloat64(t *testing.T) {
B: float64ptr(2), B: float64ptr(2),
}, },
}, },
{
name: "AnonymousHeadFloat64PtrNilStringOmitEmpty",
data: struct {
structFloat64PtrStringOmitEmpty
B *float64 `json:"b,string,omitempty"`
}{
structFloat64PtrStringOmitEmpty: structFloat64PtrStringOmitEmpty{A: nil},
B: float64ptr(2),
},
},
// PtrAnonymousHeadFloat64Ptr // PtrAnonymousHeadFloat64Ptr
{ {
@ -1570,6 +2040,16 @@ func TestCoverFloat64(t *testing.T) {
B: float64ptr(2), B: float64ptr(2),
}, },
}, },
{
name: "PtrAnonymousHeadFloat64PtrStringOmitEmpty",
data: struct {
*structFloat64PtrStringOmitEmpty
B *float64 `json:"b,string,omitempty"`
}{
structFloat64PtrStringOmitEmpty: &structFloat64PtrStringOmitEmpty{A: float64ptr(1)},
B: float64ptr(2),
},
},
// NilPtrAnonymousHeadFloat64Ptr // NilPtrAnonymousHeadFloat64Ptr
{ {
@ -1602,6 +2082,16 @@ func TestCoverFloat64(t *testing.T) {
B: float64ptr(2), B: float64ptr(2),
}, },
}, },
{
name: "NilPtrAnonymousHeadFloat64PtrStringOmitEmpty",
data: struct {
*structFloat64PtrStringOmitEmpty
B *float64 `json:"b,string,omitempty"`
}{
structFloat64PtrStringOmitEmpty: nil,
B: float64ptr(2),
},
},
// AnonymousHeadFloat64Only // AnonymousHeadFloat64Only
{ {
@ -1628,6 +2118,14 @@ func TestCoverFloat64(t *testing.T) {
structFloat64String: structFloat64String{A: 1}, structFloat64String: structFloat64String{A: 1},
}, },
}, },
{
name: "AnonymousHeadFloat64OnlyStringOmitEmpty",
data: struct {
structFloat64StringOmitEmpty
}{
structFloat64StringOmitEmpty: structFloat64StringOmitEmpty{A: 1},
},
},
// PtrAnonymousHeadFloat64Only // PtrAnonymousHeadFloat64Only
{ {
@ -1654,6 +2152,14 @@ func TestCoverFloat64(t *testing.T) {
structFloat64String: &structFloat64String{A: 1}, structFloat64String: &structFloat64String{A: 1},
}, },
}, },
{
name: "PtrAnonymousHeadFloat64OnlyStringOmitEmpty",
data: struct {
*structFloat64StringOmitEmpty
}{
structFloat64StringOmitEmpty: &structFloat64StringOmitEmpty{A: 1},
},
},
// NilPtrAnonymousHeadFloat64Only // NilPtrAnonymousHeadFloat64Only
{ {
@ -1680,6 +2186,14 @@ func TestCoverFloat64(t *testing.T) {
structFloat64String: nil, structFloat64String: nil,
}, },
}, },
{
name: "NilPtrAnonymousHeadFloat64OnlyStringOmitEmpty",
data: struct {
*structFloat64StringOmitEmpty
}{
structFloat64StringOmitEmpty: nil,
},
},
// AnonymousHeadFloat64PtrOnly // AnonymousHeadFloat64PtrOnly
{ {
@ -1706,6 +2220,14 @@ func TestCoverFloat64(t *testing.T) {
structFloat64PtrString: structFloat64PtrString{A: float64ptr(1)}, structFloat64PtrString: structFloat64PtrString{A: float64ptr(1)},
}, },
}, },
{
name: "AnonymousHeadFloat64PtrOnlyStringOmitEmpty",
data: struct {
structFloat64PtrStringOmitEmpty
}{
structFloat64PtrStringOmitEmpty: structFloat64PtrStringOmitEmpty{A: float64ptr(1)},
},
},
// AnonymousHeadFloat64PtrNilOnly // AnonymousHeadFloat64PtrNilOnly
{ {
@ -1732,6 +2254,14 @@ func TestCoverFloat64(t *testing.T) {
structFloat64PtrString: structFloat64PtrString{A: nil}, structFloat64PtrString: structFloat64PtrString{A: nil},
}, },
}, },
{
name: "AnonymousHeadFloat64PtrNilOnlyStringOmitEmpty",
data: struct {
structFloat64PtrStringOmitEmpty
}{
structFloat64PtrStringOmitEmpty: structFloat64PtrStringOmitEmpty{A: nil},
},
},
// PtrAnonymousHeadFloat64PtrOnly // PtrAnonymousHeadFloat64PtrOnly
{ {
@ -1758,6 +2288,14 @@ func TestCoverFloat64(t *testing.T) {
structFloat64PtrString: &structFloat64PtrString{A: float64ptr(1)}, structFloat64PtrString: &structFloat64PtrString{A: float64ptr(1)},
}, },
}, },
{
name: "PtrAnonymousHeadFloat64PtrOnlyStringOmitEmpty",
data: struct {
*structFloat64PtrStringOmitEmpty
}{
structFloat64PtrStringOmitEmpty: &structFloat64PtrStringOmitEmpty{A: float64ptr(1)},
},
},
// NilPtrAnonymousHeadFloat64PtrOnly // NilPtrAnonymousHeadFloat64PtrOnly
{ {
@ -1784,6 +2322,14 @@ func TestCoverFloat64(t *testing.T) {
structFloat64PtrString: nil, structFloat64PtrString: nil,
}, },
}, },
{
name: "NilPtrAnonymousHeadFloat64PtrOnlyStringOmitEmpty",
data: struct {
*structFloat64PtrStringOmitEmpty
}{
structFloat64PtrStringOmitEmpty: nil,
},
},
} }
for _, test := range tests { for _, test := range tests {
for _, indent := range []bool{true, false} { for _, indent := range []bool{true, false} {

View File

@ -17,6 +17,9 @@ func TestCoverInt(t *testing.T) {
type structIntString struct { type structIntString struct {
A int `json:"a,string"` A int `json:"a,string"`
} }
type structIntStringOmitEmpty struct {
A int `json:"a,omitempty,string"`
}
type structIntPtr struct { type structIntPtr struct {
A *int `json:"a"` A *int `json:"a"`
@ -27,6 +30,9 @@ func TestCoverInt(t *testing.T) {
type structIntPtrString struct { type structIntPtrString struct {
A *int `json:"a,string"` A *int `json:"a,string"`
} }
type structIntPtrStringOmitEmpty struct {
A *int `json:"a,omitempty,string"`
}
tests := []struct { tests := []struct {
name string name string
@ -152,6 +158,12 @@ func TestCoverInt(t *testing.T) {
A int `json:"a,string"` A int `json:"a,string"`
}{}, }{},
}, },
{
name: "PtrHeadIntZeroStringOmitEmpty",
data: &struct {
A int `json:"a,string,omitempty"`
}{},
},
// PtrHeadInt // PtrHeadInt
{ {
@ -172,6 +184,12 @@ func TestCoverInt(t *testing.T) {
A int `json:"a,string"` A int `json:"a,string"`
}{A: -1}, }{A: -1},
}, },
{
name: "PtrHeadIntStringOmitEmpty",
data: &struct {
A int `json:"a,string,omitempty"`
}{A: -1},
},
// PtrHeadIntPtr // PtrHeadIntPtr
{ {
@ -192,6 +210,12 @@ func TestCoverInt(t *testing.T) {
A *int `json:"a,string"` A *int `json:"a,string"`
}{A: intptr(-1)}, }{A: intptr(-1)},
}, },
{
name: "PtrHeadIntPtrStringOmitEmpty",
data: &struct {
A *int `json:"a,string,omitempty"`
}{A: intptr(-1)},
},
// PtrHeadIntPtrNil // PtrHeadIntPtrNil
{ {
@ -212,6 +236,12 @@ func TestCoverInt(t *testing.T) {
A *int `json:"a,string"` A *int `json:"a,string"`
}{A: nil}, }{A: nil},
}, },
{
name: "PtrHeadIntPtrNilStringOmitEmpty",
data: &struct {
A *int `json:"a,string,omitempty"`
}{A: nil},
},
// PtrHeadIntNil // PtrHeadIntNil
{ {
@ -232,6 +262,12 @@ func TestCoverInt(t *testing.T) {
A *int `json:"a,string"` A *int `json:"a,string"`
})(nil), })(nil),
}, },
{
name: "PtrHeadIntNilStringOmitEmpty",
data: (*struct {
A *int `json:"a,string,omitempty"`
})(nil),
},
// HeadIntZeroMultiFields // HeadIntZeroMultiFields
{ {
@ -251,13 +287,21 @@ func TestCoverInt(t *testing.T) {
}{}, }{},
}, },
{ {
name: "HeadIntZeroMultiFields", name: "HeadIntZeroMultiFieldsString",
data: struct { data: struct {
A int `json:"a,string"` A int `json:"a,string"`
B int `json:"b,string"` B int `json:"b,string"`
C int `json:"c,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 // HeadIntMultiFields
{ {
@ -284,6 +328,14 @@ func TestCoverInt(t *testing.T) {
C int `json:"c,string"` C int `json:"c,string"`
}{A: -1, B: 2, C: 3}, }{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 // HeadIntPtrMultiFields
{ {
@ -310,6 +362,14 @@ func TestCoverInt(t *testing.T) {
C *int `json:"c,string"` C *int `json:"c,string"`
}{A: intptr(-1), B: intptr(2), C: intptr(3)}, }{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 // HeadIntPtrNilMultiFields
{ {
@ -336,6 +396,14 @@ func TestCoverInt(t *testing.T) {
C *int `json:"c,string"` C *int `json:"c,string"`
}{A: nil, B: nil, C: nil}, }{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 // PtrHeadIntZeroMultiFields
{ {
@ -359,6 +427,13 @@ func TestCoverInt(t *testing.T) {
B int `json:"b,string"` B int `json:"b,string"`
}{}, }{},
}, },
{
name: "PtrHeadIntZeroMultiFieldsStringOmitEmpty",
data: &struct {
A int `json:"a,string,omitempty"`
B int `json:"b,string,omitempty"`
}{},
},
// PtrHeadIntMultiFields // PtrHeadIntMultiFields
{ {
@ -382,6 +457,13 @@ func TestCoverInt(t *testing.T) {
B int `json:"b,string"` B int `json:"b,string"`
}{A: -1, B: 2}, }{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 // PtrHeadIntPtrMultiFields
{ {
@ -405,6 +487,13 @@ func TestCoverInt(t *testing.T) {
B *int `json:"b,string"` B *int `json:"b,string"`
}{A: intptr(-1), B: intptr(2)}, }{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 // PtrHeadIntPtrNilMultiFields
{ {
@ -428,6 +517,13 @@ func TestCoverInt(t *testing.T) {
B *int `json:"b,string"` B *int `json:"b,string"`
}{A: nil, B: nil}, }{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 // PtrHeadIntNilMultiFields
{ {
@ -451,6 +547,13 @@ func TestCoverInt(t *testing.T) {
B *int `json:"b,string"` B *int `json:"b,string"`
})(nil), })(nil),
}, },
{
name: "PtrHeadIntNilMultiFieldsStringOmitEmpty",
data: (*struct {
A *int `json:"a,string,omitempty"`
B *int `json:"b,string,omitempty"`
})(nil),
},
// HeadIntZeroNotRoot // HeadIntZeroNotRoot
{ {
@ -477,6 +580,14 @@ func TestCoverInt(t *testing.T) {
} }
}{}, }{},
}, },
{
name: "HeadIntZeroNotRootStringOmitEmpty",
data: struct {
A struct {
A int `json:"a,string,omitempty"`
}
}{},
},
// HeadIntNotRoot // HeadIntNotRoot
{ {
@ -509,6 +620,16 @@ func TestCoverInt(t *testing.T) {
A int `json:"a,string"` A int `json:"a,string"`
}{A: -1}}, }{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 // HeadIntPtrNotRoot
{ {
@ -541,6 +662,16 @@ func TestCoverInt(t *testing.T) {
A *int `json:"a,string"` A *int `json:"a,string"`
}{intptr(-1)}}, }{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 // HeadIntPtrNilNotRoot
{ {
@ -567,6 +698,14 @@ func TestCoverInt(t *testing.T) {
} }
}{}, }{},
}, },
{
name: "HeadIntPtrNilNotRootStringOmitEmpty",
data: struct {
A struct {
A *int `json:"a,string,omitempty"`
}
}{},
},
// PtrHeadIntZeroNotRoot // PtrHeadIntZeroNotRoot
{ {
@ -599,6 +738,16 @@ func TestCoverInt(t *testing.T) {
A int `json:"a,string"` 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 // PtrHeadIntNotRoot
{ {
@ -631,6 +780,16 @@ func TestCoverInt(t *testing.T) {
A int `json:"a,string"` A int `json:"a,string"`
}{A: -1})}, }{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 // PtrHeadIntPtrNotRoot
{ {
@ -663,6 +822,16 @@ func TestCoverInt(t *testing.T) {
A *int `json:"a,string"` A *int `json:"a,string"`
}{A: intptr(-1)})}, }{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 // PtrHeadIntPtrNilNotRoot
{ {
@ -695,6 +864,16 @@ func TestCoverInt(t *testing.T) {
A *int `json:"a,string"` A *int `json:"a,string"`
}{A: nil})}, }{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 // PtrHeadIntNilNotRoot
{ {
@ -721,6 +900,14 @@ func TestCoverInt(t *testing.T) {
} `json:",string"` } `json:",string"`
}{A: nil}, }{A: nil},
}, },
{
name: "PtrHeadIntNilNotRootStringOmitEmpty",
data: struct {
A *struct {
A *int `json:"a,string,omitempty"`
} `json:",string,omitempty"`
}{A: nil},
},
// HeadIntZeroMultiFieldsNotRoot // HeadIntZeroMultiFieldsNotRoot
{ {
@ -756,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 // HeadIntMultiFieldsNotRoot
{ {
@ -803,6 +1001,21 @@ func TestCoverInt(t *testing.T) {
B int `json:"b,string"` B int `json:"b,string"`
}{B: 2}}, }{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 // HeadIntPtrMultiFieldsNotRoot
{ {
@ -850,6 +1063,21 @@ func TestCoverInt(t *testing.T) {
B *int `json:"b,string"` B *int `json:"b,string"`
}{B: intptr(2)}}, }{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 // HeadIntPtrNilMultiFieldsNotRoot
{ {
@ -897,6 +1125,21 @@ func TestCoverInt(t *testing.T) {
B *int `json:"b,string"` B *int `json:"b,string"`
}{B: nil}}, }{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 // PtrHeadIntZeroMultiFieldsNotRoot
{ {
@ -932,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 // PtrHeadIntMultiFieldsNotRoot
{ {
@ -979,6 +1233,21 @@ func TestCoverInt(t *testing.T) {
B int `json:"b,string"` B int `json:"b,string"`
}{B: 2}}, }{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 // PtrHeadIntPtrMultiFieldsNotRoot
{ {
@ -1026,6 +1295,21 @@ func TestCoverInt(t *testing.T) {
B *int `json:"b,string"` B *int `json:"b,string"`
}{B: intptr(2)})}, }{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 // PtrHeadIntPtrNilMultiFieldsNotRoot
{ {
@ -1061,6 +1345,17 @@ func TestCoverInt(t *testing.T) {
} `json:",string"` } `json:",string"`
}{A: nil, B: nil}, }{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 // PtrHeadIntNilMultiFieldsNotRoot
{ {
@ -1096,6 +1391,17 @@ func TestCoverInt(t *testing.T) {
} }
})(nil), })(nil),
}, },
{
name: "PtrHeadIntNilMultiFieldsNotRootStringOmitEmpty",
data: (*struct {
A *struct {
A *int `json:"a,string,omitempty"`
}
B *struct {
B *int `json:"b,string,omitempty"`
}
})(nil),
},
// PtrHeadIntDoubleMultiFieldsNotRoot // PtrHeadIntDoubleMultiFieldsNotRoot
{ {
@ -1155,6 +1461,25 @@ func TestCoverInt(t *testing.T) {
B int `json:"b,string"` B int `json:"b,string"`
}{A: 3, B: 4})}, }{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 // PtrHeadIntNilDoubleMultiFieldsNotRoot
{ {
@ -1196,6 +1521,19 @@ func TestCoverInt(t *testing.T) {
} }
}{A: nil, B: nil}, }{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 // PtrHeadIntNilDoubleMultiFieldsNotRoot
{ {
@ -1237,6 +1575,19 @@ func TestCoverInt(t *testing.T) {
} }
})(nil), })(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 // PtrHeadIntPtrDoubleMultiFieldsNotRoot
{ {
@ -1296,6 +1647,25 @@ func TestCoverInt(t *testing.T) {
B *int `json:"b,string"` B *int `json:"b,string"`
}{A: intptr(3), B: intptr(4)})}, }{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 // PtrHeadIntPtrNilDoubleMultiFieldsNotRoot
{ {
@ -1337,6 +1707,19 @@ func TestCoverInt(t *testing.T) {
} }
}{A: nil, B: nil}, }{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 // PtrHeadIntPtrNilDoubleMultiFieldsNotRoot
{ {
@ -1378,6 +1761,19 @@ func TestCoverInt(t *testing.T) {
} }
})(nil), })(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 // AnonymousHeadInt
{ {
@ -1410,6 +1806,16 @@ func TestCoverInt(t *testing.T) {
B: 2, B: 2,
}, },
}, },
{
name: "AnonymousHeadIntStringOmitEmpty",
data: struct {
structIntStringOmitEmpty
B int `json:"b,string,omitempty"`
}{
structIntStringOmitEmpty: structIntStringOmitEmpty{A: -1},
B: 2,
},
},
// PtrAnonymousHeadInt // PtrAnonymousHeadInt
{ {
@ -1442,6 +1848,16 @@ func TestCoverInt(t *testing.T) {
B: 2, B: 2,
}, },
}, },
{
name: "PtrAnonymousHeadIntStringOmitEmpty",
data: struct {
*structIntStringOmitEmpty
B int `json:"b,string,omitempty"`
}{
structIntStringOmitEmpty: &structIntStringOmitEmpty{A: -1},
B: 2,
},
},
// NilPtrAnonymousHeadInt // NilPtrAnonymousHeadInt
{ {
@ -1474,6 +1890,16 @@ func TestCoverInt(t *testing.T) {
B: 2, B: 2,
}, },
}, },
{
name: "NilPtrAnonymousHeadIntStringOmitEmpty",
data: struct {
*structIntStringOmitEmpty
B int `json:"b,string,omitempty"`
}{
structIntStringOmitEmpty: nil,
B: 2,
},
},
// AnonymousHeadIntPtr // AnonymousHeadIntPtr
{ {
@ -1506,6 +1932,16 @@ func TestCoverInt(t *testing.T) {
B: intptr(2), B: intptr(2),
}, },
}, },
{
name: "AnonymousHeadIntPtrStringOmitEmpty",
data: struct {
structIntPtrStringOmitEmpty
B *int `json:"b,string,omitempty"`
}{
structIntPtrStringOmitEmpty: structIntPtrStringOmitEmpty{A: intptr(-1)},
B: intptr(2),
},
},
// AnonymousHeadIntPtrNil // AnonymousHeadIntPtrNil
{ {
@ -1538,6 +1974,16 @@ func TestCoverInt(t *testing.T) {
B: intptr(2), B: intptr(2),
}, },
}, },
{
name: "AnonymousHeadIntPtrNilStringOmitEmpty",
data: struct {
structIntPtrStringOmitEmpty
B *int `json:"b,string,omitempty"`
}{
structIntPtrStringOmitEmpty: structIntPtrStringOmitEmpty{A: nil},
B: intptr(2),
},
},
// PtrAnonymousHeadIntPtr // PtrAnonymousHeadIntPtr
{ {
@ -1570,6 +2016,16 @@ func TestCoverInt(t *testing.T) {
B: intptr(2), B: intptr(2),
}, },
}, },
{
name: "PtrAnonymousHeadIntPtrStringOmitEmpty",
data: struct {
*structIntPtrStringOmitEmpty
B *int `json:"b,string,omitempty"`
}{
structIntPtrStringOmitEmpty: &structIntPtrStringOmitEmpty{A: intptr(-1)},
B: intptr(2),
},
},
// NilPtrAnonymousHeadIntPtr // NilPtrAnonymousHeadIntPtr
{ {
@ -1602,6 +2058,16 @@ func TestCoverInt(t *testing.T) {
B: intptr(2), B: intptr(2),
}, },
}, },
{
name: "NilPtrAnonymousHeadIntPtrStringOmitEmpty",
data: struct {
*structIntPtrStringOmitEmpty
B *int `json:"b,string,omitempty"`
}{
structIntPtrStringOmitEmpty: nil,
B: intptr(2),
},
},
// AnonymousHeadIntOnly // AnonymousHeadIntOnly
{ {
@ -1628,6 +2094,14 @@ func TestCoverInt(t *testing.T) {
structIntString: structIntString{A: -1}, structIntString: structIntString{A: -1},
}, },
}, },
{
name: "AnonymousHeadIntOnlyStringOmitEmpty",
data: struct {
structIntStringOmitEmpty
}{
structIntStringOmitEmpty: structIntStringOmitEmpty{A: -1},
},
},
// PtrAnonymousHeadIntOnly // PtrAnonymousHeadIntOnly
{ {
@ -1654,6 +2128,14 @@ func TestCoverInt(t *testing.T) {
structIntString: &structIntString{A: -1}, structIntString: &structIntString{A: -1},
}, },
}, },
{
name: "PtrAnonymousHeadIntOnlyStringOmitEmpty",
data: struct {
*structIntStringOmitEmpty
}{
structIntStringOmitEmpty: &structIntStringOmitEmpty{A: -1},
},
},
// NilPtrAnonymousHeadIntOnly // NilPtrAnonymousHeadIntOnly
{ {
@ -1680,6 +2162,14 @@ func TestCoverInt(t *testing.T) {
structIntString: nil, structIntString: nil,
}, },
}, },
{
name: "NilPtrAnonymousHeadIntOnlyStringOmitEmpty",
data: struct {
*structIntStringOmitEmpty
}{
structIntStringOmitEmpty: nil,
},
},
// AnonymousHeadIntPtrOnly // AnonymousHeadIntPtrOnly
{ {
@ -1706,6 +2196,14 @@ func TestCoverInt(t *testing.T) {
structIntPtrString: structIntPtrString{A: intptr(-1)}, structIntPtrString: structIntPtrString{A: intptr(-1)},
}, },
}, },
{
name: "AnonymousHeadIntPtrOnlyStringOmitEmpty",
data: struct {
structIntPtrStringOmitEmpty
}{
structIntPtrStringOmitEmpty: structIntPtrStringOmitEmpty{A: intptr(-1)},
},
},
// AnonymousHeadIntPtrNilOnly // AnonymousHeadIntPtrNilOnly
{ {
@ -1732,6 +2230,14 @@ func TestCoverInt(t *testing.T) {
structIntPtrString: structIntPtrString{A: nil}, structIntPtrString: structIntPtrString{A: nil},
}, },
}, },
{
name: "AnonymousHeadIntPtrNilOnlyStringOmitEmpty",
data: struct {
structIntPtrStringOmitEmpty
}{
structIntPtrStringOmitEmpty: structIntPtrStringOmitEmpty{A: nil},
},
},
// PtrAnonymousHeadIntPtrOnly // PtrAnonymousHeadIntPtrOnly
{ {
@ -1758,6 +2264,14 @@ func TestCoverInt(t *testing.T) {
structIntPtrString: &structIntPtrString{A: intptr(-1)}, structIntPtrString: &structIntPtrString{A: intptr(-1)},
}, },
}, },
{
name: "PtrAnonymousHeadIntPtrOnlyStringOmitEmpty",
data: struct {
*structIntPtrStringOmitEmpty
}{
structIntPtrStringOmitEmpty: &structIntPtrStringOmitEmpty{A: intptr(-1)},
},
},
// NilPtrAnonymousHeadIntPtrOnly // NilPtrAnonymousHeadIntPtrOnly
{ {
@ -1784,6 +2298,14 @@ func TestCoverInt(t *testing.T) {
structIntPtrString: nil, structIntPtrString: nil,
}, },
}, },
{
name: "NilPtrAnonymousHeadIntPtrOnlyStringOmitEmpty",
data: struct {
*structIntPtrStringOmitEmpty
}{
structIntPtrStringOmitEmpty: nil,
},
},
} }
for _, test := range tests { for _, test := range tests {
for _, indent := range []bool{true, false} { for _, indent := range []bool{true, false} {

View File

@ -17,6 +17,9 @@ func TestCoverNumber(t *testing.T) {
type structNumberString struct { type structNumberString struct {
A json.Number `json:"a,string"` A json.Number `json:"a,string"`
} }
type structNumberStringOmitEmpty struct {
A json.Number `json:"a,string,omitempty"`
}
type structNumberPtr struct { type structNumberPtr struct {
A *json.Number `json:"a"` A *json.Number `json:"a"`
@ -27,6 +30,9 @@ func TestCoverNumber(t *testing.T) {
type structNumberPtrString struct { type structNumberPtrString struct {
A *json.Number `json:"a,string"` A *json.Number `json:"a,string"`
} }
type structNumberPtrStringOmitEmpty struct {
A *json.Number `json:"a,string,omitempty"`
}
tests := []struct { tests := []struct {
name string name string
@ -72,6 +78,12 @@ func TestCoverNumber(t *testing.T) {
A json.Number `json:"a,string"` A json.Number `json:"a,string"`
}{}, }{},
}, },
{
name: "HeadNumberZeroStringOmitEmpty",
data: struct {
A json.Number `json:"a,string,omitempty"`
}{},
},
// HeadNumber // HeadNumber
{ {
@ -92,6 +104,12 @@ func TestCoverNumber(t *testing.T) {
A json.Number `json:"a,string"` A json.Number `json:"a,string"`
}{A: "1"}, }{A: "1"},
}, },
{
name: "HeadNumberStringOmitEmpty",
data: struct {
A json.Number `json:"a,string,omitempty"`
}{A: "1"},
},
// HeadNumberPtr // HeadNumberPtr
{ {
@ -112,6 +130,12 @@ func TestCoverNumber(t *testing.T) {
A *json.Number `json:"a,string"` A *json.Number `json:"a,string"`
}{A: numberptr("1")}, }{A: numberptr("1")},
}, },
{
name: "HeadNumberPtrStringOmitEmpty",
data: struct {
A *json.Number `json:"a,string,omitempty"`
}{A: numberptr("1")},
},
// HeadNumberPtrNil // HeadNumberPtrNil
{ {
@ -132,6 +156,12 @@ func TestCoverNumber(t *testing.T) {
A *json.Number `json:"a,string"` A *json.Number `json:"a,string"`
}{A: nil}, }{A: nil},
}, },
{
name: "HeadNumberPtrNilStringOmitEmpty",
data: struct {
A *json.Number `json:"a,string,omitempty"`
}{A: nil},
},
// PtrHeadNumberZero // PtrHeadNumberZero
{ {
@ -152,6 +182,12 @@ func TestCoverNumber(t *testing.T) {
A json.Number `json:"a,string"` A json.Number `json:"a,string"`
}{}, }{},
}, },
{
name: "PtrHeadNumberZeroStringOmitEmpty",
data: &struct {
A json.Number `json:"a,string,omitempty"`
}{},
},
// PtrHeadNumber // PtrHeadNumber
{ {
@ -172,6 +208,12 @@ func TestCoverNumber(t *testing.T) {
A json.Number `json:"a,string"` A json.Number `json:"a,string"`
}{A: "1"}, }{A: "1"},
}, },
{
name: "PtrHeadNumberStringOmitEmpty",
data: &struct {
A json.Number `json:"a,string,omitempty"`
}{A: "1"},
},
// PtrHeadNumberPtr // PtrHeadNumberPtr
{ {
@ -192,6 +234,12 @@ func TestCoverNumber(t *testing.T) {
A *json.Number `json:"a,string"` A *json.Number `json:"a,string"`
}{A: numberptr("1")}, }{A: numberptr("1")},
}, },
{
name: "PtrHeadNumberPtrStringOmitEmpty",
data: &struct {
A *json.Number `json:"a,string,omitempty"`
}{A: numberptr("1")},
},
// PtrHeadNumberPtrNil // PtrHeadNumberPtrNil
{ {
@ -212,6 +260,12 @@ func TestCoverNumber(t *testing.T) {
A *json.Number `json:"a,string"` A *json.Number `json:"a,string"`
}{A: nil}, }{A: nil},
}, },
{
name: "PtrHeadNumberPtrNilStringOmitEmpty",
data: &struct {
A *json.Number `json:"a,string,omitempty"`
}{A: nil},
},
// PtrHeadNumberNil // PtrHeadNumberNil
{ {
@ -232,6 +286,12 @@ func TestCoverNumber(t *testing.T) {
A *json.Number `json:"a,string"` A *json.Number `json:"a,string"`
})(nil), })(nil),
}, },
{
name: "PtrHeadNumberNilStringOmitEmpty",
data: (*struct {
A *json.Number `json:"a,string,omitempty"`
})(nil),
},
// HeadNumberZeroMultiFields // HeadNumberZeroMultiFields
{ {
@ -251,13 +311,21 @@ func TestCoverNumber(t *testing.T) {
}{}, }{},
}, },
{ {
name: "HeadNumberZeroMultiFields", name: "HeadNumberZeroMultiFieldsString",
data: struct { data: struct {
A json.Number `json:"a,string"` A json.Number `json:"a,string"`
B json.Number `json:"b,string"` B json.Number `json:"b,string"`
C json.Number `json:"c,string"` C json.Number `json:"c,string"`
}{}, }{},
}, },
{
name: "HeadNumberZeroMultiFieldsStringOmitEmpty",
data: struct {
A json.Number `json:"a,string,omitempty"`
B json.Number `json:"b,string,omitempty"`
C json.Number `json:"c,string,omitempty"`
}{},
},
// HeadNumberMultiFields // HeadNumberMultiFields
{ {
@ -284,6 +352,14 @@ func TestCoverNumber(t *testing.T) {
C json.Number `json:"c,string"` C json.Number `json:"c,string"`
}{A: "1", B: "2", C: "3"}, }{A: "1", B: "2", C: "3"},
}, },
{
name: "HeadNumberMultiFieldsStringOmitEmpty",
data: struct {
A json.Number `json:"a,string,omitempty"`
B json.Number `json:"b,string,omitempty"`
C json.Number `json:"c,string,omitempty"`
}{A: "1", B: "2", C: "3"},
},
// HeadNumberPtrMultiFields // HeadNumberPtrMultiFields
{ {
@ -310,6 +386,14 @@ func TestCoverNumber(t *testing.T) {
C *json.Number `json:"c,string"` C *json.Number `json:"c,string"`
}{A: numberptr("1"), B: numberptr("2"), C: numberptr("3")}, }{A: numberptr("1"), B: numberptr("2"), C: numberptr("3")},
}, },
{
name: "HeadNumberPtrMultiFieldsStringOmitEmpty",
data: struct {
A *json.Number `json:"a,string,omitempty"`
B *json.Number `json:"b,string,omitempty"`
C *json.Number `json:"c,string,omitempty"`
}{A: numberptr("1"), B: numberptr("2"), C: numberptr("3")},
},
// HeadNumberPtrNilMultiFields // HeadNumberPtrNilMultiFields
{ {
@ -336,6 +420,14 @@ func TestCoverNumber(t *testing.T) {
C *json.Number `json:"c,string"` C *json.Number `json:"c,string"`
}{A: nil, B: nil, C: nil}, }{A: nil, B: nil, C: nil},
}, },
{
name: "HeadNumberPtrNilMultiFieldsStringOmitEmpty",
data: struct {
A *json.Number `json:"a,string,omitempty"`
B *json.Number `json:"b,string,omitempty"`
C *json.Number `json:"c,string,omitempty"`
}{A: nil, B: nil, C: nil},
},
// PtrHeadNumberZeroMultiFields // PtrHeadNumberZeroMultiFields
{ {
@ -359,6 +451,13 @@ func TestCoverNumber(t *testing.T) {
B json.Number `json:"b,string"` B json.Number `json:"b,string"`
}{}, }{},
}, },
{
name: "PtrHeadNumberZeroMultiFieldsStringOmitEmpty",
data: &struct {
A json.Number `json:"a,string,omitempty"`
B json.Number `json:"b,string,omitempty"`
}{},
},
// PtrHeadNumberMultiFields // PtrHeadNumberMultiFields
{ {
@ -382,6 +481,13 @@ func TestCoverNumber(t *testing.T) {
B json.Number `json:"b,string"` B json.Number `json:"b,string"`
}{A: "1", B: "2"}, }{A: "1", B: "2"},
}, },
{
name: "PtrHeadNumberMultiFieldsStringOmitEmpty",
data: &struct {
A json.Number `json:"a,string,omitempty"`
B json.Number `json:"b,string,omitempty"`
}{A: "1", B: "2"},
},
// PtrHeadNumberPtrMultiFields // PtrHeadNumberPtrMultiFields
{ {
@ -405,6 +511,13 @@ func TestCoverNumber(t *testing.T) {
B *json.Number `json:"b,string"` B *json.Number `json:"b,string"`
}{A: numberptr("1"), B: numberptr("2")}, }{A: numberptr("1"), B: numberptr("2")},
}, },
{
name: "PtrHeadNumberPtrMultiFieldsStringOmitEmpty",
data: &struct {
A *json.Number `json:"a,string,omitempty"`
B *json.Number `json:"b,string,omitempty"`
}{A: numberptr("1"), B: numberptr("2")},
},
// PtrHeadNumberPtrNilMultiFields // PtrHeadNumberPtrNilMultiFields
{ {
@ -428,6 +541,13 @@ func TestCoverNumber(t *testing.T) {
B *json.Number `json:"b,string"` B *json.Number `json:"b,string"`
}{A: nil, B: nil}, }{A: nil, B: nil},
}, },
{
name: "PtrHeadNumberPtrNilMultiFieldsStringOmitEmpty",
data: &struct {
A *json.Number `json:"a,string,omitempty"`
B *json.Number `json:"b,string,omitempty"`
}{A: nil, B: nil},
},
// PtrHeadNumberNilMultiFields // PtrHeadNumberNilMultiFields
{ {
@ -451,6 +571,13 @@ func TestCoverNumber(t *testing.T) {
B *json.Number `json:"b,string"` B *json.Number `json:"b,string"`
})(nil), })(nil),
}, },
{
name: "PtrHeadNumberNilMultiFieldsStringOmitEmpty",
data: (*struct {
A *json.Number `json:"a,string,omitempty"`
B *json.Number `json:"b,string,omitempty"`
})(nil),
},
// HeadNumberZeroNotRoot // HeadNumberZeroNotRoot
{ {
@ -477,6 +604,14 @@ func TestCoverNumber(t *testing.T) {
} }
}{}, }{},
}, },
{
name: "HeadNumberZeroNotRootStringOmitEmpty",
data: struct {
A struct {
A json.Number `json:"a,string,omitempty"`
}
}{},
},
// HeadNumberNotRoot // HeadNumberNotRoot
{ {
@ -509,6 +644,16 @@ func TestCoverNumber(t *testing.T) {
A json.Number `json:"a,string"` A json.Number `json:"a,string"`
}{A: "1"}}, }{A: "1"}},
}, },
{
name: "HeadNumberNotRootStringOmitEmpty",
data: struct {
A struct {
A json.Number `json:"a,string,omitempty"`
}
}{A: struct {
A json.Number `json:"a,string,omitempty"`
}{A: "1"}},
},
// HeadNumberPtrNotRoot // HeadNumberPtrNotRoot
{ {
@ -541,6 +686,16 @@ func TestCoverNumber(t *testing.T) {
A *json.Number `json:"a,string"` A *json.Number `json:"a,string"`
}{numberptr("1")}}, }{numberptr("1")}},
}, },
{
name: "HeadNumberPtrNotRootStringOmitEmpty",
data: struct {
A struct {
A *json.Number `json:"a,string,omitempty"`
}
}{A: struct {
A *json.Number `json:"a,string,omitempty"`
}{numberptr("1")}},
},
// HeadNumberPtrNilNotRoot // HeadNumberPtrNilNotRoot
{ {
@ -567,6 +722,14 @@ func TestCoverNumber(t *testing.T) {
} }
}{}, }{},
}, },
{
name: "HeadNumberPtrNilNotRootStringOmitEmpty",
data: struct {
A struct {
A *json.Number `json:"a,string,omitempty"`
}
}{},
},
// PtrHeadNumberZeroNotRoot // PtrHeadNumberZeroNotRoot
{ {
@ -599,6 +762,16 @@ func TestCoverNumber(t *testing.T) {
A json.Number `json:"a,string"` A json.Number `json:"a,string"`
})}, })},
}, },
{
name: "PtrHeadNumberZeroNotRootStringOmitEmpty",
data: struct {
A *struct {
A json.Number `json:"a,string,omitempty"`
}
}{A: new(struct {
A json.Number `json:"a,string,omitempty"`
})},
},
// PtrHeadNumberNotRoot // PtrHeadNumberNotRoot
{ {
@ -631,6 +804,16 @@ func TestCoverNumber(t *testing.T) {
A json.Number `json:"a,string"` A json.Number `json:"a,string"`
}{A: "1"})}, }{A: "1"})},
}, },
{
name: "PtrHeadNumberNotRootStringOmitEmpty",
data: struct {
A *struct {
A json.Number `json:"a,string,omitempty"`
}
}{A: &(struct {
A json.Number `json:"a,string,omitempty"`
}{A: "1"})},
},
// PtrHeadNumberPtrNotRoot // PtrHeadNumberPtrNotRoot
{ {
@ -663,6 +846,16 @@ func TestCoverNumber(t *testing.T) {
A *json.Number `json:"a,string"` A *json.Number `json:"a,string"`
}{A: numberptr("1")})}, }{A: numberptr("1")})},
}, },
{
name: "PtrHeadNumberPtrNotRootStringOmitEmpty",
data: struct {
A *struct {
A *json.Number `json:"a,string,omitempty"`
}
}{A: &(struct {
A *json.Number `json:"a,string,omitempty"`
}{A: numberptr("1")})},
},
// PtrHeadNumberPtrNilNotRoot // PtrHeadNumberPtrNilNotRoot
{ {
@ -695,6 +888,16 @@ func TestCoverNumber(t *testing.T) {
A *json.Number `json:"a,string"` A *json.Number `json:"a,string"`
}{A: nil})}, }{A: nil})},
}, },
{
name: "PtrHeadNumberPtrNilNotRootStringOmitEmpty",
data: struct {
A *struct {
A *json.Number `json:"a,string,omitempty"`
}
}{A: &(struct {
A *json.Number `json:"a,string,omitempty"`
}{A: nil})},
},
// PtrHeadNumberNilNotRoot // PtrHeadNumberNilNotRoot
{ {
@ -721,6 +924,14 @@ func TestCoverNumber(t *testing.T) {
} `json:",string"` } `json:",string"`
}{A: nil}, }{A: nil},
}, },
{
name: "PtrHeadNumberNilNotRootStringOmitEmpty",
data: struct {
A *struct {
A *json.Number `json:"a,string,omitempty"`
} `json:",string,omitempty"`
}{A: nil},
},
// HeadNumberZeroMultiFieldsNotRoot // HeadNumberZeroMultiFieldsNotRoot
{ {
@ -756,6 +967,17 @@ func TestCoverNumber(t *testing.T) {
} }
}{}, }{},
}, },
{
name: "HeadNumberZeroMultiFieldsNotRootStringOmitEmpty",
data: struct {
A struct {
A json.Number `json:"a,string,omitempty"`
}
B struct {
B json.Number `json:"b,string,omitempty"`
}
}{},
},
// HeadNumberMultiFieldsNotRoot // HeadNumberMultiFieldsNotRoot
{ {
@ -803,6 +1025,21 @@ func TestCoverNumber(t *testing.T) {
B json.Number `json:"b,string"` B json.Number `json:"b,string"`
}{B: "2"}}, }{B: "2"}},
}, },
{
name: "HeadNumberMultiFieldsNotRootStringOmitEmpty",
data: struct {
A struct {
A json.Number `json:"a,string,omitempty"`
}
B struct {
B json.Number `json:"b,string,omitempty"`
}
}{A: struct {
A json.Number `json:"a,string,omitempty"`
}{A: "1"}, B: struct {
B json.Number `json:"b,string,omitempty"`
}{B: "2"}},
},
// HeadNumberPtrMultiFieldsNotRoot // HeadNumberPtrMultiFieldsNotRoot
{ {
@ -850,6 +1087,21 @@ func TestCoverNumber(t *testing.T) {
B *json.Number `json:"b,string"` B *json.Number `json:"b,string"`
}{B: numberptr("2")}}, }{B: numberptr("2")}},
}, },
{
name: "HeadNumberPtrMultiFieldsNotRootStringOmitEmpty",
data: struct {
A struct {
A *json.Number `json:"a,string,omitempty"`
}
B struct {
B *json.Number `json:"b,string,omitempty"`
}
}{A: struct {
A *json.Number `json:"a,string,omitempty"`
}{A: numberptr("1")}, B: struct {
B *json.Number `json:"b,string,omitempty"`
}{B: numberptr("2")}},
},
// HeadNumberPtrNilMultiFieldsNotRoot // HeadNumberPtrNilMultiFieldsNotRoot
{ {
@ -897,6 +1149,21 @@ func TestCoverNumber(t *testing.T) {
B *json.Number `json:"b,string"` B *json.Number `json:"b,string"`
}{B: nil}}, }{B: nil}},
}, },
{
name: "HeadNumberPtrNilMultiFieldsNotRootStringOmitEmpty",
data: struct {
A struct {
A *json.Number `json:"a,string,omitempty"`
}
B struct {
B *json.Number `json:"b,string,omitempty"`
}
}{A: struct {
A *json.Number `json:"a,string,omitempty"`
}{A: nil}, B: struct {
B *json.Number `json:"b,string,omitempty"`
}{B: nil}},
},
// PtrHeadNumberZeroMultiFieldsNotRoot // PtrHeadNumberZeroMultiFieldsNotRoot
{ {
@ -932,6 +1199,17 @@ func TestCoverNumber(t *testing.T) {
} }
}{}, }{},
}, },
{
name: "PtrHeadNumberZeroMultiFieldsNotRootStringOmitEmpty",
data: &struct {
A struct {
A json.Number `json:"a,string,omitempty"`
}
B struct {
B json.Number `json:"b,string,omitempty"`
}
}{},
},
// PtrHeadNumberMultiFieldsNotRoot // PtrHeadNumberMultiFieldsNotRoot
{ {
@ -979,6 +1257,21 @@ func TestCoverNumber(t *testing.T) {
B json.Number `json:"b,string"` B json.Number `json:"b,string"`
}{B: "2"}}, }{B: "2"}},
}, },
{
name: "PtrHeadNumberMultiFieldsNotRootStringOmitEmpty",
data: &struct {
A struct {
A json.Number `json:"a,string,omitempty"`
}
B struct {
B json.Number `json:"b,string,omitempty"`
}
}{A: struct {
A json.Number `json:"a,string,omitempty"`
}{A: "1"}, B: struct {
B json.Number `json:"b,string,omitempty"`
}{B: "2"}},
},
// PtrHeadNumberPtrMultiFieldsNotRoot // PtrHeadNumberPtrMultiFieldsNotRoot
{ {
@ -1026,6 +1319,21 @@ func TestCoverNumber(t *testing.T) {
B *json.Number `json:"b,string"` B *json.Number `json:"b,string"`
}{B: numberptr("2")})}, }{B: numberptr("2")})},
}, },
{
name: "PtrHeadNumberPtrMultiFieldsNotRootStringOmitEmpty",
data: &struct {
A *struct {
A *json.Number `json:"a,string,omitempty"`
}
B *struct {
B *json.Number `json:"b,string,omitempty"`
}
}{A: &(struct {
A *json.Number `json:"a,string,omitempty"`
}{A: numberptr("1")}), B: &(struct {
B *json.Number `json:"b,string,omitempty"`
}{B: numberptr("2")})},
},
// PtrHeadNumberPtrNilMultiFieldsNotRoot // PtrHeadNumberPtrNilMultiFieldsNotRoot
{ {
@ -1061,6 +1369,17 @@ func TestCoverNumber(t *testing.T) {
} `json:",string"` } `json:",string"`
}{A: nil, B: nil}, }{A: nil, B: nil},
}, },
{
name: "PtrHeadNumberPtrNilMultiFieldsNotRootStringOmitEmpty",
data: &struct {
A *struct {
A *json.Number `json:"a,string,omitempty"`
} `json:",string,omitempty"`
B *struct {
B *json.Number `json:"b,string,omitempty"`
} `json:",string,omitempty"`
}{A: nil, B: nil},
},
// PtrHeadNumberNilMultiFieldsNotRoot // PtrHeadNumberNilMultiFieldsNotRoot
{ {
@ -1096,6 +1415,17 @@ func TestCoverNumber(t *testing.T) {
} }
})(nil), })(nil),
}, },
{
name: "PtrHeadNumberNilMultiFieldsNotRootStringOmitEmpty",
data: (*struct {
A *struct {
A *json.Number `json:"a,string,omitempty"`
}
B *struct {
B *json.Number `json:"b,string,omitempty"`
}
})(nil),
},
// PtrHeadNumberDoubleMultiFieldsNotRoot // PtrHeadNumberDoubleMultiFieldsNotRoot
{ {
@ -1155,6 +1485,25 @@ func TestCoverNumber(t *testing.T) {
B json.Number `json:"b,string"` B json.Number `json:"b,string"`
}{A: "3", B: "4"})}, }{A: "3", B: "4"})},
}, },
{
name: "PtrHeadNumberDoubleMultiFieldsNotRootStringOmitEmpty",
data: &struct {
A *struct {
A json.Number `json:"a,string,omitempty"`
B json.Number `json:"b,string,omitempty"`
}
B *struct {
A json.Number `json:"a,string,omitempty"`
B json.Number `json:"b,string,omitempty"`
}
}{A: &(struct {
A json.Number `json:"a,string,omitempty"`
B json.Number `json:"b,string,omitempty"`
}{A: "1", B: "2"}), B: &(struct {
A json.Number `json:"a,string,omitempty"`
B json.Number `json:"b,string,omitempty"`
}{A: "3", B: "4"})},
},
// PtrHeadNumberNilDoubleMultiFieldsNotRoot // PtrHeadNumberNilDoubleMultiFieldsNotRoot
{ {
@ -1196,6 +1545,19 @@ func TestCoverNumber(t *testing.T) {
} }
}{A: nil, B: nil}, }{A: nil, B: nil},
}, },
{
name: "PtrHeadNumberNilDoubleMultiFieldsNotRootStringOmitEmpty",
data: &struct {
A *struct {
A json.Number `json:"a,string,omitempty"`
B json.Number `json:"b,string,omitempty"`
}
B *struct {
A json.Number `json:"a,string,omitempty"`
B json.Number `json:"b,string,omitempty"`
}
}{A: nil, B: nil},
},
// PtrHeadNumberNilDoubleMultiFieldsNotRoot // PtrHeadNumberNilDoubleMultiFieldsNotRoot
{ {
@ -1237,6 +1599,19 @@ func TestCoverNumber(t *testing.T) {
} }
})(nil), })(nil),
}, },
{
name: "PtrHeadNumberNilDoubleMultiFieldsNotRootStringOmitEmpty",
data: (*struct {
A *struct {
A json.Number `json:"a,string,omitempty"`
B json.Number `json:"b,string,omitempty"`
}
B *struct {
A json.Number `json:"a,string,omitempty"`
B json.Number `json:"b,string,omitempty"`
}
})(nil),
},
// PtrHeadNumberPtrDoubleMultiFieldsNotRoot // PtrHeadNumberPtrDoubleMultiFieldsNotRoot
{ {
@ -1296,6 +1671,25 @@ func TestCoverNumber(t *testing.T) {
B *json.Number `json:"b,string"` B *json.Number `json:"b,string"`
}{A: numberptr("3"), B: numberptr("4")})}, }{A: numberptr("3"), B: numberptr("4")})},
}, },
{
name: "PtrHeadNumberPtrDoubleMultiFieldsNotRootStringOmitEmpty",
data: &struct {
A *struct {
A *json.Number `json:"a,string,omitempty"`
B *json.Number `json:"b,string,omitempty"`
}
B *struct {
A *json.Number `json:"a,string,omitempty"`
B *json.Number `json:"b,string,omitempty"`
}
}{A: &(struct {
A *json.Number `json:"a,string,omitempty"`
B *json.Number `json:"b,string,omitempty"`
}{A: numberptr("1"), B: numberptr("2")}), B: &(struct {
A *json.Number `json:"a,string,omitempty"`
B *json.Number `json:"b,string,omitempty"`
}{A: numberptr("3"), B: numberptr("4")})},
},
// PtrHeadNumberPtrNilDoubleMultiFieldsNotRoot // PtrHeadNumberPtrNilDoubleMultiFieldsNotRoot
{ {
@ -1337,6 +1731,19 @@ func TestCoverNumber(t *testing.T) {
} }
}{A: nil, B: nil}, }{A: nil, B: nil},
}, },
{
name: "PtrHeadNumberPtrNilDoubleMultiFieldsNotRootStringOmitEmpty",
data: &struct {
A *struct {
A *json.Number `json:"a,string,omitempty"`
B *json.Number `json:"b,string,omitempty"`
}
B *struct {
A *json.Number `json:"a,string,omitempty"`
B *json.Number `json:"b,string,omitempty"`
}
}{A: nil, B: nil},
},
// PtrHeadNumberPtrNilDoubleMultiFieldsNotRoot // PtrHeadNumberPtrNilDoubleMultiFieldsNotRoot
{ {
@ -1378,6 +1785,19 @@ func TestCoverNumber(t *testing.T) {
} }
})(nil), })(nil),
}, },
{
name: "PtrHeadNumberPtrNilDoubleMultiFieldsNotRootStringOmitEmpty",
data: (*struct {
A *struct {
A *json.Number `json:"a,string,omitempty"`
B *json.Number `json:"b,string,omitempty"`
}
B *struct {
A *json.Number `json:"a,string,omitempty"`
B *json.Number `json:"b,string,omitempty"`
}
})(nil),
},
// AnonymousHeadNumber // AnonymousHeadNumber
{ {
@ -1410,6 +1830,16 @@ func TestCoverNumber(t *testing.T) {
B: "2", B: "2",
}, },
}, },
{
name: "AnonymousHeadNumberStringOmitEmpty",
data: struct {
structNumberStringOmitEmpty
B json.Number `json:"b,string,omitempty"`
}{
structNumberStringOmitEmpty: structNumberStringOmitEmpty{A: "1"},
B: "2",
},
},
// PtrAnonymousHeadNumber // PtrAnonymousHeadNumber
{ {
@ -1442,6 +1872,16 @@ func TestCoverNumber(t *testing.T) {
B: "2", B: "2",
}, },
}, },
{
name: "PtrAnonymousHeadNumberStringOmitEmpty",
data: struct {
*structNumberStringOmitEmpty
B json.Number `json:"b,string,omitempty"`
}{
structNumberStringOmitEmpty: &structNumberStringOmitEmpty{A: "1"},
B: "2",
},
},
// NilPtrAnonymousHeadNumber // NilPtrAnonymousHeadNumber
{ {
@ -1474,6 +1914,16 @@ func TestCoverNumber(t *testing.T) {
B: "2", B: "2",
}, },
}, },
{
name: "NilPtrAnonymousHeadNumberStringOmitEmpty",
data: struct {
*structNumberStringOmitEmpty
B json.Number `json:"b,string,omitempty"`
}{
structNumberStringOmitEmpty: nil,
B: "2",
},
},
// AnonymousHeadNumberPtr // AnonymousHeadNumberPtr
{ {
@ -1506,6 +1956,16 @@ func TestCoverNumber(t *testing.T) {
B: numberptr("2"), B: numberptr("2"),
}, },
}, },
{
name: "AnonymousHeadNumberPtrStringOmitEmpty",
data: struct {
structNumberPtrStringOmitEmpty
B *json.Number `json:"b,string,omitempty"`
}{
structNumberPtrStringOmitEmpty: structNumberPtrStringOmitEmpty{A: numberptr("1")},
B: numberptr("2"),
},
},
// AnonymousHeadNumberPtrNil // AnonymousHeadNumberPtrNil
{ {
@ -1538,6 +1998,16 @@ func TestCoverNumber(t *testing.T) {
B: numberptr("2"), B: numberptr("2"),
}, },
}, },
{
name: "AnonymousHeadNumberPtrNilStringOmitEmpty",
data: struct {
structNumberPtrStringOmitEmpty
B *json.Number `json:"b,string,omitempty"`
}{
structNumberPtrStringOmitEmpty: structNumberPtrStringOmitEmpty{A: nil},
B: numberptr("2"),
},
},
// PtrAnonymousHeadNumberPtr // PtrAnonymousHeadNumberPtr
{ {
@ -1570,6 +2040,16 @@ func TestCoverNumber(t *testing.T) {
B: numberptr("2"), B: numberptr("2"),
}, },
}, },
{
name: "PtrAnonymousHeadNumberPtrStringOmitEmpty",
data: struct {
*structNumberPtrStringOmitEmpty
B *json.Number `json:"b,string,omitempty"`
}{
structNumberPtrStringOmitEmpty: &structNumberPtrStringOmitEmpty{A: numberptr("1")},
B: numberptr("2"),
},
},
// NilPtrAnonymousHeadNumberPtr // NilPtrAnonymousHeadNumberPtr
{ {
@ -1602,6 +2082,16 @@ func TestCoverNumber(t *testing.T) {
B: numberptr("2"), B: numberptr("2"),
}, },
}, },
{
name: "NilPtrAnonymousHeadNumberPtrStringOmitEmpty",
data: struct {
*structNumberPtrStringOmitEmpty
B *json.Number `json:"b,string,omitempty"`
}{
structNumberPtrStringOmitEmpty: nil,
B: numberptr("2"),
},
},
// AnonymousHeadNumberOnly // AnonymousHeadNumberOnly
{ {
@ -1628,6 +2118,14 @@ func TestCoverNumber(t *testing.T) {
structNumberString: structNumberString{A: "1"}, structNumberString: structNumberString{A: "1"},
}, },
}, },
{
name: "AnonymousHeadNumberOnlyStringOmitEmpty",
data: struct {
structNumberStringOmitEmpty
}{
structNumberStringOmitEmpty: structNumberStringOmitEmpty{A: "1"},
},
},
// PtrAnonymousHeadNumberOnly // PtrAnonymousHeadNumberOnly
{ {
@ -1654,6 +2152,14 @@ func TestCoverNumber(t *testing.T) {
structNumberString: &structNumberString{A: "1"}, structNumberString: &structNumberString{A: "1"},
}, },
}, },
{
name: "PtrAnonymousHeadNumberOnlyStringOmitEmpty",
data: struct {
*structNumberStringOmitEmpty
}{
structNumberStringOmitEmpty: &structNumberStringOmitEmpty{A: "1"},
},
},
// NilPtrAnonymousHeadNumberOnly // NilPtrAnonymousHeadNumberOnly
{ {
@ -1680,6 +2186,14 @@ func TestCoverNumber(t *testing.T) {
structNumberString: nil, structNumberString: nil,
}, },
}, },
{
name: "NilPtrAnonymousHeadNumberOnlyStringOmitEmpty",
data: struct {
*structNumberStringOmitEmpty
}{
structNumberStringOmitEmpty: nil,
},
},
// AnonymousHeadNumberPtrOnly // AnonymousHeadNumberPtrOnly
{ {
@ -1706,6 +2220,14 @@ func TestCoverNumber(t *testing.T) {
structNumberPtrString: structNumberPtrString{A: numberptr("1")}, structNumberPtrString: structNumberPtrString{A: numberptr("1")},
}, },
}, },
{
name: "AnonymousHeadNumberPtrOnlyStringOmitEmpty",
data: struct {
structNumberPtrStringOmitEmpty
}{
structNumberPtrStringOmitEmpty: structNumberPtrStringOmitEmpty{A: numberptr("1")},
},
},
// AnonymousHeadNumberPtrNilOnly // AnonymousHeadNumberPtrNilOnly
{ {
@ -1732,6 +2254,14 @@ func TestCoverNumber(t *testing.T) {
structNumberPtrString: structNumberPtrString{A: nil}, structNumberPtrString: structNumberPtrString{A: nil},
}, },
}, },
{
name: "AnonymousHeadNumberPtrNilOnlyStringOmitEmpty",
data: struct {
structNumberPtrStringOmitEmpty
}{
structNumberPtrStringOmitEmpty: structNumberPtrStringOmitEmpty{A: nil},
},
},
// PtrAnonymousHeadNumberPtrOnly // PtrAnonymousHeadNumberPtrOnly
{ {
@ -1758,6 +2288,14 @@ func TestCoverNumber(t *testing.T) {
structNumberPtrString: &structNumberPtrString{A: numberptr("1")}, structNumberPtrString: &structNumberPtrString{A: numberptr("1")},
}, },
}, },
{
name: "PtrAnonymousHeadNumberPtrOnlyStringOmitEmpty",
data: struct {
*structNumberPtrStringOmitEmpty
}{
structNumberPtrStringOmitEmpty: &structNumberPtrStringOmitEmpty{A: numberptr("1")},
},
},
// NilPtrAnonymousHeadNumberPtrOnly // NilPtrAnonymousHeadNumberPtrOnly
{ {
@ -1784,6 +2322,14 @@ func TestCoverNumber(t *testing.T) {
structNumberPtrString: nil, structNumberPtrString: nil,
}, },
}, },
{
name: "NilPtrAnonymousHeadNumberPtrOnlyStringOmitEmpty",
data: struct {
*structNumberPtrStringOmitEmpty
}{
structNumberPtrStringOmitEmpty: nil,
},
},
} }
for _, test := range tests { for _, test := range tests {
for _, indent := range []bool{true, false} { for _, indent := range []bool{true, false} {

View File

@ -17,6 +17,9 @@ func TestCoverString(t *testing.T) {
type structStringString struct { type structStringString struct {
A string `json:"a,string"` A string `json:"a,string"`
} }
type structStringStringOmitEmpty struct {
A string `json:"a,string,omitempty"`
}
type structStringPtr struct { type structStringPtr struct {
A *string `json:"a"` A *string `json:"a"`
@ -27,6 +30,9 @@ func TestCoverString(t *testing.T) {
type structStringPtrString struct { type structStringPtrString struct {
A *string `json:"a,string"` A *string `json:"a,string"`
} }
type structStringPtrStringOmitEmpty struct {
A *string `json:"a,string,omitempty"`
}
tests := []struct { tests := []struct {
name string name string
@ -84,6 +90,12 @@ func TestCoverString(t *testing.T) {
A string `json:"a,string"` A string `json:"a,string"`
}{}, }{},
}, },
{
name: "HeadStringZeroStringOmitEmpty",
data: struct {
A string `json:"a,string,omitempty"`
}{},
},
// HeadString // HeadString
{ {
@ -104,6 +116,12 @@ func TestCoverString(t *testing.T) {
A string `json:"a,string"` A string `json:"a,string"`
}{A: "foo"}, }{A: "foo"},
}, },
{
name: "HeadStringStringOmitEmpty",
data: struct {
A string `json:"a,string,omitempty"`
}{A: "foo"},
},
// HeadStringPtr // HeadStringPtr
{ {
@ -124,6 +142,12 @@ func TestCoverString(t *testing.T) {
A *string `json:"a,string"` A *string `json:"a,string"`
}{A: stringptr("foo")}, }{A: stringptr("foo")},
}, },
{
name: "HeadStringPtrStringOmitEmpty",
data: struct {
A *string `json:"a,string,omitempty"`
}{A: stringptr("foo")},
},
// HeadStringPtrNil // HeadStringPtrNil
{ {
@ -144,6 +168,12 @@ func TestCoverString(t *testing.T) {
A *string `json:"a,string"` A *string `json:"a,string"`
}{A: nil}, }{A: nil},
}, },
{
name: "HeadStringPtrNilStringOmitEmpty",
data: struct {
A *string `json:"a,string,omitempty"`
}{A: nil},
},
// PtrHeadStringZero // PtrHeadStringZero
{ {
@ -164,6 +194,12 @@ func TestCoverString(t *testing.T) {
A string `json:"a,string"` A string `json:"a,string"`
}{}, }{},
}, },
{
name: "PtrHeadStringZeroStringOmitEmpty",
data: &struct {
A string `json:"a,string,omitempty"`
}{},
},
// PtrHeadString // PtrHeadString
{ {
@ -184,6 +220,12 @@ func TestCoverString(t *testing.T) {
A string `json:"a,string"` A string `json:"a,string"`
}{A: "foo"}, }{A: "foo"},
}, },
{
name: "PtrHeadStringStringOmitEmpty",
data: &struct {
A string `json:"a,string,omitempty"`
}{A: "foo"},
},
// PtrHeadStringPtr // PtrHeadStringPtr
{ {
@ -204,6 +246,12 @@ func TestCoverString(t *testing.T) {
A *string `json:"a,string"` A *string `json:"a,string"`
}{A: stringptr("foo")}, }{A: stringptr("foo")},
}, },
{
name: "PtrHeadStringPtrStringOmitEmpty",
data: &struct {
A *string `json:"a,string,omitempty"`
}{A: stringptr("foo")},
},
// PtrHeadStringPtrNil // PtrHeadStringPtrNil
{ {
@ -224,6 +272,12 @@ func TestCoverString(t *testing.T) {
A *string `json:"a,string"` A *string `json:"a,string"`
}{A: nil}, }{A: nil},
}, },
{
name: "PtrHeadStringPtrNilStringOmitEmpty",
data: &struct {
A *string `json:"a,string,omitempty"`
}{A: nil},
},
// PtrHeadStringNil // PtrHeadStringNil
{ {
@ -244,6 +298,12 @@ func TestCoverString(t *testing.T) {
A *string `json:"a,string"` A *string `json:"a,string"`
})(nil), })(nil),
}, },
{
name: "PtrHeadStringNilStringOmitEmpty",
data: (*struct {
A *string `json:"a,string,omitempty"`
})(nil),
},
// HeadStringZeroMultiFields // HeadStringZeroMultiFields
{ {
@ -270,6 +330,14 @@ func TestCoverString(t *testing.T) {
C string `json:"c,string"` C string `json:"c,string"`
}{}, }{},
}, },
{
name: "HeadStringZeroMultiFieldsStringOmitEmpty",
data: struct {
A string `json:"a,string,omitempty"`
B string `json:"b,string,omitempty"`
C string `json:"c,string,omitempty"`
}{},
},
// HeadStringMultiFields // HeadStringMultiFields
{ {
@ -296,6 +364,14 @@ func TestCoverString(t *testing.T) {
C string `json:"c,string"` C string `json:"c,string"`
}{A: "foo", B: "bar", C: "baz"}, }{A: "foo", B: "bar", C: "baz"},
}, },
{
name: "HeadStringMultiFieldsStringOmitEmpty",
data: struct {
A string `json:"a,string,omitempty"`
B string `json:"b,string,omitempty"`
C string `json:"c,string,omitempty"`
}{A: "foo", B: "bar", C: "baz"},
},
// HeadStringPtrMultiFields // HeadStringPtrMultiFields
{ {
@ -322,6 +398,14 @@ func TestCoverString(t *testing.T) {
C *string `json:"c,string"` C *string `json:"c,string"`
}{A: stringptr("foo"), B: stringptr("bar"), C: stringptr("baz")}, }{A: stringptr("foo"), B: stringptr("bar"), C: stringptr("baz")},
}, },
{
name: "HeadStringPtrMultiFieldsStringOmitEmpty",
data: struct {
A *string `json:"a,string,omitempty"`
B *string `json:"b,string,omitempty"`
C *string `json:"c,string,omitempty"`
}{A: stringptr("foo"), B: stringptr("bar"), C: stringptr("baz")},
},
// HeadStringPtrNilMultiFields // HeadStringPtrNilMultiFields
{ {
@ -348,6 +432,14 @@ func TestCoverString(t *testing.T) {
C *string `json:"c,string"` C *string `json:"c,string"`
}{A: nil, B: nil, C: nil}, }{A: nil, B: nil, C: nil},
}, },
{
name: "HeadStringPtrNilMultiFieldsStringOmitEmpty",
data: struct {
A *string `json:"a,string,omitempty"`
B *string `json:"b,string,omitempty"`
C *string `json:"c,string,omitempty"`
}{A: nil, B: nil, C: nil},
},
// PtrHeadStringZeroMultiFields // PtrHeadStringZeroMultiFields
{ {
@ -374,6 +466,14 @@ func TestCoverString(t *testing.T) {
C string `json:"c,string"` C string `json:"c,string"`
}{}, }{},
}, },
{
name: "PtrHeadStringZeroMultiFieldsStringOmitEmpty",
data: &struct {
A string `json:"a,string,omitempty"`
B string `json:"b,string,omitempty"`
C string `json:"c,string,omitempty"`
}{},
},
// PtrHeadStringMultiFields // PtrHeadStringMultiFields
{ {
@ -400,6 +500,14 @@ func TestCoverString(t *testing.T) {
C string `json:"c,string"` C string `json:"c,string"`
}{A: "foo", B: "bar", C: "baz"}, }{A: "foo", B: "bar", C: "baz"},
}, },
{
name: "PtrHeadStringMultiFieldsStringOmitEmpty",
data: &struct {
A string `json:"a,string,omitempty"`
B string `json:"b,string,omitempty"`
C string `json:"c,string,omitempty"`
}{A: "foo", B: "bar", C: "baz"},
},
// PtrHeadStringPtrMultiFields // PtrHeadStringPtrMultiFields
{ {
@ -426,6 +534,14 @@ func TestCoverString(t *testing.T) {
C *string `json:"c,string"` C *string `json:"c,string"`
}{A: stringptr("foo"), B: stringptr("bar"), C: stringptr("baz")}, }{A: stringptr("foo"), B: stringptr("bar"), C: stringptr("baz")},
}, },
{
name: "PtrHeadStringPtrMultiFieldsStringOmitEmpty",
data: &struct {
A *string `json:"a,string,omitempty"`
B *string `json:"b,string,omitempty"`
C *string `json:"c,string,omitempty"`
}{A: stringptr("foo"), B: stringptr("bar"), C: stringptr("baz")},
},
// PtrHeadStringPtrNilMultiFields // PtrHeadStringPtrNilMultiFields
{ {
@ -452,6 +568,14 @@ func TestCoverString(t *testing.T) {
C *string `json:"c,string"` C *string `json:"c,string"`
}{A: nil, B: nil, C: nil}, }{A: nil, B: nil, C: nil},
}, },
{
name: "PtrHeadStringPtrNilMultiFieldsStringOmitEmpty",
data: &struct {
A *string `json:"a,string,omitempty"`
B *string `json:"b,string,omitempty"`
C *string `json:"c,string,omitempty"`
}{A: nil, B: nil, C: nil},
},
// PtrHeadStringNilMultiFields // PtrHeadStringNilMultiFields
{ {
@ -478,6 +602,14 @@ func TestCoverString(t *testing.T) {
C *string `json:"c,string"` C *string `json:"c,string"`
})(nil), })(nil),
}, },
{
name: "PtrHeadStringNilMultiFieldsStringOmitEmpty",
data: (*struct {
A *string `json:"a,string,omitempty"`
B *string `json:"b,string,omitempty"`
C *string `json:"c,string,omitempty"`
})(nil),
},
// HeadStringZeroNotRoot // HeadStringZeroNotRoot
{ {
@ -504,6 +636,14 @@ func TestCoverString(t *testing.T) {
} }
}{}, }{},
}, },
{
name: "HeadStringZeroNotRootStringOmitEmpty",
data: struct {
A struct {
A string `json:"a,string,omitempty"`
}
}{},
},
// HeadStringNotRoot // HeadStringNotRoot
{ {
@ -536,6 +676,16 @@ func TestCoverString(t *testing.T) {
A string `json:"a,string"` A string `json:"a,string"`
}{A: "foo"}}, }{A: "foo"}},
}, },
{
name: "HeadStringNotRootStringOmitEmpty",
data: struct {
A struct {
A string `json:"a,string,omitempty"`
}
}{A: struct {
A string `json:"a,string,omitempty"`
}{A: "foo"}},
},
// HeadStringPtrNotRoot // HeadStringPtrNotRoot
{ {
@ -568,6 +718,16 @@ func TestCoverString(t *testing.T) {
A *string `json:"a,string"` A *string `json:"a,string"`
}{stringptr("foo")}}, }{stringptr("foo")}},
}, },
{
name: "HeadStringPtrNotRootStringOmitEmpty",
data: struct {
A struct {
A *string `json:"a,string,omitempty"`
}
}{A: struct {
A *string `json:"a,string,omitempty"`
}{stringptr("foo")}},
},
// HeadStringPtrNilNotRoot // HeadStringPtrNilNotRoot
{ {
@ -594,6 +754,14 @@ func TestCoverString(t *testing.T) {
} }
}{}, }{},
}, },
{
name: "HeadStringPtrNilNotRootStringOmitEmpty",
data: struct {
A struct {
A *string `json:"a,string,omitempty"`
}
}{},
},
// PtrHeadStringZeroNotRoot // PtrHeadStringZeroNotRoot
{ {
@ -626,6 +794,16 @@ func TestCoverString(t *testing.T) {
A string `json:"a,string"` A string `json:"a,string"`
})}, })},
}, },
{
name: "PtrHeadStringZeroNotRootStringOmitEmpty",
data: struct {
A *struct {
A string `json:"a,string,omitempty"`
}
}{A: new(struct {
A string `json:"a,string,omitempty"`
})},
},
// PtrHeadStringNotRoot // PtrHeadStringNotRoot
{ {
@ -658,6 +836,16 @@ func TestCoverString(t *testing.T) {
A string `json:"a,string"` A string `json:"a,string"`
}{A: "foo"})}, }{A: "foo"})},
}, },
{
name: "PtrHeadStringNotRootStringOmitEmpty",
data: struct {
A *struct {
A string `json:"a,string,omitempty"`
}
}{A: &(struct {
A string `json:"a,string,omitempty"`
}{A: "foo"})},
},
// PtrHeadStringPtrNotRoot // PtrHeadStringPtrNotRoot
{ {
@ -690,6 +878,16 @@ func TestCoverString(t *testing.T) {
A *string `json:"a,string"` A *string `json:"a,string"`
}{A: stringptr("foo")})}, }{A: stringptr("foo")})},
}, },
{
name: "PtrHeadStringPtrNotRootStringOmitEmpty",
data: struct {
A *struct {
A *string `json:"a,string,omitempty"`
}
}{A: &(struct {
A *string `json:"a,string,omitempty"`
}{A: stringptr("foo")})},
},
// PtrHeadStringPtrNilNotRoot // PtrHeadStringPtrNilNotRoot
{ {
@ -722,6 +920,16 @@ func TestCoverString(t *testing.T) {
A *string `json:"a,string"` A *string `json:"a,string"`
}{A: nil})}, }{A: nil})},
}, },
{
name: "PtrHeadStringPtrNilNotRootStringOmitEmpty",
data: struct {
A *struct {
A *string `json:"a,string,omitempty"`
}
}{A: &(struct {
A *string `json:"a,string,omitempty"`
}{A: nil})},
},
// PtrHeadStringNilNotRoot // PtrHeadStringNilNotRoot
{ {
@ -748,6 +956,14 @@ func TestCoverString(t *testing.T) {
} `json:",string"` } `json:",string"`
}{A: nil}, }{A: nil},
}, },
{
name: "PtrHeadStringNilNotRootStringOmitEmpty",
data: struct {
A *struct {
A *string `json:"a,string,omitempty"`
} `json:",string,omitempty"`
}{A: nil},
},
// HeadStringZeroMultiFieldsNotRoot // HeadStringZeroMultiFieldsNotRoot
{ {
@ -783,6 +999,17 @@ func TestCoverString(t *testing.T) {
} }
}{}, }{},
}, },
{
name: "HeadStringZeroMultiFieldsNotRootStringOmitEmpty",
data: struct {
A struct {
A string `json:"a,string,omitempty"`
}
B struct {
B string `json:"b,string,omitempty"`
}
}{},
},
// HeadStringMultiFieldsNotRoot // HeadStringMultiFieldsNotRoot
{ {
@ -830,6 +1057,21 @@ func TestCoverString(t *testing.T) {
B string `json:"b,string"` B string `json:"b,string"`
}{B: "bar"}}, }{B: "bar"}},
}, },
{
name: "HeadStringMultiFieldsNotRootStringOmitEmpty",
data: struct {
A struct {
A string `json:"a,string,omitempty"`
}
B struct {
B string `json:"b,string,omitempty"`
}
}{A: struct {
A string `json:"a,string,omitempty"`
}{A: "foo"}, B: struct {
B string `json:"b,string,omitempty"`
}{B: "bar"}},
},
// HeadStringPtrMultiFieldsNotRoot // HeadStringPtrMultiFieldsNotRoot
{ {
@ -877,6 +1119,21 @@ func TestCoverString(t *testing.T) {
B *string `json:"b,string"` B *string `json:"b,string"`
}{B: stringptr("bar")}}, }{B: stringptr("bar")}},
}, },
{
name: "HeadStringPtrMultiFieldsNotRootStringOmitEmpty",
data: struct {
A struct {
A *string `json:"a,string,omitempty"`
}
B struct {
B *string `json:"b,string,omitempty"`
}
}{A: struct {
A *string `json:"a,string,omitempty"`
}{A: stringptr("foo")}, B: struct {
B *string `json:"b,string,omitempty"`
}{B: stringptr("bar")}},
},
// HeadStringPtrNilMultiFieldsNotRoot // HeadStringPtrNilMultiFieldsNotRoot
{ {
@ -924,6 +1181,21 @@ func TestCoverString(t *testing.T) {
B *string `json:"b,string"` B *string `json:"b,string"`
}{B: nil}}, }{B: nil}},
}, },
{
name: "HeadStringPtrNilMultiFieldsNotRootStringOmitEmpty",
data: struct {
A struct {
A *string `json:"a,string,omitempty"`
}
B struct {
B *string `json:"b,string,omitempty"`
}
}{A: struct {
A *string `json:"a,string,omitempty"`
}{A: nil}, B: struct {
B *string `json:"b,string,omitempty"`
}{B: nil}},
},
// PtrHeadStringZeroMultiFieldsNotRoot // PtrHeadStringZeroMultiFieldsNotRoot
{ {
@ -959,6 +1231,17 @@ func TestCoverString(t *testing.T) {
} }
}{}, }{},
}, },
{
name: "PtrHeadStringZeroMultiFieldsNotRootStringOmitEmpty",
data: &struct {
A struct {
A string `json:"a,string,omitempty"`
}
B struct {
B string `json:"b,string,omitempty"`
}
}{},
},
// PtrHeadStringMultiFieldsNotRoot // PtrHeadStringMultiFieldsNotRoot
{ {
@ -1006,6 +1289,21 @@ func TestCoverString(t *testing.T) {
B string `json:"b,string"` B string `json:"b,string"`
}{B: "bar"}}, }{B: "bar"}},
}, },
{
name: "PtrHeadStringMultiFieldsNotRootStringOmitEmpty",
data: &struct {
A struct {
A string `json:"a,string,omitempty"`
}
B struct {
B string `json:"b,string,omitempty"`
}
}{A: struct {
A string `json:"a,string,omitempty"`
}{A: "foo"}, B: struct {
B string `json:"b,string,omitempty"`
}{B: "bar"}},
},
// PtrHeadStringPtrMultiFieldsNotRoot // PtrHeadStringPtrMultiFieldsNotRoot
{ {
@ -1053,6 +1351,21 @@ func TestCoverString(t *testing.T) {
B *string `json:"b,string"` B *string `json:"b,string"`
}{B: stringptr("bar")})}, }{B: stringptr("bar")})},
}, },
{
name: "PtrHeadStringPtrMultiFieldsNotRootStringOmitEmpty",
data: &struct {
A *struct {
A *string `json:"a,string,omitempty"`
}
B *struct {
B *string `json:"b,string,omitempty"`
}
}{A: &(struct {
A *string `json:"a,string,omitempty"`
}{A: stringptr("foo")}), B: &(struct {
B *string `json:"b,string,omitempty"`
}{B: stringptr("bar")})},
},
// PtrHeadStringPtrNilMultiFieldsNotRoot // PtrHeadStringPtrNilMultiFieldsNotRoot
{ {
@ -1088,6 +1401,17 @@ func TestCoverString(t *testing.T) {
} }
}{A: nil, B: nil}, }{A: nil, B: nil},
}, },
{
name: "PtrHeadStringPtrNilMultiFieldsNotRootStringOmitEmpty",
data: &struct {
A *struct {
A *string `json:"a,string,omitempty"`
}
B *struct {
B *string `json:"b,string,omitempty"`
}
}{A: nil, B: nil},
},
// PtrHeadStringNilMultiFieldsNotRoot // PtrHeadStringNilMultiFieldsNotRoot
{ {
@ -1123,6 +1447,17 @@ func TestCoverString(t *testing.T) {
} }
})(nil), })(nil),
}, },
{
name: "PtrHeadStringNilMultiFieldsNotRootStringOmitEmpty",
data: (*struct {
A *struct {
A *string `json:"a,string,omitempty"`
}
B *struct {
B *string `json:"b,string,omitempty"`
}
})(nil),
},
// PtrHeadStringDoubleMultiFieldsNotRoot // PtrHeadStringDoubleMultiFieldsNotRoot
{ {
@ -1186,6 +1521,25 @@ func TestCoverString(t *testing.T) {
B string `json:"b,string"` B string `json:"b,string"`
}{A: "foo", B: "bar"})}, }{A: "foo", B: "bar"})},
}, },
{
name: "PtrHeadStringDoubleMultiFieldsNotRootStringOmitEmpty",
data: &struct {
A *struct {
A string `json:"a,string,omitempty"`
B string `json:"b,string,omitempty"`
}
B *struct {
A string `json:"a,string,omitempty"`
B string `json:"b,string,omitempty"`
}
}{A: &(struct {
A string `json:"a,string,omitempty"`
B string `json:"b,string,omitempty"`
}{A: "foo", B: "bar"}), B: &(struct {
A string `json:"a,string,omitempty"`
B string `json:"b,string,omitempty"`
}{A: "foo", B: "bar"})},
},
// PtrHeadStringNilDoubleMultiFieldsNotRoot // PtrHeadStringNilDoubleMultiFieldsNotRoot
{ {
@ -1227,6 +1581,19 @@ func TestCoverString(t *testing.T) {
} }
}{A: nil, B: nil}, }{A: nil, B: nil},
}, },
{
name: "PtrHeadStringNilDoubleMultiFieldsNotRootStringOmitEmpty",
data: &struct {
A *struct {
A string `json:"a,string,omitempty"`
B string `json:"b,string,omitempty"`
}
B *struct {
A string `json:"a,string,omitempty"`
B string `json:"b,string,omitempty"`
}
}{A: nil, B: nil},
},
// PtrHeadStringNilDoubleMultiFieldsNotRoot // PtrHeadStringNilDoubleMultiFieldsNotRoot
{ {
@ -1268,6 +1635,19 @@ func TestCoverString(t *testing.T) {
} }
})(nil), })(nil),
}, },
{
name: "PtrHeadStringNilDoubleMultiFieldsNotRootStringOmitEmpty",
data: (*struct {
A *struct {
A string `json:"a,string,omitempty"`
B string `json:"b,string,omitempty"`
}
B *struct {
A string `json:"a,string,omitempty"`
B string `json:"b,string,omitempty"`
}
})(nil),
},
// PtrHeadStringPtrDoubleMultiFieldsNotRoot // PtrHeadStringPtrDoubleMultiFieldsNotRoot
{ {
@ -1327,6 +1707,25 @@ func TestCoverString(t *testing.T) {
B *string `json:"b,string"` B *string `json:"b,string"`
}{A: stringptr("foo"), B: stringptr("bar")})}, }{A: stringptr("foo"), B: stringptr("bar")})},
}, },
{
name: "PtrHeadStringPtrDoubleMultiFieldsNotRootStringOmitEmpty",
data: &struct {
A *struct {
A *string `json:"a,string,omitempty"`
B *string `json:"b,string,omitempty"`
}
B *struct {
A *string `json:"a,string,omitempty"`
B *string `json:"b,string,omitempty"`
}
}{A: &(struct {
A *string `json:"a,string,omitempty"`
B *string `json:"b,string,omitempty"`
}{A: stringptr("foo"), B: stringptr("bar")}), B: &(struct {
A *string `json:"a,string,omitempty"`
B *string `json:"b,string,omitempty"`
}{A: stringptr("foo"), B: stringptr("bar")})},
},
// PtrHeadStringPtrNilDoubleMultiFieldsNotRoot // PtrHeadStringPtrNilDoubleMultiFieldsNotRoot
{ {
@ -1368,6 +1767,19 @@ func TestCoverString(t *testing.T) {
} }
}{A: nil, B: nil}, }{A: nil, B: nil},
}, },
{
name: "PtrHeadStringPtrNilDoubleMultiFieldsNotRootStringOmitEmpty",
data: &struct {
A *struct {
A *string `json:"a,string,omitempty"`
B *string `json:"b,string,omitempty"`
}
B *struct {
A *string `json:"a,string,omitempty"`
B *string `json:"b,string,omitempty"`
}
}{A: nil, B: nil},
},
// PtrHeadStringPtrNilDoubleMultiFieldsNotRoot // PtrHeadStringPtrNilDoubleMultiFieldsNotRoot
{ {
@ -1409,6 +1821,19 @@ func TestCoverString(t *testing.T) {
} }
})(nil), })(nil),
}, },
{
name: "PtrHeadStringPtrNilDoubleMultiFieldsNotRootStringOmitEmpty",
data: (*struct {
A *struct {
A *string `json:"a,string,omitempty"`
B *string `json:"b,string,omitempty"`
}
B *struct {
A *string `json:"a,string,omitempty"`
B *string `json:"b,string,omitempty"`
}
})(nil),
},
// AnonymousHeadString // AnonymousHeadString
{ {
@ -1441,6 +1866,16 @@ func TestCoverString(t *testing.T) {
B: "bar", B: "bar",
}, },
}, },
{
name: "AnonymousHeadStringStringOmitEmpty",
data: struct {
structStringStringOmitEmpty
B string `json:"b,string,omitempty"`
}{
structStringStringOmitEmpty: structStringStringOmitEmpty{A: "foo"},
B: "bar",
},
},
// PtrAnonymousHeadString // PtrAnonymousHeadString
{ {
@ -1473,6 +1908,16 @@ func TestCoverString(t *testing.T) {
B: "bar", B: "bar",
}, },
}, },
{
name: "PtrAnonymousHeadStringStringOmitEmpty",
data: struct {
*structStringStringOmitEmpty
B string `json:"b,string,omitempty"`
}{
structStringStringOmitEmpty: &structStringStringOmitEmpty{A: "foo"},
B: "bar",
},
},
// NilPtrAnonymousHeadString // NilPtrAnonymousHeadString
{ {
@ -1505,6 +1950,16 @@ func TestCoverString(t *testing.T) {
B: "baz", B: "baz",
}, },
}, },
{
name: "NilPtrAnonymousHeadStringStringOmitEmpty",
data: struct {
*structStringStringOmitEmpty
B string `json:"b,string,omitempty"`
}{
structStringStringOmitEmpty: nil,
B: "baz",
},
},
// AnonymousHeadStringPtr // AnonymousHeadStringPtr
{ {
@ -1537,6 +1992,16 @@ func TestCoverString(t *testing.T) {
B: stringptr("bar"), B: stringptr("bar"),
}, },
}, },
{
name: "AnonymousHeadStringPtrStringOmitEmpty",
data: struct {
structStringPtrStringOmitEmpty
B *string `json:"b,string,omitempty"`
}{
structStringPtrStringOmitEmpty: structStringPtrStringOmitEmpty{A: stringptr("foo")},
B: stringptr("bar"),
},
},
// AnonymousHeadStringPtrNil // AnonymousHeadStringPtrNil
{ {
@ -1569,6 +2034,16 @@ func TestCoverString(t *testing.T) {
B: stringptr("foo"), B: stringptr("foo"),
}, },
}, },
{
name: "AnonymousHeadStringPtrNilStringOmitEmpty",
data: struct {
structStringPtrStringOmitEmpty
B *string `json:"b,string,omitempty"`
}{
structStringPtrStringOmitEmpty: structStringPtrStringOmitEmpty{A: nil},
B: stringptr("foo"),
},
},
// PtrAnonymousHeadStringPtr // PtrAnonymousHeadStringPtr
{ {
@ -1601,6 +2076,16 @@ func TestCoverString(t *testing.T) {
B: stringptr("bar"), B: stringptr("bar"),
}, },
}, },
{
name: "PtrAnonymousHeadStringPtrStringOmitEmpty",
data: struct {
*structStringPtrStringOmitEmpty
B *string `json:"b,string,omitempty"`
}{
structStringPtrStringOmitEmpty: &structStringPtrStringOmitEmpty{A: stringptr("foo")},
B: stringptr("bar"),
},
},
// NilPtrAnonymousHeadStringPtr // NilPtrAnonymousHeadStringPtr
{ {
@ -1633,6 +2118,16 @@ func TestCoverString(t *testing.T) {
B: stringptr("foo"), B: stringptr("foo"),
}, },
}, },
{
name: "NilPtrAnonymousHeadStringPtrStringOmitEmpty",
data: struct {
*structStringPtrStringOmitEmpty
B *string `json:"b,string,omitempty"`
}{
structStringPtrStringOmitEmpty: nil,
B: stringptr("foo"),
},
},
// AnonymousHeadStringOnly // AnonymousHeadStringOnly
{ {
@ -1659,6 +2154,14 @@ func TestCoverString(t *testing.T) {
structStringString: structStringString{A: "foo"}, structStringString: structStringString{A: "foo"},
}, },
}, },
{
name: "AnonymousHeadStringOnlyStringOmitEmpty",
data: struct {
structStringStringOmitEmpty
}{
structStringStringOmitEmpty: structStringStringOmitEmpty{A: "foo"},
},
},
// PtrAnonymousHeadStringOnly // PtrAnonymousHeadStringOnly
{ {
@ -1685,6 +2188,14 @@ func TestCoverString(t *testing.T) {
structStringString: &structStringString{A: "foo"}, structStringString: &structStringString{A: "foo"},
}, },
}, },
{
name: "PtrAnonymousHeadStringOnlyStringOmitEmpty",
data: struct {
*structStringStringOmitEmpty
}{
structStringStringOmitEmpty: &structStringStringOmitEmpty{A: "foo"},
},
},
// NilPtrAnonymousHeadStringOnly // NilPtrAnonymousHeadStringOnly
{ {
@ -1711,6 +2222,14 @@ func TestCoverString(t *testing.T) {
structStringString: nil, structStringString: nil,
}, },
}, },
{
name: "NilPtrAnonymousHeadStringOnlyStringOmitEmpty",
data: struct {
*structStringStringOmitEmpty
}{
structStringStringOmitEmpty: nil,
},
},
// AnonymousHeadStringPtrOnly // AnonymousHeadStringPtrOnly
{ {
@ -1737,6 +2256,14 @@ func TestCoverString(t *testing.T) {
structStringPtrString: structStringPtrString{A: stringptr("foo")}, structStringPtrString: structStringPtrString{A: stringptr("foo")},
}, },
}, },
{
name: "AnonymousHeadStringPtrOnlyStringOmitEmpty",
data: struct {
structStringPtrStringOmitEmpty
}{
structStringPtrStringOmitEmpty: structStringPtrStringOmitEmpty{A: stringptr("foo")},
},
},
// AnonymousHeadStringPtrNilOnly // AnonymousHeadStringPtrNilOnly
{ {
@ -1763,6 +2290,14 @@ func TestCoverString(t *testing.T) {
structStringPtrString: structStringPtrString{A: nil}, structStringPtrString: structStringPtrString{A: nil},
}, },
}, },
{
name: "AnonymousHeadStringPtrNilOnlyStringOmitEmpty",
data: struct {
structStringPtrStringOmitEmpty
}{
structStringPtrStringOmitEmpty: structStringPtrStringOmitEmpty{A: nil},
},
},
// PtrAnonymousHeadStringPtrOnly // PtrAnonymousHeadStringPtrOnly
{ {
@ -1789,6 +2324,14 @@ func TestCoverString(t *testing.T) {
structStringPtrString: &structStringPtrString{A: stringptr("foo")}, structStringPtrString: &structStringPtrString{A: stringptr("foo")},
}, },
}, },
{
name: "PtrAnonymousHeadStringPtrOnlyStringOmitEmpty",
data: struct {
*structStringPtrStringOmitEmpty
}{
structStringPtrStringOmitEmpty: &structStringPtrStringOmitEmpty{A: stringptr("foo")},
},
},
// NilPtrAnonymousHeadStringPtrOnly // NilPtrAnonymousHeadStringPtrOnly
{ {
@ -1815,6 +2358,14 @@ func TestCoverString(t *testing.T) {
structStringPtrString: nil, structStringPtrString: nil,
}, },
}, },
{
name: "NilPtrAnonymousHeadStringPtrOnlyStringOmitEmpty",
data: struct {
*structStringPtrStringOmitEmpty
}{
structStringPtrStringOmitEmpty: nil,
},
},
} }
for _, test := range tests { for _, test := range tests {
for _, indent := range []bool{true, false} { for _, indent := range []bool{true, false} {

View File

@ -17,6 +17,9 @@ func TestCoverUint(t *testing.T) {
type structUintString struct { type structUintString struct {
A uint `json:"a,string"` A uint `json:"a,string"`
} }
type structUintStringOmitEmpty struct {
A uint `json:"a,string,omitempty"`
}
type structUintPtr struct { type structUintPtr struct {
A *uint `json:"a"` A *uint `json:"a"`
@ -27,6 +30,9 @@ func TestCoverUint(t *testing.T) {
type structUintPtrString struct { type structUintPtrString struct {
A *uint `json:"a,string"` A *uint `json:"a,string"`
} }
type structUintPtrStringOmitEmpty struct {
A *uint `json:"a,string,omitempty"`
}
tests := []struct { tests := []struct {
name string name string
@ -72,6 +78,12 @@ func TestCoverUint(t *testing.T) {
A uint `json:"a,string"` A uint `json:"a,string"`
}{}, }{},
}, },
{
name: "HeadUintZeroStringOmitEmpty",
data: struct {
A uint `json:"a,string,omitempty"`
}{},
},
// HeadUint // HeadUint
{ {
@ -92,6 +104,12 @@ func TestCoverUint(t *testing.T) {
A uint `json:"a,string"` A uint `json:"a,string"`
}{A: 1}, }{A: 1},
}, },
{
name: "HeadUintStringOmitEmpty",
data: struct {
A uint `json:"a,string,omitempty"`
}{A: 1},
},
// HeadUintPtr // HeadUintPtr
{ {
@ -112,6 +130,12 @@ func TestCoverUint(t *testing.T) {
A *uint `json:"a,string"` A *uint `json:"a,string"`
}{A: uptr(1)}, }{A: uptr(1)},
}, },
{
name: "HeadUintPtrStringOmitEmpty",
data: struct {
A *uint `json:"a,string,omitempty"`
}{A: uptr(1)},
},
// HeadUintPtrNil // HeadUintPtrNil
{ {
@ -132,6 +156,12 @@ func TestCoverUint(t *testing.T) {
A *uint `json:"a,string"` A *uint `json:"a,string"`
}{A: nil}, }{A: nil},
}, },
{
name: "HeadUintPtrNilStringOmitEmpty",
data: struct {
A *uint `json:"a,string,omitempty"`
}{A: nil},
},
// PtrHeadUintZero // PtrHeadUintZero
{ {
@ -152,6 +182,12 @@ func TestCoverUint(t *testing.T) {
A uint `json:"a,string"` A uint `json:"a,string"`
}{}, }{},
}, },
{
name: "PtrHeadUintZeroStringOmitEmpty",
data: &struct {
A uint `json:"a,string,omitempty"`
}{},
},
// PtrHeadUint // PtrHeadUint
{ {
@ -172,6 +208,12 @@ func TestCoverUint(t *testing.T) {
A uint `json:"a,string"` A uint `json:"a,string"`
}{A: 1}, }{A: 1},
}, },
{
name: "PtrHeadUintStringOmitEmpty",
data: &struct {
A uint `json:"a,string,omitempty"`
}{A: 1},
},
// PtrHeadUintPtr // PtrHeadUintPtr
{ {
@ -192,6 +234,12 @@ func TestCoverUint(t *testing.T) {
A *uint `json:"a,string"` A *uint `json:"a,string"`
}{A: uptr(1)}, }{A: uptr(1)},
}, },
{
name: "PtrHeadUintPtrStringOmitEmpty",
data: &struct {
A *uint `json:"a,string,omitempty"`
}{A: uptr(1)},
},
// PtrHeadUintPtrNil // PtrHeadUintPtrNil
{ {
@ -212,6 +260,12 @@ func TestCoverUint(t *testing.T) {
A *uint `json:"a,string"` A *uint `json:"a,string"`
}{A: nil}, }{A: nil},
}, },
{
name: "PtrHeadUintPtrNilStringOmitEmpty",
data: &struct {
A *uint `json:"a,string,omitempty"`
}{A: nil},
},
// PtrHeadUintNil // PtrHeadUintNil
{ {
@ -232,6 +286,12 @@ func TestCoverUint(t *testing.T) {
A *uint `json:"a,string"` A *uint `json:"a,string"`
})(nil), })(nil),
}, },
{
name: "PtrHeadUintNilStringOmitEmpty",
data: (*struct {
A *uint `json:"a,string,omitempty"`
})(nil),
},
// HeadUintZeroMultiFields // HeadUintZeroMultiFields
{ {
@ -251,13 +311,21 @@ func TestCoverUint(t *testing.T) {
}{}, }{},
}, },
{ {
name: "HeadUintZeroMultiFields", name: "HeadUintZeroMultiFieldsString",
data: struct { data: struct {
A uint `json:"a,string"` A uint `json:"a,string"`
B uint `json:"b,string"` B uint `json:"b,string"`
C uint `json:"c,string"` C uint `json:"c,string"`
}{}, }{},
}, },
{
name: "HeadUintZeroMultiFieldsStringOmitEmpty",
data: struct {
A uint `json:"a,string,omitempty"`
B uint `json:"b,string,omitempty"`
C uint `json:"c,string,omitempty"`
}{},
},
// HeadUintMultiFields // HeadUintMultiFields
{ {
@ -284,6 +352,14 @@ func TestCoverUint(t *testing.T) {
C uint `json:"c,string"` C uint `json:"c,string"`
}{A: 1, B: 2, C: 3}, }{A: 1, B: 2, C: 3},
}, },
{
name: "HeadUintMultiFieldsStringOmitEmpty",
data: struct {
A uint `json:"a,string,omitempty"`
B uint `json:"b,string,omitempty"`
C uint `json:"c,string,omitempty"`
}{A: 1, B: 2, C: 3},
},
// HeadUintPtrMultiFields // HeadUintPtrMultiFields
{ {
@ -310,6 +386,14 @@ func TestCoverUint(t *testing.T) {
C *uint `json:"c,string"` C *uint `json:"c,string"`
}{A: uptr(1), B: uptr(2), C: uptr(3)}, }{A: uptr(1), B: uptr(2), C: uptr(3)},
}, },
{
name: "HeadUintPtrMultiFieldsStringOmitEmpty",
data: struct {
A *uint `json:"a,string,omitempty"`
B *uint `json:"b,string,omitempty"`
C *uint `json:"c,string,omitempty"`
}{A: uptr(1), B: uptr(2), C: uptr(3)},
},
// HeadUintPtrNilMultiFields // HeadUintPtrNilMultiFields
{ {
@ -336,6 +420,14 @@ func TestCoverUint(t *testing.T) {
C *uint `json:"c,string"` C *uint `json:"c,string"`
}{A: nil, B: nil, C: nil}, }{A: nil, B: nil, C: nil},
}, },
{
name: "HeadUintPtrNilMultiFieldsStringOmitEmpty",
data: struct {
A *uint `json:"a,string,omitempty"`
B *uint `json:"b,string,omitempty"`
C *uint `json:"c,string,omitempty"`
}{A: nil, B: nil, C: nil},
},
// PtrHeadUintZeroMultiFields // PtrHeadUintZeroMultiFields
{ {
@ -359,6 +451,13 @@ func TestCoverUint(t *testing.T) {
B uint `json:"b,string"` B uint `json:"b,string"`
}{}, }{},
}, },
{
name: "PtrHeadUintZeroMultiFieldsStringOmitEmpty",
data: &struct {
A uint `json:"a,string,omitempty"`
B uint `json:"b,string,omitempty"`
}{},
},
// PtrHeadUintMultiFields // PtrHeadUintMultiFields
{ {
@ -382,6 +481,13 @@ func TestCoverUint(t *testing.T) {
B uint `json:"b,string"` B uint `json:"b,string"`
}{A: 1, B: 2}, }{A: 1, B: 2},
}, },
{
name: "PtrHeadUintMultiFieldsStringOmitEmpty",
data: &struct {
A uint `json:"a,string,omitempty"`
B uint `json:"b,string,omitempty"`
}{A: 1, B: 2},
},
// PtrHeadUintPtrMultiFields // PtrHeadUintPtrMultiFields
{ {
@ -405,6 +511,13 @@ func TestCoverUint(t *testing.T) {
B *uint `json:"b,string"` B *uint `json:"b,string"`
}{A: uptr(1), B: uptr(2)}, }{A: uptr(1), B: uptr(2)},
}, },
{
name: "PtrHeadUintPtrMultiFieldsStringOmitEmpty",
data: &struct {
A *uint `json:"a,string,omitempty"`
B *uint `json:"b,string,omitempty"`
}{A: uptr(1), B: uptr(2)},
},
// PtrHeadUintPtrNilMultiFields // PtrHeadUintPtrNilMultiFields
{ {
@ -428,6 +541,13 @@ func TestCoverUint(t *testing.T) {
B *uint `json:"b,string"` B *uint `json:"b,string"`
}{A: nil, B: nil}, }{A: nil, B: nil},
}, },
{
name: "PtrHeadUintPtrNilMultiFieldsStringOmitEmpty",
data: &struct {
A *uint `json:"a,string,omitempty"`
B *uint `json:"b,string,omitempty"`
}{A: nil, B: nil},
},
// PtrHeadUintNilMultiFields // PtrHeadUintNilMultiFields
{ {
@ -451,6 +571,13 @@ func TestCoverUint(t *testing.T) {
B *uint `json:"b,string"` B *uint `json:"b,string"`
})(nil), })(nil),
}, },
{
name: "PtrHeadUintNilMultiFieldsStringOmitEmpty",
data: (*struct {
A *uint `json:"a,string,omitempty"`
B *uint `json:"b,string,omitempty"`
})(nil),
},
// HeadUintZeroNotRoot // HeadUintZeroNotRoot
{ {
@ -477,6 +604,14 @@ func TestCoverUint(t *testing.T) {
} }
}{}, }{},
}, },
{
name: "HeadUintZeroNotRootStringOmitEmpty",
data: struct {
A struct {
A uint `json:"a,string,omitempty"`
}
}{},
},
// HeadUintNotRoot // HeadUintNotRoot
{ {
@ -509,6 +644,16 @@ func TestCoverUint(t *testing.T) {
A uint `json:"a,string"` A uint `json:"a,string"`
}{A: 1}}, }{A: 1}},
}, },
{
name: "HeadUintNotRootStringOmitEmpty",
data: struct {
A struct {
A uint `json:"a,string,omitempty"`
}
}{A: struct {
A uint `json:"a,string,omitempty"`
}{A: 1}},
},
// HeadUintPtrNotRoot // HeadUintPtrNotRoot
{ {
@ -541,6 +686,16 @@ func TestCoverUint(t *testing.T) {
A *uint `json:"a,string"` A *uint `json:"a,string"`
}{uptr(1)}}, }{uptr(1)}},
}, },
{
name: "HeadUintPtrNotRootStringOmitEmpty",
data: struct {
A struct {
A *uint `json:"a,string,omitempty"`
}
}{A: struct {
A *uint `json:"a,string,omitempty"`
}{uptr(1)}},
},
// HeadUintPtrNilNotRoot // HeadUintPtrNilNotRoot
{ {
@ -567,6 +722,14 @@ func TestCoverUint(t *testing.T) {
} }
}{}, }{},
}, },
{
name: "HeadUintPtrNilNotRootStringOmitEmpty",
data: struct {
A struct {
A *uint `json:"a,string,omitempty"`
}
}{},
},
// PtrHeadUintZeroNotRoot // PtrHeadUintZeroNotRoot
{ {
@ -599,6 +762,16 @@ func TestCoverUint(t *testing.T) {
A uint `json:"a,string"` A uint `json:"a,string"`
})}, })},
}, },
{
name: "PtrHeadUintZeroNotRootStringOmitEmpty",
data: struct {
A *struct {
A uint `json:"a,string,omitempty"`
}
}{A: new(struct {
A uint `json:"a,string,omitempty"`
})},
},
// PtrHeadUintNotRoot // PtrHeadUintNotRoot
{ {
@ -631,6 +804,16 @@ func TestCoverUint(t *testing.T) {
A uint `json:"a,string"` A uint `json:"a,string"`
}{A: 1})}, }{A: 1})},
}, },
{
name: "PtrHeadUintNotRootStringOmitEmpty",
data: struct {
A *struct {
A uint `json:"a,string,omitempty"`
}
}{A: &(struct {
A uint `json:"a,string,omitempty"`
}{A: 1})},
},
// PtrHeadUintPtrNotRoot // PtrHeadUintPtrNotRoot
{ {
@ -663,6 +846,16 @@ func TestCoverUint(t *testing.T) {
A *uint `json:"a,string"` A *uint `json:"a,string"`
}{A: uptr(1)})}, }{A: uptr(1)})},
}, },
{
name: "PtrHeadUintPtrNotRootStringOmitEmpty",
data: struct {
A *struct {
A *uint `json:"a,string,omitempty"`
}
}{A: &(struct {
A *uint `json:"a,string,omitempty"`
}{A: uptr(1)})},
},
// PtrHeadUintPtrNilNotRoot // PtrHeadUintPtrNilNotRoot
{ {
@ -695,6 +888,16 @@ func TestCoverUint(t *testing.T) {
A *uint `json:"a,string"` A *uint `json:"a,string"`
}{A: nil})}, }{A: nil})},
}, },
{
name: "PtrHeadUintPtrNilNotRootStringOmitEmpty",
data: struct {
A *struct {
A *uint `json:"a,string,omitempty"`
}
}{A: &(struct {
A *uint `json:"a,string,omitempty"`
}{A: nil})},
},
// PtrHeadUintNilNotRoot // PtrHeadUintNilNotRoot
{ {
@ -721,6 +924,14 @@ func TestCoverUint(t *testing.T) {
} `json:",string"` } `json:",string"`
}{A: nil}, }{A: nil},
}, },
{
name: "PtrHeadUintNilNotRootStringOmitEmpty",
data: struct {
A *struct {
A *uint `json:"a,string,omitempty"`
} `json:",string,omitempty"`
}{A: nil},
},
// HeadUintZeroMultiFieldsNotRoot // HeadUintZeroMultiFieldsNotRoot
{ {
@ -756,6 +967,17 @@ func TestCoverUint(t *testing.T) {
} }
}{}, }{},
}, },
{
name: "HeadUintZeroMultiFieldsNotRootStringOmitEmpty",
data: struct {
A struct {
A uint `json:"a,string,omitempty"`
}
B struct {
B uint `json:"b,string,omitempty"`
}
}{},
},
// HeadUintMultiFieldsNotRoot // HeadUintMultiFieldsNotRoot
{ {
@ -803,6 +1025,21 @@ func TestCoverUint(t *testing.T) {
B uint `json:"b,string"` B uint `json:"b,string"`
}{B: 2}}, }{B: 2}},
}, },
{
name: "HeadUintMultiFieldsNotRootStringOmitEmpty",
data: struct {
A struct {
A uint `json:"a,string,omitempty"`
}
B struct {
B uint `json:"b,string,omitempty"`
}
}{A: struct {
A uint `json:"a,string,omitempty"`
}{A: 1}, B: struct {
B uint `json:"b,string,omitempty"`
}{B: 2}},
},
// HeadUintPtrMultiFieldsNotRoot // HeadUintPtrMultiFieldsNotRoot
{ {
@ -850,6 +1087,21 @@ func TestCoverUint(t *testing.T) {
B *uint `json:"b,string"` B *uint `json:"b,string"`
}{B: uptr(2)}}, }{B: uptr(2)}},
}, },
{
name: "HeadUintPtrMultiFieldsNotRootStringOmitEmpty",
data: struct {
A struct {
A *uint `json:"a,string,omitempty"`
}
B struct {
B *uint `json:"b,string,omitempty"`
}
}{A: struct {
A *uint `json:"a,string,omitempty"`
}{A: uptr(1)}, B: struct {
B *uint `json:"b,string,omitempty"`
}{B: uptr(2)}},
},
// HeadUintPtrNilMultiFieldsNotRoot // HeadUintPtrNilMultiFieldsNotRoot
{ {
@ -897,6 +1149,21 @@ func TestCoverUint(t *testing.T) {
B *uint `json:"b,string"` B *uint `json:"b,string"`
}{B: nil}}, }{B: nil}},
}, },
{
name: "HeadUintPtrNilMultiFieldsNotRootStringOmitEmpty",
data: struct {
A struct {
A *uint `json:"a,string,omitempty"`
}
B struct {
B *uint `json:"b,string,omitempty"`
}
}{A: struct {
A *uint `json:"a,string,omitempty"`
}{A: nil}, B: struct {
B *uint `json:"b,string,omitempty"`
}{B: nil}},
},
// PtrHeadUintZeroMultiFieldsNotRoot // PtrHeadUintZeroMultiFieldsNotRoot
{ {
@ -932,6 +1199,17 @@ func TestCoverUint(t *testing.T) {
} }
}{}, }{},
}, },
{
name: "PtrHeadUintZeroMultiFieldsNotRootStringOmitEmpty",
data: &struct {
A struct {
A uint `json:"a,string,omitempty"`
}
B struct {
B uint `json:"b,string,omitempty"`
}
}{},
},
// PtrHeadUintMultiFieldsNotRoot // PtrHeadUintMultiFieldsNotRoot
{ {
@ -979,6 +1257,21 @@ func TestCoverUint(t *testing.T) {
B uint `json:"b,string"` B uint `json:"b,string"`
}{B: 2}}, }{B: 2}},
}, },
{
name: "PtrHeadUintMultiFieldsNotRootStringOmitEmpty",
data: &struct {
A struct {
A uint `json:"a,string,omitempty"`
}
B struct {
B uint `json:"b,string,omitempty"`
}
}{A: struct {
A uint `json:"a,string,omitempty"`
}{A: 1}, B: struct {
B uint `json:"b,string,omitempty"`
}{B: 2}},
},
// PtrHeadUintPtrMultiFieldsNotRoot // PtrHeadUintPtrMultiFieldsNotRoot
{ {
@ -1026,6 +1319,21 @@ func TestCoverUint(t *testing.T) {
B *uint `json:"b,string"` B *uint `json:"b,string"`
}{B: uptr(2)})}, }{B: uptr(2)})},
}, },
{
name: "PtrHeadUintPtrMultiFieldsNotRootStringOmitEmpty",
data: &struct {
A *struct {
A *uint `json:"a,string,omitempty"`
}
B *struct {
B *uint `json:"b,string,omitempty"`
}
}{A: &(struct {
A *uint `json:"a,string,omitempty"`
}{A: uptr(1)}), B: &(struct {
B *uint `json:"b,string,omitempty"`
}{B: uptr(2)})},
},
// PtrHeadUintPtrNilMultiFieldsNotRoot // PtrHeadUintPtrNilMultiFieldsNotRoot
{ {
@ -1061,6 +1369,17 @@ func TestCoverUint(t *testing.T) {
} `json:",string"` } `json:",string"`
}{A: nil, B: nil}, }{A: nil, B: nil},
}, },
{
name: "PtrHeadUintPtrNilMultiFieldsNotRootStringOmitEmpty",
data: &struct {
A *struct {
A *uint `json:"a,string,omitempty"`
} `json:",string,omitempty"`
B *struct {
B *uint `json:"b,string,omitempty"`
} `json:",string,omitempty"`
}{A: nil, B: nil},
},
// PtrHeadUintNilMultiFieldsNotRoot // PtrHeadUintNilMultiFieldsNotRoot
{ {
@ -1096,6 +1415,17 @@ func TestCoverUint(t *testing.T) {
} }
})(nil), })(nil),
}, },
{
name: "PtrHeadUintNilMultiFieldsNotRootStringOmitEmpty",
data: (*struct {
A *struct {
A *uint `json:"a,string,omitempty"`
}
B *struct {
B *uint `json:"b,string,omitempty"`
}
})(nil),
},
// PtrHeadUintDoubleMultiFieldsNotRoot // PtrHeadUintDoubleMultiFieldsNotRoot
{ {
@ -1155,6 +1485,25 @@ func TestCoverUint(t *testing.T) {
B uint `json:"b,string"` B uint `json:"b,string"`
}{A: 3, B: 4})}, }{A: 3, B: 4})},
}, },
{
name: "PtrHeadUintDoubleMultiFieldsNotRootStringOmitEmpty",
data: &struct {
A *struct {
A uint `json:"a,string,omitempty"`
B uint `json:"b,string,omitempty"`
}
B *struct {
A uint `json:"a,string,omitempty"`
B uint `json:"b,string,omitempty"`
}
}{A: &(struct {
A uint `json:"a,string,omitempty"`
B uint `json:"b,string,omitempty"`
}{A: 1, B: 2}), B: &(struct {
A uint `json:"a,string,omitempty"`
B uint `json:"b,string,omitempty"`
}{A: 3, B: 4})},
},
// PtrHeadUintNilDoubleMultiFieldsNotRoot // PtrHeadUintNilDoubleMultiFieldsNotRoot
{ {
@ -1196,6 +1545,19 @@ func TestCoverUint(t *testing.T) {
} }
}{A: nil, B: nil}, }{A: nil, B: nil},
}, },
{
name: "PtrHeadUintNilDoubleMultiFieldsNotRootStringOmitEmpty",
data: &struct {
A *struct {
A uint `json:"a,string,omitempty"`
B uint `json:"b,string,omitempty"`
}
B *struct {
A uint `json:"a,string,omitempty"`
B uint `json:"b,string,omitempty"`
}
}{A: nil, B: nil},
},
// PtrHeadUintNilDoubleMultiFieldsNotRoot // PtrHeadUintNilDoubleMultiFieldsNotRoot
{ {
@ -1237,6 +1599,19 @@ func TestCoverUint(t *testing.T) {
} }
})(nil), })(nil),
}, },
{
name: "PtrHeadUintNilDoubleMultiFieldsNotRootStringOmitEmpty",
data: (*struct {
A *struct {
A uint `json:"a,string,omitempty"`
B uint `json:"b,string,omitempty"`
}
B *struct {
A uint `json:"a,string,omitempty"`
B uint `json:"b,string,omitempty"`
}
})(nil),
},
// PtrHeadUintPtrDoubleMultiFieldsNotRoot // PtrHeadUintPtrDoubleMultiFieldsNotRoot
{ {
@ -1296,6 +1671,25 @@ func TestCoverUint(t *testing.T) {
B *uint `json:"b,string"` B *uint `json:"b,string"`
}{A: uptr(3), B: uptr(4)})}, }{A: uptr(3), B: uptr(4)})},
}, },
{
name: "PtrHeadUintPtrDoubleMultiFieldsNotRootStringOmitEmpty",
data: &struct {
A *struct {
A *uint `json:"a,string,omitempty"`
B *uint `json:"b,string,omitempty"`
}
B *struct {
A *uint `json:"a,string,omitempty"`
B *uint `json:"b,string,omitempty"`
}
}{A: &(struct {
A *uint `json:"a,string,omitempty"`
B *uint `json:"b,string,omitempty"`
}{A: uptr(1), B: uptr(2)}), B: &(struct {
A *uint `json:"a,string,omitempty"`
B *uint `json:"b,string,omitempty"`
}{A: uptr(3), B: uptr(4)})},
},
// PtrHeadUintPtrNilDoubleMultiFieldsNotRoot // PtrHeadUintPtrNilDoubleMultiFieldsNotRoot
{ {
@ -1337,6 +1731,19 @@ func TestCoverUint(t *testing.T) {
} }
}{A: nil, B: nil}, }{A: nil, B: nil},
}, },
{
name: "PtrHeadUintPtrNilDoubleMultiFieldsNotRootStringOmitEmpty",
data: &struct {
A *struct {
A *uint `json:"a,string,omitempty"`
B *uint `json:"b,string,omitempty"`
}
B *struct {
A *uint `json:"a,string,omitempty"`
B *uint `json:"b,string,omitempty"`
}
}{A: nil, B: nil},
},
// PtrHeadUintPtrNilDoubleMultiFieldsNotRoot // PtrHeadUintPtrNilDoubleMultiFieldsNotRoot
{ {
@ -1378,6 +1785,19 @@ func TestCoverUint(t *testing.T) {
} }
})(nil), })(nil),
}, },
{
name: "PtrHeadUintPtrNilDoubleMultiFieldsNotRootStringOmitEmpty",
data: (*struct {
A *struct {
A *uint `json:"a,string,omitempty"`
B *uint `json:"b,string,omitempty"`
}
B *struct {
A *uint `json:"a,string,omitempty"`
B *uint `json:"b,string,omitempty"`
}
})(nil),
},
// AnonymousHeadUint // AnonymousHeadUint
{ {
@ -1410,6 +1830,16 @@ func TestCoverUint(t *testing.T) {
B: 2, B: 2,
}, },
}, },
{
name: "AnonymousHeadUintStringOmitEmpty",
data: struct {
structUintStringOmitEmpty
B uint `json:"b,string,omitempty"`
}{
structUintStringOmitEmpty: structUintStringOmitEmpty{A: 1},
B: 2,
},
},
// PtrAnonymousHeadUint // PtrAnonymousHeadUint
{ {
@ -1442,6 +1872,16 @@ func TestCoverUint(t *testing.T) {
B: 2, B: 2,
}, },
}, },
{
name: "PtrAnonymousHeadUintStringOmitEmpty",
data: struct {
*structUintStringOmitEmpty
B uint `json:"b,string,omitempty"`
}{
structUintStringOmitEmpty: &structUintStringOmitEmpty{A: 1},
B: 2,
},
},
// NilPtrAnonymousHeadUint // NilPtrAnonymousHeadUint
{ {
@ -1474,6 +1914,16 @@ func TestCoverUint(t *testing.T) {
B: 2, B: 2,
}, },
}, },
{
name: "NilPtrAnonymousHeadUintStringOmitEmpty",
data: struct {
*structUintStringOmitEmpty
B uint `json:"b,string,omitempty"`
}{
structUintStringOmitEmpty: nil,
B: 2,
},
},
// AnonymousHeadUintPtr // AnonymousHeadUintPtr
{ {
@ -1506,6 +1956,16 @@ func TestCoverUint(t *testing.T) {
B: uptr(2), B: uptr(2),
}, },
}, },
{
name: "AnonymousHeadUintPtrStringOmitEmpty",
data: struct {
structUintPtrStringOmitEmpty
B *uint `json:"b,string,omitempty"`
}{
structUintPtrStringOmitEmpty: structUintPtrStringOmitEmpty{A: uptr(1)},
B: uptr(2),
},
},
// AnonymousHeadUintPtrNil // AnonymousHeadUintPtrNil
{ {
@ -1538,6 +1998,16 @@ func TestCoverUint(t *testing.T) {
B: uptr(2), B: uptr(2),
}, },
}, },
{
name: "AnonymousHeadUintPtrNilStringOmitEmpty",
data: struct {
structUintPtrStringOmitEmpty
B *uint `json:"b,string,omitempty"`
}{
structUintPtrStringOmitEmpty: structUintPtrStringOmitEmpty{A: nil},
B: uptr(2),
},
},
// PtrAnonymousHeadUintPtr // PtrAnonymousHeadUintPtr
{ {
@ -1570,6 +2040,16 @@ func TestCoverUint(t *testing.T) {
B: uptr(2), B: uptr(2),
}, },
}, },
{
name: "PtrAnonymousHeadUintPtrStringOmitEmpty",
data: struct {
*structUintPtrStringOmitEmpty
B *uint `json:"b,string,omitempty"`
}{
structUintPtrStringOmitEmpty: &structUintPtrStringOmitEmpty{A: uptr(1)},
B: uptr(2),
},
},
// NilPtrAnonymousHeadUintPtr // NilPtrAnonymousHeadUintPtr
{ {
@ -1602,6 +2082,16 @@ func TestCoverUint(t *testing.T) {
B: uptr(2), B: uptr(2),
}, },
}, },
{
name: "NilPtrAnonymousHeadUintPtrStringOmitEmpty",
data: struct {
*structUintPtrStringOmitEmpty
B *uint `json:"b,string,omitempty"`
}{
structUintPtrStringOmitEmpty: nil,
B: uptr(2),
},
},
// AnonymousHeadUintOnly // AnonymousHeadUintOnly
{ {
@ -1628,6 +2118,14 @@ func TestCoverUint(t *testing.T) {
structUintString: structUintString{A: 1}, structUintString: structUintString{A: 1},
}, },
}, },
{
name: "AnonymousHeadUintOnlyStringOmitEmpty",
data: struct {
structUintStringOmitEmpty
}{
structUintStringOmitEmpty: structUintStringOmitEmpty{A: 1},
},
},
// PtrAnonymousHeadUintOnly // PtrAnonymousHeadUintOnly
{ {
@ -1654,6 +2152,14 @@ func TestCoverUint(t *testing.T) {
structUintString: &structUintString{A: 1}, structUintString: &structUintString{A: 1},
}, },
}, },
{
name: "PtrAnonymousHeadUintOnlyStringOmitEmpty",
data: struct {
*structUintStringOmitEmpty
}{
structUintStringOmitEmpty: &structUintStringOmitEmpty{A: 1},
},
},
// NilPtrAnonymousHeadUintOnly // NilPtrAnonymousHeadUintOnly
{ {
@ -1680,6 +2186,14 @@ func TestCoverUint(t *testing.T) {
structUintString: nil, structUintString: nil,
}, },
}, },
{
name: "NilPtrAnonymousHeadUintOnlyStringOmitEmpty",
data: struct {
*structUintStringOmitEmpty
}{
structUintStringOmitEmpty: nil,
},
},
// AnonymousHeadUintPtrOnly // AnonymousHeadUintPtrOnly
{ {
@ -1706,6 +2220,14 @@ func TestCoverUint(t *testing.T) {
structUintPtrString: structUintPtrString{A: uptr(1)}, structUintPtrString: structUintPtrString{A: uptr(1)},
}, },
}, },
{
name: "AnonymousHeadUintPtrOnlyStringOmitEmpty",
data: struct {
structUintPtrStringOmitEmpty
}{
structUintPtrStringOmitEmpty: structUintPtrStringOmitEmpty{A: uptr(1)},
},
},
// AnonymousHeadUintPtrNilOnly // AnonymousHeadUintPtrNilOnly
{ {
@ -1732,6 +2254,14 @@ func TestCoverUint(t *testing.T) {
structUintPtrString: structUintPtrString{A: nil}, structUintPtrString: structUintPtrString{A: nil},
}, },
}, },
{
name: "AnonymousHeadUintPtrNilOnlyStringOmitEmpty",
data: struct {
structUintPtrStringOmitEmpty
}{
structUintPtrStringOmitEmpty: structUintPtrStringOmitEmpty{A: nil},
},
},
// PtrAnonymousHeadUintPtrOnly // PtrAnonymousHeadUintPtrOnly
{ {
@ -1758,6 +2288,14 @@ func TestCoverUint(t *testing.T) {
structUintPtrString: &structUintPtrString{A: uptr(1)}, structUintPtrString: &structUintPtrString{A: uptr(1)},
}, },
}, },
{
name: "PtrAnonymousHeadUintPtrOnlyStringOmitEmpty",
data: struct {
*structUintPtrStringOmitEmpty
}{
structUintPtrStringOmitEmpty: &structUintPtrStringOmitEmpty{A: uptr(1)},
},
},
// NilPtrAnonymousHeadUintPtrOnly // NilPtrAnonymousHeadUintPtrOnly
{ {
@ -1784,6 +2322,14 @@ func TestCoverUint(t *testing.T) {
structUintPtrString: nil, structUintPtrString: nil,
}, },
}, },
{
name: "NilPtrAnonymousHeadUintPtrOnlyStringOmitEmpty",
data: struct {
*structUintPtrStringOmitEmpty
}{
structUintPtrStringOmitEmpty: nil,
},
},
} }
for _, test := range tests { for _, test := range tests {
for _, indent := range []bool{true, false} { for _, indent := range []bool{true, false} {

View File

@ -7,7 +7,7 @@ services:
deploy: deploy:
resources: resources:
limits: limits:
memory: 600M memory: 700M
working_dir: /go/src/go-json working_dir: /go/src/go-json
command: | command: |
sh -c "go test -c . && ls go-json.test" sh -c "go test -c . && ls go-json.test"

View File

@ -100,7 +100,7 @@ func (t OpType) HeadToPtrHead() OpType {
} }
suffix := "PtrHead"+t.String()[idx+len("Head"):] suffix := "PtrHead"+t.String()[idx+len("Head"):]
const toPtrOffset = 3 const toPtrOffset = 2
if strings.Contains(OpType(int(t) + toPtrOffset).String(), suffix) { if strings.Contains(OpType(int(t) + toPtrOffset).String(), suffix) {
return OpType(int(t) + toPtrOffset) return OpType(int(t) + toPtrOffset)
} }
@ -116,14 +116,6 @@ func (t OpType) HeadToOmitEmptyHead() OpType {
return t return t
} }
func (t OpType) HeadToStringTagHead() OpType {
const toStringTagOffset = 2
if strings.Contains(OpType(int(t) + toStringTagOffset).String(), "StringTag") {
return OpType(int(t) + toStringTagOffset)
}
return t
}
func (t OpType) PtrHeadToHead() OpType { func (t OpType) PtrHeadToHead() OpType {
idx := strings.Index(t.String(), "Ptr") idx := strings.Index(t.String(), "Ptr")
if idx == -1 { if idx == -1 {
@ -131,7 +123,7 @@ func (t OpType) PtrHeadToHead() OpType {
} }
suffix := t.String()[idx+len("Ptr"):] suffix := t.String()[idx+len("Ptr"):]
const toPtrOffset = 3 const toPtrOffset = 2
if strings.Contains(OpType(int(t) - toPtrOffset).String(), suffix) { if strings.Contains(OpType(int(t) - toPtrOffset).String(), suffix) {
return OpType(int(t) - toPtrOffset) return OpType(int(t) - toPtrOffset)
} }
@ -144,10 +136,10 @@ func (t OpType) FieldToEnd() OpType {
return t return t
} }
suffix := t.String()[idx+len("Field"):] suffix := t.String()[idx+len("Field"):]
if suffix == "" || suffix == "OmitEmpty" || suffix == "StringTag" { if suffix == "" || suffix == "OmitEmpty" {
return t return t
} }
const toEndOffset = 3 const toEndOffset = 2
if strings.Contains(OpType(int(t) + toEndOffset).String(), "End"+suffix) { if strings.Contains(OpType(int(t) + toEndOffset).String(), "End"+suffix) {
return OpType(int(t) + toEndOffset) return OpType(int(t) + toEndOffset)
} }
@ -161,15 +153,6 @@ func (t OpType) FieldToOmitEmptyField() OpType {
} }
return t return t
} }
func (t OpType) FieldToStringTagField() OpType {
const toStringTagOffset = 2
if strings.Contains(OpType(int(t) + toStringTagOffset).String(), "StringTag") {
return OpType(int(t) + toStringTagOffset)
}
return t
}
`) `)
if err != nil { if err != nil {
return err return err
@ -191,9 +174,10 @@ func (t OpType) FieldToStringTagField() OpType {
primitiveTypes := []string{ primitiveTypes := []string{
"int", "uint", "float32", "float64", "bool", "string", "bytes", "number", "int", "uint", "float32", "float64", "bool", "string", "bytes", "number",
"array", "map", "slice", "struct", "MarshalJSON", "MarshalText", "array", "map", "slice", "struct", "MarshalJSON", "MarshalText",
"intString", "uintString", "intString", "uintString", "float32String", "float64String", "boolString", "stringString", "numberString",
"intPtr", "uintPtr", "float32Ptr", "float64Ptr", "boolPtr", "stringPtr", "bytesPtr", "numberPtr", "intPtr", "uintPtr", "float32Ptr", "float64Ptr", "boolPtr", "stringPtr", "bytesPtr", "numberPtr",
"arrayPtr", "mapPtr", "slicePtr", "marshalJSONPtr", "marshalTextPtr", "interfacePtr", "arrayPtr", "mapPtr", "slicePtr", "marshalJSONPtr", "marshalTextPtr", "interfacePtr",
"intPtrString", "uintPtrString", "float32PtrString", "float64PtrString", "boolPtrString", "stringPtrString", "numberPtrString",
} }
primitiveTypesUpper := []string{} primitiveTypesUpper := []string{}
for _, typ := range primitiveTypes { for _, typ := range primitiveTypes {
@ -221,7 +205,7 @@ func (t OpType) FieldToStringTagField() OpType {
} }
for _, typ := range append(primitiveTypesUpper, "") { for _, typ := range append(primitiveTypesUpper, "") {
for _, ptrOrNot := range []string{"", "Ptr"} { for _, ptrOrNot := range []string{"", "Ptr"} {
for _, opt := range []string{"", "OmitEmpty", "StringTag"} { for _, opt := range []string{"", "OmitEmpty"} {
ptrOrNot := ptrOrNot ptrOrNot := ptrOrNot
opt := opt opt := opt
typ := typ typ := typ
@ -240,7 +224,7 @@ func (t OpType) FieldToStringTagField() OpType {
} }
} }
for _, typ := range append(primitiveTypesUpper, "") { for _, typ := range append(primitiveTypesUpper, "") {
for _, opt := range []string{"", "OmitEmpty", "StringTag"} { for _, opt := range []string{"", "OmitEmpty"} {
opt := opt opt := opt
typ := typ typ := typ
@ -254,7 +238,7 @@ func (t OpType) FieldToStringTagField() OpType {
Code: "StructField", Code: "StructField",
}) })
} }
for _, opt := range []string{"", "OmitEmpty", "StringTag"} { for _, opt := range []string{"", "OmitEmpty"} {
opt := opt opt := opt
typ := typ typ := typ

View File

@ -1019,23 +1019,17 @@ func compileMapValue(ctx *compileContext) (*Opcode, error) {
} }
func optimizeStructHeader(code *Opcode, tag *runtime.StructTag) OpType { func optimizeStructHeader(code *Opcode, tag *runtime.StructTag) OpType {
headType := code.ToHeaderType() headType := code.ToHeaderType(tag.IsString)
switch { if tag.IsOmitEmpty {
case tag.IsOmitEmpty:
headType = headType.HeadToOmitEmptyHead() headType = headType.HeadToOmitEmptyHead()
case tag.IsString:
headType = headType.HeadToStringTagHead()
} }
return headType return headType
} }
func optimizeStructField(code *Opcode, tag *runtime.StructTag) OpType { func optimizeStructField(code *Opcode, tag *runtime.StructTag) OpType {
fieldType := code.ToFieldType() fieldType := code.ToFieldType(tag.IsString)
switch { if tag.IsOmitEmpty {
case tag.IsOmitEmpty:
fieldType = fieldType.FieldToOmitEmptyField() fieldType = fieldType.FieldToOmitEmptyField()
case tag.IsString:
fieldType = fieldType.FieldToStringTagField()
} }
return fieldType return fieldType
} }

View File

@ -41,38 +41,24 @@ func (t OpType) IsMultipleOpHead() bool {
return true return true
case OpStructHeadOmitEmptySlice: case OpStructHeadOmitEmptySlice:
return true return true
case OpStructHeadStringTagSlice:
return true
case OpStructHeadOmitEmptyArray: case OpStructHeadOmitEmptyArray:
return true return true
case OpStructHeadStringTagArray:
return true
case OpStructHeadOmitEmptyMap: case OpStructHeadOmitEmptyMap:
return true return true
case OpStructHeadStringTagMap:
return true
case OpStructHeadOmitEmptyStruct: case OpStructHeadOmitEmptyStruct:
return true return true
case OpStructHeadStringTag:
return true
case OpStructHeadSlicePtr: case OpStructHeadSlicePtr:
return true return true
case OpStructHeadOmitEmptySlicePtr: case OpStructHeadOmitEmptySlicePtr:
return true return true
case OpStructHeadStringTagSlicePtr:
return true
case OpStructHeadArrayPtr: case OpStructHeadArrayPtr:
return true return true
case OpStructHeadOmitEmptyArrayPtr: case OpStructHeadOmitEmptyArrayPtr:
return true return true
case OpStructHeadStringTagArrayPtr:
return true
case OpStructHeadMapPtr: case OpStructHeadMapPtr:
return true return true
case OpStructHeadOmitEmptyMapPtr: case OpStructHeadOmitEmptyMapPtr:
return true return true
case OpStructHeadStringTagMapPtr:
return true
} }
return false return false
} }
@ -93,38 +79,24 @@ func (t OpType) IsMultipleOpField() bool {
return true return true
case OpStructFieldOmitEmptySlice: case OpStructFieldOmitEmptySlice:
return true return true
case OpStructFieldStringTagSlice:
return true
case OpStructFieldOmitEmptyArray: case OpStructFieldOmitEmptyArray:
return true return true
case OpStructFieldStringTagArray:
return true
case OpStructFieldOmitEmptyMap: case OpStructFieldOmitEmptyMap:
return true return true
case OpStructFieldStringTagMap:
return true
case OpStructFieldOmitEmptyStruct: case OpStructFieldOmitEmptyStruct:
return true return true
case OpStructFieldStringTag:
return true
case OpStructFieldSlicePtr: case OpStructFieldSlicePtr:
return true return true
case OpStructFieldOmitEmptySlicePtr: case OpStructFieldOmitEmptySlicePtr:
return true return true
case OpStructFieldStringTagSlicePtr:
return true
case OpStructFieldArrayPtr: case OpStructFieldArrayPtr:
return true return true
case OpStructFieldOmitEmptyArrayPtr: case OpStructFieldOmitEmptyArrayPtr:
return true return true
case OpStructFieldStringTagArrayPtr:
return true
case OpStructFieldMapPtr: case OpStructFieldMapPtr:
return true return true
case OpStructFieldOmitEmptyMapPtr: case OpStructFieldOmitEmptyMapPtr:
return true return true
case OpStructFieldStringTagMapPtr:
return true
} }
return false return false
} }

View File

@ -68,35 +68,77 @@ func (c *Opcode) setMaskAndRshiftNum(bitSize uint8) {
c.RshiftNum = rshitNum(bitSize) c.RshiftNum = rshitNum(bitSize)
} }
func (c *Opcode) ToHeaderType() OpType { func (c *Opcode) ToHeaderType(isString bool) OpType {
switch c.Op { switch c.Op {
case OpInt: case OpInt:
if isString {
return OpStructHeadIntString
}
return OpStructHeadInt return OpStructHeadInt
case OpIntPtr: case OpIntPtr:
if isString {
return OpStructHeadIntPtrString
}
return OpStructHeadIntPtr return OpStructHeadIntPtr
case OpUint: case OpUint:
if isString {
return OpStructHeadUintString
}
return OpStructHeadUint return OpStructHeadUint
case OpUintPtr: case OpUintPtr:
if isString {
return OpStructHeadUintPtrString
}
return OpStructHeadUintPtr return OpStructHeadUintPtr
case OpFloat32: case OpFloat32:
if isString {
return OpStructHeadFloat32String
}
return OpStructHeadFloat32 return OpStructHeadFloat32
case OpFloat32Ptr: case OpFloat32Ptr:
if isString {
return OpStructHeadFloat32PtrString
}
return OpStructHeadFloat32Ptr return OpStructHeadFloat32Ptr
case OpFloat64: case OpFloat64:
if isString {
return OpStructHeadFloat64String
}
return OpStructHeadFloat64 return OpStructHeadFloat64
case OpFloat64Ptr: case OpFloat64Ptr:
if isString {
return OpStructHeadFloat64PtrString
}
return OpStructHeadFloat64Ptr return OpStructHeadFloat64Ptr
case OpString: case OpString:
if isString {
return OpStructHeadStringString
}
return OpStructHeadString return OpStructHeadString
case OpStringPtr: case OpStringPtr:
if isString {
return OpStructHeadStringPtrString
}
return OpStructHeadStringPtr return OpStructHeadStringPtr
case OpNumber: case OpNumber:
if isString {
return OpStructHeadNumberString
}
return OpStructHeadNumber return OpStructHeadNumber
case OpNumberPtr: case OpNumberPtr:
if isString {
return OpStructHeadNumberPtrString
}
return OpStructHeadNumberPtr return OpStructHeadNumberPtr
case OpBool: case OpBool:
if isString {
return OpStructHeadBoolString
}
return OpStructHeadBool return OpStructHeadBool
case OpBoolPtr: case OpBoolPtr:
if isString {
return OpStructHeadBoolPtrString
}
return OpStructHeadBoolPtr return OpStructHeadBoolPtr
case OpBytes: case OpBytes:
return OpStructHeadBytes return OpStructHeadBytes
@ -129,35 +171,77 @@ func (c *Opcode) ToHeaderType() OpType {
return OpStructHead return OpStructHead
} }
func (c *Opcode) ToFieldType() OpType { func (c *Opcode) ToFieldType(isString bool) OpType {
switch c.Op { switch c.Op {
case OpInt: case OpInt:
if isString {
return OpStructFieldIntString
}
return OpStructFieldInt return OpStructFieldInt
case OpIntPtr: case OpIntPtr:
if isString {
return OpStructFieldIntPtrString
}
return OpStructFieldIntPtr return OpStructFieldIntPtr
case OpUint: case OpUint:
if isString {
return OpStructFieldUintString
}
return OpStructFieldUint return OpStructFieldUint
case OpUintPtr: case OpUintPtr:
if isString {
return OpStructFieldUintPtrString
}
return OpStructFieldUintPtr return OpStructFieldUintPtr
case OpFloat32: case OpFloat32:
if isString {
return OpStructFieldFloat32String
}
return OpStructFieldFloat32 return OpStructFieldFloat32
case OpFloat32Ptr: case OpFloat32Ptr:
if isString {
return OpStructFieldFloat32PtrString
}
return OpStructFieldFloat32Ptr return OpStructFieldFloat32Ptr
case OpFloat64: case OpFloat64:
if isString {
return OpStructFieldFloat64String
}
return OpStructFieldFloat64 return OpStructFieldFloat64
case OpFloat64Ptr: case OpFloat64Ptr:
if isString {
return OpStructFieldFloat64PtrString
}
return OpStructFieldFloat64Ptr return OpStructFieldFloat64Ptr
case OpString: case OpString:
if isString {
return OpStructFieldStringString
}
return OpStructFieldString return OpStructFieldString
case OpStringPtr: case OpStringPtr:
if isString {
return OpStructFieldStringPtrString
}
return OpStructFieldStringPtr return OpStructFieldStringPtr
case OpNumber: case OpNumber:
if isString {
return OpStructFieldNumberString
}
return OpStructFieldNumber return OpStructFieldNumber
case OpNumberPtr: case OpNumberPtr:
if isString {
return OpStructFieldNumberPtrString
}
return OpStructFieldNumberPtr return OpStructFieldNumberPtr
case OpBool: case OpBool:
if isString {
return OpStructFieldBoolString
}
return OpStructFieldBool return OpStructFieldBool
case OpBoolPtr: case OpBoolPtr:
if isString {
return OpStructFieldBoolPtrString
}
return OpStructFieldBoolPtr return OpStructFieldBoolPtr
case OpBytes: case OpBytes:
return OpStructFieldBytes return OpStructFieldBytes

File diff suppressed because it is too large Load Diff

View File

@ -79,3 +79,12 @@ func appendComma(b []byte) []byte {
func appendStructEnd(b []byte) []byte { func appendStructEnd(b []byte) []byte {
return append(b, '}', ',') return append(b, '}', ',')
} }
func appendStructEndSkipLast(b []byte) []byte {
last := len(b) - 1
if b[last] == ',' {
b[last] = '}'
return appendComma(b)
}
return appendStructEnd(b)
}

File diff suppressed because it is too large Load Diff

View File

@ -79,3 +79,12 @@ func appendComma(b []byte) []byte {
func appendStructEnd(b []byte) []byte { func appendStructEnd(b []byte) []byte {
return append(b, '}', ',') return append(b, '}', ',')
} }
func appendStructEndSkipLast(b []byte) []byte {
last := len(b) - 1
if b[last] == ',' {
b[last] = '}'
return appendComma(b)
}
return appendStructEnd(b)
}

File diff suppressed because it is too large Load Diff

View File

@ -79,3 +79,12 @@ func appendComma(b []byte) []byte {
func appendStructEnd(b []byte) []byte { func appendStructEnd(b []byte) []byte {
return append(b, '}', ',') return append(b, '}', ',')
} }
func appendStructEndSkipLast(b []byte) []byte {
last := len(b) - 1
if b[last] == ',' {
b[last] = '}'
return appendComma(b)
}
return appendStructEnd(b)
}

File diff suppressed because it is too large Load Diff

View File

@ -75,3 +75,19 @@ func appendNull(b []byte) []byte {
func appendComma(b []byte) []byte { func appendComma(b []byte) []byte {
return append(b, ',', '\n') return append(b, ',', '\n')
} }
func appendStructEndSkipLast(ctx *encoder.RuntimeContext, b []byte, code *encoder.Opcode) []byte {
last := len(b) - 1
if b[last-1] == '{' {
b[last] = '}'
} else {
if b[last] == '\n' {
// to remove ',' and '\n' characters
b = b[:len(b)-2]
}
b = append(b, '\n')
b = appendIndent(ctx, b, code.Indent-1)
b = append(b, '}')
}
return appendComma(b)
}

File diff suppressed because it is too large Load Diff

View File

@ -75,3 +75,19 @@ func appendNull(b []byte) []byte {
func appendComma(b []byte) []byte { func appendComma(b []byte) []byte {
return append(b, ',', '\n') return append(b, ',', '\n')
} }
func appendStructEndSkipLast(ctx *encoder.RuntimeContext, b []byte, code *encoder.Opcode) []byte {
last := len(b) - 1
if b[last-1] == '{' {
b[last] = '}'
} else {
if b[last] == '\n' {
// to remove ',' and '\n' characters
b = b[:len(b)-2]
}
b = append(b, '\n')
b = appendIndent(ctx, b, code.Indent-1)
b = append(b, '}')
}
return appendComma(b)
}

File diff suppressed because it is too large Load Diff

View File

@ -74,8 +74,14 @@ func StructTagFromField(field reflect.StructField) *StructTag {
} }
st.Key = keyName st.Key = keyName
if len(opts) > 1 { if len(opts) > 1 {
st.IsOmitEmpty = opts[1] == "omitempty" for _, opt := range opts[1:] {
st.IsString = opts[1] == "string" switch opt {
case "omitempty":
st.IsOmitEmpty = true
case "string":
st.IsString = true
}
}
} }
return st return st
} }