mirror of https://github.com/goccy/go-json.git
Add test case for json.Number type
This commit is contained in:
parent
a6c1f6442c
commit
065efcf447
|
@ -17,6 +17,9 @@ func TestCoverNumber(t *testing.T) {
|
|||
type structNumberString struct {
|
||||
A json.Number `json:"a,string"`
|
||||
}
|
||||
type structNumberStringOmitEmpty struct {
|
||||
A json.Number `json:"a,string,omitempty"`
|
||||
}
|
||||
|
||||
type structNumberPtr struct {
|
||||
A *json.Number `json:"a"`
|
||||
|
@ -27,6 +30,9 @@ func TestCoverNumber(t *testing.T) {
|
|||
type structNumberPtrString struct {
|
||||
A *json.Number `json:"a,string"`
|
||||
}
|
||||
type structNumberPtrStringOmitEmpty struct {
|
||||
A *json.Number `json:"a,string,omitempty"`
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
|
@ -72,6 +78,12 @@ func TestCoverNumber(t *testing.T) {
|
|||
A json.Number `json:"a,string"`
|
||||
}{},
|
||||
},
|
||||
{
|
||||
name: "HeadNumberZeroStringOmitEmpty",
|
||||
data: struct {
|
||||
A json.Number `json:"a,string,omitempty"`
|
||||
}{},
|
||||
},
|
||||
|
||||
// HeadNumber
|
||||
{
|
||||
|
@ -92,6 +104,12 @@ func TestCoverNumber(t *testing.T) {
|
|||
A json.Number `json:"a,string"`
|
||||
}{A: "1"},
|
||||
},
|
||||
{
|
||||
name: "HeadNumberStringOmitEmpty",
|
||||
data: struct {
|
||||
A json.Number `json:"a,string,omitempty"`
|
||||
}{A: "1"},
|
||||
},
|
||||
|
||||
// HeadNumberPtr
|
||||
{
|
||||
|
@ -112,6 +130,12 @@ func TestCoverNumber(t *testing.T) {
|
|||
A *json.Number `json:"a,string"`
|
||||
}{A: numberptr("1")},
|
||||
},
|
||||
{
|
||||
name: "HeadNumberPtrStringOmitEmpty",
|
||||
data: struct {
|
||||
A *json.Number `json:"a,string,omitempty"`
|
||||
}{A: numberptr("1")},
|
||||
},
|
||||
|
||||
// HeadNumberPtrNil
|
||||
{
|
||||
|
@ -132,6 +156,12 @@ func TestCoverNumber(t *testing.T) {
|
|||
A *json.Number `json:"a,string"`
|
||||
}{A: nil},
|
||||
},
|
||||
{
|
||||
name: "HeadNumberPtrNilStringOmitEmpty",
|
||||
data: struct {
|
||||
A *json.Number `json:"a,string,omitempty"`
|
||||
}{A: nil},
|
||||
},
|
||||
|
||||
// PtrHeadNumberZero
|
||||
{
|
||||
|
@ -152,6 +182,12 @@ func TestCoverNumber(t *testing.T) {
|
|||
A json.Number `json:"a,string"`
|
||||
}{},
|
||||
},
|
||||
{
|
||||
name: "PtrHeadNumberZeroStringOmitEmpty",
|
||||
data: &struct {
|
||||
A json.Number `json:"a,string,omitempty"`
|
||||
}{},
|
||||
},
|
||||
|
||||
// PtrHeadNumber
|
||||
{
|
||||
|
@ -172,6 +208,12 @@ func TestCoverNumber(t *testing.T) {
|
|||
A json.Number `json:"a,string"`
|
||||
}{A: "1"},
|
||||
},
|
||||
{
|
||||
name: "PtrHeadNumberStringOmitEmpty",
|
||||
data: &struct {
|
||||
A json.Number `json:"a,string,omitempty"`
|
||||
}{A: "1"},
|
||||
},
|
||||
|
||||
// PtrHeadNumberPtr
|
||||
{
|
||||
|
@ -192,6 +234,12 @@ func TestCoverNumber(t *testing.T) {
|
|||
A *json.Number `json:"a,string"`
|
||||
}{A: numberptr("1")},
|
||||
},
|
||||
{
|
||||
name: "PtrHeadNumberPtrStringOmitEmpty",
|
||||
data: &struct {
|
||||
A *json.Number `json:"a,string,omitempty"`
|
||||
}{A: numberptr("1")},
|
||||
},
|
||||
|
||||
// PtrHeadNumberPtrNil
|
||||
{
|
||||
|
@ -212,6 +260,12 @@ func TestCoverNumber(t *testing.T) {
|
|||
A *json.Number `json:"a,string"`
|
||||
}{A: nil},
|
||||
},
|
||||
{
|
||||
name: "PtrHeadNumberPtrNilStringOmitEmpty",
|
||||
data: &struct {
|
||||
A *json.Number `json:"a,string,omitempty"`
|
||||
}{A: nil},
|
||||
},
|
||||
|
||||
// PtrHeadNumberNil
|
||||
{
|
||||
|
@ -232,6 +286,12 @@ func TestCoverNumber(t *testing.T) {
|
|||
A *json.Number `json:"a,string"`
|
||||
})(nil),
|
||||
},
|
||||
{
|
||||
name: "PtrHeadNumberNilStringOmitEmpty",
|
||||
data: (*struct {
|
||||
A *json.Number `json:"a,string,omitempty"`
|
||||
})(nil),
|
||||
},
|
||||
|
||||
// HeadNumberZeroMultiFields
|
||||
{
|
||||
|
@ -251,13 +311,21 @@ func TestCoverNumber(t *testing.T) {
|
|||
}{},
|
||||
},
|
||||
{
|
||||
name: "HeadNumberZeroMultiFields",
|
||||
name: "HeadNumberZeroMultiFieldsString",
|
||||
data: struct {
|
||||
A json.Number `json:"a,string"`
|
||||
B json.Number `json:"b,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
|
||||
{
|
||||
|
@ -284,6 +352,14 @@ func TestCoverNumber(t *testing.T) {
|
|||
C json.Number `json:"c,string"`
|
||||
}{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
|
||||
{
|
||||
|
@ -310,6 +386,14 @@ func TestCoverNumber(t *testing.T) {
|
|||
C *json.Number `json:"c,string"`
|
||||
}{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
|
||||
{
|
||||
|
@ -336,6 +420,14 @@ func TestCoverNumber(t *testing.T) {
|
|||
C *json.Number `json:"c,string"`
|
||||
}{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
|
||||
{
|
||||
|
@ -359,6 +451,13 @@ func TestCoverNumber(t *testing.T) {
|
|||
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
|
||||
{
|
||||
|
@ -382,6 +481,13 @@ func TestCoverNumber(t *testing.T) {
|
|||
B json.Number `json:"b,string"`
|
||||
}{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
|
||||
{
|
||||
|
@ -405,6 +511,13 @@ func TestCoverNumber(t *testing.T) {
|
|||
B *json.Number `json:"b,string"`
|
||||
}{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
|
||||
{
|
||||
|
@ -428,6 +541,13 @@ func TestCoverNumber(t *testing.T) {
|
|||
B *json.Number `json:"b,string"`
|
||||
}{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
|
||||
{
|
||||
|
@ -451,6 +571,13 @@ func TestCoverNumber(t *testing.T) {
|
|||
B *json.Number `json:"b,string"`
|
||||
})(nil),
|
||||
},
|
||||
{
|
||||
name: "PtrHeadNumberNilMultiFieldsStringOmitEmpty",
|
||||
data: (*struct {
|
||||
A *json.Number `json:"a,string,omitempty"`
|
||||
B *json.Number `json:"b,string,omitempty"`
|
||||
})(nil),
|
||||
},
|
||||
|
||||
// HeadNumberZeroNotRoot
|
||||
{
|
||||
|
@ -477,6 +604,14 @@ func TestCoverNumber(t *testing.T) {
|
|||
}
|
||||
}{},
|
||||
},
|
||||
{
|
||||
name: "HeadNumberZeroNotRootStringOmitEmpty",
|
||||
data: struct {
|
||||
A struct {
|
||||
A json.Number `json:"a,string,omitempty"`
|
||||
}
|
||||
}{},
|
||||
},
|
||||
|
||||
// HeadNumberNotRoot
|
||||
{
|
||||
|
@ -509,6 +644,16 @@ func TestCoverNumber(t *testing.T) {
|
|||
A json.Number `json:"a,string"`
|
||||
}{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
|
||||
{
|
||||
|
@ -541,6 +686,16 @@ func TestCoverNumber(t *testing.T) {
|
|||
A *json.Number `json:"a,string"`
|
||||
}{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
|
||||
{
|
||||
|
@ -567,6 +722,14 @@ func TestCoverNumber(t *testing.T) {
|
|||
}
|
||||
}{},
|
||||
},
|
||||
{
|
||||
name: "HeadNumberPtrNilNotRootStringOmitEmpty",
|
||||
data: struct {
|
||||
A struct {
|
||||
A *json.Number `json:"a,string,omitempty"`
|
||||
}
|
||||
}{},
|
||||
},
|
||||
|
||||
// PtrHeadNumberZeroNotRoot
|
||||
{
|
||||
|
@ -599,6 +762,16 @@ func TestCoverNumber(t *testing.T) {
|
|||
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
|
||||
{
|
||||
|
@ -631,6 +804,16 @@ func TestCoverNumber(t *testing.T) {
|
|||
A json.Number `json:"a,string"`
|
||||
}{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
|
||||
{
|
||||
|
@ -663,6 +846,16 @@ func TestCoverNumber(t *testing.T) {
|
|||
A *json.Number `json:"a,string"`
|
||||
}{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
|
||||
{
|
||||
|
@ -695,6 +888,16 @@ func TestCoverNumber(t *testing.T) {
|
|||
A *json.Number `json:"a,string"`
|
||||
}{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
|
||||
{
|
||||
|
@ -721,6 +924,14 @@ func TestCoverNumber(t *testing.T) {
|
|||
} `json:",string"`
|
||||
}{A: nil},
|
||||
},
|
||||
{
|
||||
name: "PtrHeadNumberNilNotRootStringOmitEmpty",
|
||||
data: struct {
|
||||
A *struct {
|
||||
A *json.Number `json:"a,string,omitempty"`
|
||||
} `json:",string,omitempty"`
|
||||
}{A: nil},
|
||||
},
|
||||
|
||||
// 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
|
||||
{
|
||||
|
@ -803,6 +1025,21 @@ func TestCoverNumber(t *testing.T) {
|
|||
B json.Number `json:"b,string"`
|
||||
}{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
|
||||
{
|
||||
|
@ -850,6 +1087,21 @@ func TestCoverNumber(t *testing.T) {
|
|||
B *json.Number `json:"b,string"`
|
||||
}{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
|
||||
{
|
||||
|
@ -897,6 +1149,21 @@ func TestCoverNumber(t *testing.T) {
|
|||
B *json.Number `json:"b,string"`
|
||||
}{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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -979,6 +1257,21 @@ func TestCoverNumber(t *testing.T) {
|
|||
B json.Number `json:"b,string"`
|
||||
}{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
|
||||
{
|
||||
|
@ -1026,6 +1319,21 @@ func TestCoverNumber(t *testing.T) {
|
|||
B *json.Number `json:"b,string"`
|
||||
}{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
|
||||
{
|
||||
|
@ -1061,6 +1369,17 @@ func TestCoverNumber(t *testing.T) {
|
|||
} `json:",string"`
|
||||
}{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
|
||||
{
|
||||
|
@ -1096,6 +1415,17 @@ func TestCoverNumber(t *testing.T) {
|
|||
}
|
||||
})(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
|
||||
{
|
||||
|
@ -1155,6 +1485,25 @@ func TestCoverNumber(t *testing.T) {
|
|||
B json.Number `json:"b,string"`
|
||||
}{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
|
||||
{
|
||||
|
@ -1196,6 +1545,19 @@ func TestCoverNumber(t *testing.T) {
|
|||
}
|
||||
}{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
|
||||
{
|
||||
|
@ -1237,6 +1599,19 @@ func TestCoverNumber(t *testing.T) {
|
|||
}
|
||||
})(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
|
||||
{
|
||||
|
@ -1296,6 +1671,25 @@ func TestCoverNumber(t *testing.T) {
|
|||
B *json.Number `json:"b,string"`
|
||||
}{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
|
||||
{
|
||||
|
@ -1337,6 +1731,19 @@ func TestCoverNumber(t *testing.T) {
|
|||
}
|
||||
}{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
|
||||
{
|
||||
|
@ -1378,6 +1785,19 @@ func TestCoverNumber(t *testing.T) {
|
|||
}
|
||||
})(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
|
||||
{
|
||||
|
@ -1410,6 +1830,16 @@ func TestCoverNumber(t *testing.T) {
|
|||
B: "2",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "AnonymousHeadNumberStringOmitEmpty",
|
||||
data: struct {
|
||||
structNumberStringOmitEmpty
|
||||
B json.Number `json:"b,string,omitempty"`
|
||||
}{
|
||||
structNumberStringOmitEmpty: structNumberStringOmitEmpty{A: "1"},
|
||||
B: "2",
|
||||
},
|
||||
},
|
||||
|
||||
// PtrAnonymousHeadNumber
|
||||
{
|
||||
|
@ -1442,6 +1872,16 @@ func TestCoverNumber(t *testing.T) {
|
|||
B: "2",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "PtrAnonymousHeadNumberStringOmitEmpty",
|
||||
data: struct {
|
||||
*structNumberStringOmitEmpty
|
||||
B json.Number `json:"b,string,omitempty"`
|
||||
}{
|
||||
structNumberStringOmitEmpty: &structNumberStringOmitEmpty{A: "1"},
|
||||
B: "2",
|
||||
},
|
||||
},
|
||||
|
||||
// NilPtrAnonymousHeadNumber
|
||||
{
|
||||
|
@ -1474,6 +1914,16 @@ func TestCoverNumber(t *testing.T) {
|
|||
B: "2",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "NilPtrAnonymousHeadNumberStringOmitEmpty",
|
||||
data: struct {
|
||||
*structNumberStringOmitEmpty
|
||||
B json.Number `json:"b,string,omitempty"`
|
||||
}{
|
||||
structNumberStringOmitEmpty: nil,
|
||||
B: "2",
|
||||
},
|
||||
},
|
||||
|
||||
// AnonymousHeadNumberPtr
|
||||
{
|
||||
|
@ -1506,6 +1956,16 @@ func TestCoverNumber(t *testing.T) {
|
|||
B: numberptr("2"),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "AnonymousHeadNumberPtrStringOmitEmpty",
|
||||
data: struct {
|
||||
structNumberPtrStringOmitEmpty
|
||||
B *json.Number `json:"b,string,omitempty"`
|
||||
}{
|
||||
structNumberPtrStringOmitEmpty: structNumberPtrStringOmitEmpty{A: numberptr("1")},
|
||||
B: numberptr("2"),
|
||||
},
|
||||
},
|
||||
|
||||
// AnonymousHeadNumberPtrNil
|
||||
{
|
||||
|
@ -1538,6 +1998,16 @@ func TestCoverNumber(t *testing.T) {
|
|||
B: numberptr("2"),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "AnonymousHeadNumberPtrNilStringOmitEmpty",
|
||||
data: struct {
|
||||
structNumberPtrStringOmitEmpty
|
||||
B *json.Number `json:"b,string,omitempty"`
|
||||
}{
|
||||
structNumberPtrStringOmitEmpty: structNumberPtrStringOmitEmpty{A: nil},
|
||||
B: numberptr("2"),
|
||||
},
|
||||
},
|
||||
|
||||
// PtrAnonymousHeadNumberPtr
|
||||
{
|
||||
|
@ -1570,6 +2040,16 @@ func TestCoverNumber(t *testing.T) {
|
|||
B: numberptr("2"),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "PtrAnonymousHeadNumberPtrStringOmitEmpty",
|
||||
data: struct {
|
||||
*structNumberPtrStringOmitEmpty
|
||||
B *json.Number `json:"b,string,omitempty"`
|
||||
}{
|
||||
structNumberPtrStringOmitEmpty: &structNumberPtrStringOmitEmpty{A: numberptr("1")},
|
||||
B: numberptr("2"),
|
||||
},
|
||||
},
|
||||
|
||||
// NilPtrAnonymousHeadNumberPtr
|
||||
{
|
||||
|
@ -1602,6 +2082,16 @@ func TestCoverNumber(t *testing.T) {
|
|||
B: numberptr("2"),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "NilPtrAnonymousHeadNumberPtrStringOmitEmpty",
|
||||
data: struct {
|
||||
*structNumberPtrStringOmitEmpty
|
||||
B *json.Number `json:"b,string,omitempty"`
|
||||
}{
|
||||
structNumberPtrStringOmitEmpty: nil,
|
||||
B: numberptr("2"),
|
||||
},
|
||||
},
|
||||
|
||||
// AnonymousHeadNumberOnly
|
||||
{
|
||||
|
@ -1628,6 +2118,14 @@ func TestCoverNumber(t *testing.T) {
|
|||
structNumberString: structNumberString{A: "1"},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "AnonymousHeadNumberOnlyStringOmitEmpty",
|
||||
data: struct {
|
||||
structNumberStringOmitEmpty
|
||||
}{
|
||||
structNumberStringOmitEmpty: structNumberStringOmitEmpty{A: "1"},
|
||||
},
|
||||
},
|
||||
|
||||
// PtrAnonymousHeadNumberOnly
|
||||
{
|
||||
|
@ -1654,6 +2152,14 @@ func TestCoverNumber(t *testing.T) {
|
|||
structNumberString: &structNumberString{A: "1"},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "PtrAnonymousHeadNumberOnlyStringOmitEmpty",
|
||||
data: struct {
|
||||
*structNumberStringOmitEmpty
|
||||
}{
|
||||
structNumberStringOmitEmpty: &structNumberStringOmitEmpty{A: "1"},
|
||||
},
|
||||
},
|
||||
|
||||
// NilPtrAnonymousHeadNumberOnly
|
||||
{
|
||||
|
@ -1680,6 +2186,14 @@ func TestCoverNumber(t *testing.T) {
|
|||
structNumberString: nil,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "NilPtrAnonymousHeadNumberOnlyStringOmitEmpty",
|
||||
data: struct {
|
||||
*structNumberStringOmitEmpty
|
||||
}{
|
||||
structNumberStringOmitEmpty: nil,
|
||||
},
|
||||
},
|
||||
|
||||
// AnonymousHeadNumberPtrOnly
|
||||
{
|
||||
|
@ -1706,6 +2220,14 @@ func TestCoverNumber(t *testing.T) {
|
|||
structNumberPtrString: structNumberPtrString{A: numberptr("1")},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "AnonymousHeadNumberPtrOnlyStringOmitEmpty",
|
||||
data: struct {
|
||||
structNumberPtrStringOmitEmpty
|
||||
}{
|
||||
structNumberPtrStringOmitEmpty: structNumberPtrStringOmitEmpty{A: numberptr("1")},
|
||||
},
|
||||
},
|
||||
|
||||
// AnonymousHeadNumberPtrNilOnly
|
||||
{
|
||||
|
@ -1732,6 +2254,14 @@ func TestCoverNumber(t *testing.T) {
|
|||
structNumberPtrString: structNumberPtrString{A: nil},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "AnonymousHeadNumberPtrNilOnlyStringOmitEmpty",
|
||||
data: struct {
|
||||
structNumberPtrStringOmitEmpty
|
||||
}{
|
||||
structNumberPtrStringOmitEmpty: structNumberPtrStringOmitEmpty{A: nil},
|
||||
},
|
||||
},
|
||||
|
||||
// PtrAnonymousHeadNumberPtrOnly
|
||||
{
|
||||
|
@ -1758,6 +2288,14 @@ func TestCoverNumber(t *testing.T) {
|
|||
structNumberPtrString: &structNumberPtrString{A: numberptr("1")},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "PtrAnonymousHeadNumberPtrOnlyStringOmitEmpty",
|
||||
data: struct {
|
||||
*structNumberPtrStringOmitEmpty
|
||||
}{
|
||||
structNumberPtrStringOmitEmpty: &structNumberPtrStringOmitEmpty{A: numberptr("1")},
|
||||
},
|
||||
},
|
||||
|
||||
// NilPtrAnonymousHeadNumberPtrOnly
|
||||
{
|
||||
|
@ -1784,6 +2322,14 @@ func TestCoverNumber(t *testing.T) {
|
|||
structNumberPtrString: nil,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "NilPtrAnonymousHeadNumberPtrOnlyStringOmitEmpty",
|
||||
data: struct {
|
||||
*structNumberPtrStringOmitEmpty
|
||||
}{
|
||||
structNumberPtrStringOmitEmpty: nil,
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
for _, indent := range []bool{true, false} {
|
||||
|
|
Loading…
Reference in New Issue