Add test case for json.Number type

This commit is contained in:
Masaaki Goshima 2021-05-09 00:56:00 +09:00
parent a6c1f6442c
commit 065efcf447
1 changed files with 547 additions and 1 deletions

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} {