diff --git a/cover_int32_test.go b/cover_int32_test.go index 80110ae..b7b8b73 100644 --- a/cover_int32_test.go +++ b/cover_int32_test.go @@ -2,7 +2,6 @@ package json_test import ( "bytes" - "strings" "testing" "github.com/goccy/go-json" @@ -30,42 +29,24 @@ func TestCoverInt32(t *testing.T) { } tests := []struct { - name string - expected string - indentExpected string - data interface{} + name string + data interface{} }{ // HeadInt32Zero { - name: "HeadInt32Zero", - expected: `{"a":0}`, - indentExpected: ` -{ - "a": 0 -} -`, + name: "HeadInt32Zero", data: struct { A int32 `json:"a"` }{}, }, { - name: "HeadInt32ZeroOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "HeadInt32ZeroOmitEmpty", data: struct { A int32 `json:"a,omitempty"` }{}, }, { - name: "HeadInt32ZeroString", - expected: `{"a":"0"}`, - indentExpected: ` -{ - "a": "0" -} -`, + name: "HeadInt32ZeroString", data: struct { A int32 `json:"a,string"` }{}, @@ -73,37 +54,19 @@ func TestCoverInt32(t *testing.T) { // HeadInt32 { - name: "HeadInt32", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "HeadInt32", data: struct { A int32 `json:"a"` }{A: 1}, }, { - name: "HeadInt32OmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "HeadInt32OmitEmpty", data: struct { A int32 `json:"a,omitempty"` }{A: 1}, }, { - name: "HeadInt32String", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "HeadInt32String", data: struct { A int32 `json:"a,string"` }{A: 1}, @@ -111,37 +74,19 @@ func TestCoverInt32(t *testing.T) { // HeadInt32Ptr { - name: "HeadInt32Ptr", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "HeadInt32Ptr", data: struct { A *int32 `json:"a"` }{A: int32ptr(1)}, }, { - name: "HeadInt32PtrOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "HeadInt32PtrOmitEmpty", data: struct { A *int32 `json:"a,omitempty"` }{A: int32ptr(1)}, }, { - name: "HeadInt32PtrString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "HeadInt32PtrString", data: struct { A *int32 `json:"a,string"` }{A: int32ptr(1)}, @@ -149,35 +94,19 @@ func TestCoverInt32(t *testing.T) { // HeadInt32PtrNil { - name: "HeadInt32PtrNil", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "HeadInt32PtrNil", data: struct { A *int32 `json:"a"` }{A: nil}, }, { - name: "HeadInt32PtrNilOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "HeadInt32PtrNilOmitEmpty", data: struct { A *int32 `json:"a,omitempty"` }{A: nil}, }, { - name: "HeadInt32PtrNilString", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "HeadInt32PtrNilString", data: struct { A *int32 `json:"a,string"` }{A: nil}, @@ -185,35 +114,19 @@ func TestCoverInt32(t *testing.T) { // PtrHeadInt32Zero { - name: "PtrHeadInt32Zero", - expected: `{"a":0}`, - indentExpected: ` -{ - "a": 0 -} -`, + name: "PtrHeadInt32Zero", data: &struct { A int32 `json:"a"` }{}, }, { - name: "PtrHeadInt32ZeroOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadInt32ZeroOmitEmpty", data: &struct { A int32 `json:"a,omitempty"` }{}, }, { - name: "PtrHeadInt32ZeroString", - expected: `{"a":"0"}`, - indentExpected: ` -{ - "a": "0" -} -`, + name: "PtrHeadInt32ZeroString", data: &struct { A int32 `json:"a,string"` }{}, @@ -221,37 +134,19 @@ func TestCoverInt32(t *testing.T) { // PtrHeadInt32 { - name: "PtrHeadInt32", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrHeadInt32", data: &struct { A int32 `json:"a"` }{A: 1}, }, { - name: "PtrHeadInt32OmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrHeadInt32OmitEmpty", data: &struct { A int32 `json:"a,omitempty"` }{A: 1}, }, { - name: "PtrHeadInt32String", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "PtrHeadInt32String", data: &struct { A int32 `json:"a,string"` }{A: 1}, @@ -259,37 +154,19 @@ func TestCoverInt32(t *testing.T) { // PtrHeadInt32Ptr { - name: "PtrHeadInt32Ptr", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrHeadInt32Ptr", data: &struct { A *int32 `json:"a"` }{A: int32ptr(1)}, }, { - name: "PtrHeadInt32PtrOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrHeadInt32PtrOmitEmpty", data: &struct { A *int32 `json:"a,omitempty"` }{A: int32ptr(1)}, }, { - name: "PtrHeadInt32PtrString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "PtrHeadInt32PtrString", data: &struct { A *int32 `json:"a,string"` }{A: int32ptr(1)}, @@ -297,35 +174,19 @@ func TestCoverInt32(t *testing.T) { // PtrHeadInt32PtrNil { - name: "PtrHeadInt32PtrNil", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "PtrHeadInt32PtrNil", data: &struct { A *int32 `json:"a"` }{A: nil}, }, { - name: "PtrHeadInt32PtrNilOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadInt32PtrNilOmitEmpty", data: &struct { A *int32 `json:"a,omitempty"` }{A: nil}, }, { - name: "PtrHeadInt32PtrNilString", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "PtrHeadInt32PtrNilString", data: &struct { A *int32 `json:"a,string"` }{A: nil}, @@ -333,31 +194,19 @@ func TestCoverInt32(t *testing.T) { // PtrHeadInt32Nil { - name: "PtrHeadInt32Nil", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt32Nil", data: (*struct { A *int32 `json:"a"` })(nil), }, { - name: "PtrHeadInt32NilOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt32NilOmitEmpty", data: (*struct { A *int32 `json:"a,omitempty"` })(nil), }, { - name: "PtrHeadInt32NilString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt32NilString", data: (*struct { A *int32 `json:"a,string"` })(nil), @@ -365,209 +214,125 @@ null // HeadInt32ZeroMultiFields { - name: "HeadInt32ZeroMultiFields", - expected: `{"a":0,"b":0}`, - indentExpected: ` -{ - "a": 0, - "b": 0 -} -`, + name: "HeadInt32ZeroMultiFields", data: struct { A int32 `json:"a"` B int32 `json:"b"` + C int32 `json:"c"` }{}, }, { - name: "HeadInt32ZeroMultiFieldsOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "HeadInt32ZeroMultiFieldsOmitEmpty", data: struct { A int32 `json:"a,omitempty"` B int32 `json:"b,omitempty"` + C int32 `json:"c,omitempty"` }{}, }, { - name: "HeadInt32ZeroMultiFields", - expected: `{"a":"0","b":"0"}`, - indentExpected: ` -{ - "a": "0", - "b": "0" -} -`, + name: "HeadInt32ZeroMultiFields", data: struct { A int32 `json:"a,string"` B int32 `json:"b,string"` + C int32 `json:"c,string"` }{}, }, // HeadInt32MultiFields { - name: "HeadInt32MultiFields", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "HeadInt32MultiFields", data: struct { A int32 `json:"a"` B int32 `json:"b"` - }{A: 1, B: 2}, + C int32 `json:"c"` + }{A: 1, B: 2, C: 3}, }, { - name: "HeadInt32MultiFieldsOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "HeadInt32MultiFieldsOmitEmpty", data: struct { A int32 `json:"a,omitempty"` B int32 `json:"b,omitempty"` - }{A: 1, B: 2}, + C int32 `json:"c,omitempty"` + }{A: 1, B: 2, C: 3}, }, { - name: "HeadInt32MultiFieldsString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "HeadInt32MultiFieldsString", data: struct { A int32 `json:"a,string"` B int32 `json:"b,string"` - }{A: 1, B: 2}, + C int32 `json:"c,string"` + }{A: 1, B: 2, C: 3}, }, // HeadInt32PtrMultiFields { - name: "HeadInt32PtrMultiFields", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "HeadInt32PtrMultiFields", data: struct { A *int32 `json:"a"` B *int32 `json:"b"` - }{A: int32ptr(1), B: int32ptr(2)}, + C *int32 `json:"c"` + }{A: int32ptr(1), B: int32ptr(2), C: int32ptr(3)}, }, { - name: "HeadInt32PtrMultiFieldsOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "HeadInt32PtrMultiFieldsOmitEmpty", data: struct { A *int32 `json:"a,omitempty"` B *int32 `json:"b,omitempty"` - }{A: int32ptr(1), B: int32ptr(2)}, + C *int32 `json:"c,omitempty"` + }{A: int32ptr(1), B: int32ptr(2), C: int32ptr(3)}, }, { - name: "HeadInt32PtrMultiFieldsString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "HeadInt32PtrMultiFieldsString", data: struct { A *int32 `json:"a,string"` B *int32 `json:"b,string"` - }{A: int32ptr(1), B: int32ptr(2)}, + C *int32 `json:"c,string"` + }{A: int32ptr(1), B: int32ptr(2), C: int32ptr(3)}, }, // HeadInt32PtrNilMultiFields { - name: "HeadInt32PtrNilMultiFields", - expected: `{"a":null,"b":null}`, - indentExpected: ` -{ - "a": null, - "b": null -} -`, + name: "HeadInt32PtrNilMultiFields", data: struct { A *int32 `json:"a"` B *int32 `json:"b"` - }{A: nil, B: nil}, + C *int32 `json:"c"` + }{A: nil, B: nil, C: nil}, }, { - name: "HeadInt32PtrNilMultiFieldsOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "HeadInt32PtrNilMultiFieldsOmitEmpty", data: struct { A *int32 `json:"a,omitempty"` B *int32 `json:"b,omitempty"` - }{A: nil, B: nil}, + C *int32 `json:"c,omitempty"` + }{A: nil, B: nil, C: nil}, }, { - name: "HeadInt32PtrNilMultiFieldsString", - expected: `{"a":null,"b":null}`, - indentExpected: ` -{ - "a": null, - "b": null -} -`, + name: "HeadInt32PtrNilMultiFieldsString", data: struct { A *int32 `json:"a,string"` B *int32 `json:"b,string"` - }{A: nil, B: nil}, + C *int32 `json:"c,string"` + }{A: nil, B: nil, C: nil}, }, // PtrHeadInt32ZeroMultiFields { - name: "PtrHeadInt32ZeroMultiFields", - expected: `{"a":0,"b":0}`, - indentExpected: ` -{ - "a": 0, - "b": 0 -} -`, + name: "PtrHeadInt32ZeroMultiFields", data: &struct { A int32 `json:"a"` B int32 `json:"b"` }{}, }, { - name: "PtrHeadInt32ZeroMultiFieldsOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadInt32ZeroMultiFieldsOmitEmpty", data: &struct { A int32 `json:"a,omitempty"` B int32 `json:"b,omitempty"` }{}, }, { - name: "PtrHeadInt32ZeroMultiFieldsString", - expected: `{"a":"0","b":"0"}`, - indentExpected: ` -{ - "a": "0", - "b": "0" -} -`, + name: "PtrHeadInt32ZeroMultiFieldsString", data: &struct { A int32 `json:"a,string"` B int32 `json:"b,string"` @@ -576,42 +341,21 @@ null // PtrHeadInt32MultiFields { - name: "PtrHeadInt32MultiFields", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrHeadInt32MultiFields", data: &struct { A int32 `json:"a"` B int32 `json:"b"` }{A: 1, B: 2}, }, { - name: "PtrHeadInt32MultiFieldsOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrHeadInt32MultiFieldsOmitEmpty", data: &struct { A int32 `json:"a,omitempty"` B int32 `json:"b,omitempty"` }{A: 1, B: 2}, }, { - name: "PtrHeadInt32MultiFieldsString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "PtrHeadInt32MultiFieldsString", data: &struct { A int32 `json:"a,string"` B int32 `json:"b,string"` @@ -620,42 +364,21 @@ null // PtrHeadInt32PtrMultiFields { - name: "PtrHeadInt32PtrMultiFields", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrHeadInt32PtrMultiFields", data: &struct { A *int32 `json:"a"` B *int32 `json:"b"` }{A: int32ptr(1), B: int32ptr(2)}, }, { - name: "PtrHeadInt32PtrMultiFieldsOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrHeadInt32PtrMultiFieldsOmitEmpty", data: &struct { A *int32 `json:"a,omitempty"` B *int32 `json:"b,omitempty"` }{A: int32ptr(1), B: int32ptr(2)}, }, { - name: "PtrHeadInt32PtrMultiFieldsString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "PtrHeadInt32PtrMultiFieldsString", data: &struct { A *int32 `json:"a,string"` B *int32 `json:"b,string"` @@ -664,39 +387,21 @@ null // PtrHeadInt32PtrNilMultiFields { - name: "PtrHeadInt32PtrNilMultiFields", - expected: `{"a":null,"b":null}`, - indentExpected: ` -{ - "a": null, - "b": null -} -`, + name: "PtrHeadInt32PtrNilMultiFields", data: &struct { A *int32 `json:"a"` B *int32 `json:"b"` }{A: nil, B: nil}, }, { - name: "PtrHeadInt32PtrNilMultiFieldsOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadInt32PtrNilMultiFieldsOmitEmpty", data: &struct { A *int32 `json:"a,omitempty"` B *int32 `json:"b,omitempty"` }{A: nil, B: nil}, }, { - name: "PtrHeadInt32PtrNilMultiFieldsString", - expected: `{"a":null,"b":null}`, - indentExpected: ` -{ - "a": null, - "b": null -} -`, + name: "PtrHeadInt32PtrNilMultiFieldsString", data: &struct { A *int32 `json:"a,string"` B *int32 `json:"b,string"` @@ -705,33 +410,21 @@ null // PtrHeadInt32NilMultiFields { - name: "PtrHeadInt32NilMultiFields", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt32NilMultiFields", data: (*struct { A *int32 `json:"a"` B *int32 `json:"b"` })(nil), }, { - name: "PtrHeadInt32NilMultiFieldsOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt32NilMultiFieldsOmitEmpty", data: (*struct { A *int32 `json:"a,omitempty"` B *int32 `json:"b,omitempty"` })(nil), }, { - name: "PtrHeadInt32NilMultiFieldsString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt32NilMultiFieldsString", data: (*struct { A *int32 `json:"a,string"` B *int32 `json:"b,string"` @@ -740,15 +433,7 @@ null // HeadInt32ZeroNotRoot { - name: "HeadInt32ZeroNotRoot", - expected: `{"A":{"a":0}}`, - indentExpected: ` -{ - "A": { - "a": 0 - } -} -`, + name: "HeadInt32ZeroNotRoot", data: struct { A struct { A int32 `json:"a"` @@ -756,13 +441,7 @@ null }{}, }, { - name: "HeadInt32ZeroNotRootOmitEmpty", - expected: `{"A":{}}`, - indentExpected: ` -{ - "A": {} -} -`, + name: "HeadInt32ZeroNotRootOmitEmpty", data: struct { A struct { A int32 `json:"a,omitempty"` @@ -770,15 +449,7 @@ null }{}, }, { - name: "HeadInt32ZeroNotRootString", - expected: `{"A":{"a":"0"}}`, - indentExpected: ` -{ - "A": { - "a": "0" - } -} -`, + name: "HeadInt32ZeroNotRootString", data: struct { A struct { A int32 `json:"a,string"` @@ -788,15 +459,7 @@ null // HeadInt32NotRoot { - name: "HeadInt32NotRoot", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "HeadInt32NotRoot", data: struct { A struct { A int32 `json:"a"` @@ -806,15 +469,7 @@ null }{A: 1}}, }, { - name: "HeadInt32NotRootOmitEmpty", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "HeadInt32NotRootOmitEmpty", data: struct { A struct { A int32 `json:"a,omitempty"` @@ -824,15 +479,7 @@ null }{A: 1}}, }, { - name: "HeadInt32NotRootString", - expected: `{"A":{"a":"1"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - } -} -`, + name: "HeadInt32NotRootString", data: struct { A struct { A int32 `json:"a,string"` @@ -844,15 +491,7 @@ null // HeadInt32PtrNotRoot { - name: "HeadInt32PtrNotRoot", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "HeadInt32PtrNotRoot", data: struct { A struct { A *int32 `json:"a"` @@ -862,15 +501,7 @@ null }{int32ptr(1)}}, }, { - name: "HeadInt32PtrNotRootOmitEmpty", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "HeadInt32PtrNotRootOmitEmpty", data: struct { A struct { A *int32 `json:"a,omitempty"` @@ -880,15 +511,7 @@ null }{int32ptr(1)}}, }, { - name: "HeadInt32PtrNotRootString", - expected: `{"A":{"a":"1"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - } -} -`, + name: "HeadInt32PtrNotRootString", data: struct { A struct { A *int32 `json:"a,string"` @@ -900,15 +523,7 @@ null // HeadInt32PtrNilNotRoot { - name: "HeadInt32PtrNilNotRoot", - expected: `{"A":{"a":null}}`, - indentExpected: ` -{ - "A": { - "a": null - } -} -`, + name: "HeadInt32PtrNilNotRoot", data: struct { A struct { A *int32 `json:"a"` @@ -916,13 +531,7 @@ null }{}, }, { - name: "HeadInt32PtrNilNotRootOmitEmpty", - expected: `{"A":{}}`, - indentExpected: ` -{ - "A": {} -} -`, + name: "HeadInt32PtrNilNotRootOmitEmpty", data: struct { A struct { A *int32 `json:"a,omitempty"` @@ -930,15 +539,7 @@ null }{}, }, { - name: "HeadInt32PtrNilNotRootString", - expected: `{"A":{"a":null}}`, - indentExpected: ` -{ - "A": { - "a": null - } -} -`, + name: "HeadInt32PtrNilNotRootString", data: struct { A struct { A *int32 `json:"a,string"` @@ -948,15 +549,7 @@ null // PtrHeadInt32ZeroNotRoot { - name: "PtrHeadInt32ZeroNotRoot", - expected: `{"A":{"a":0}}`, - indentExpected: ` -{ - "A": { - "a": 0 - } -} -`, + name: "PtrHeadInt32ZeroNotRoot", data: struct { A *struct { A int32 `json:"a"` @@ -966,13 +559,7 @@ null })}, }, { - name: "PtrHeadInt32ZeroNotRootOmitEmpty", - expected: `{"A":{}}`, - indentExpected: ` -{ - "A": {} -} -`, + name: "PtrHeadInt32ZeroNotRootOmitEmpty", data: struct { A *struct { A int32 `json:"a,omitempty"` @@ -982,15 +569,7 @@ null })}, }, { - name: "PtrHeadInt32ZeroNotRootString", - expected: `{"A":{"a":"0"}}`, - indentExpected: ` -{ - "A": { - "a": "0" - } -} -`, + name: "PtrHeadInt32ZeroNotRootString", data: struct { A *struct { A int32 `json:"a,string"` @@ -1002,15 +581,7 @@ null // PtrHeadInt32NotRoot { - name: "PtrHeadInt32NotRoot", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "PtrHeadInt32NotRoot", data: struct { A *struct { A int32 `json:"a"` @@ -1020,15 +591,7 @@ null }{A: 1})}, }, { - name: "PtrHeadInt32NotRootOmitEmpty", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "PtrHeadInt32NotRootOmitEmpty", data: struct { A *struct { A int32 `json:"a,omitempty"` @@ -1038,15 +601,7 @@ null }{A: 1})}, }, { - name: "PtrHeadInt32NotRootString", - expected: `{"A":{"a":"1"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - } -} -`, + name: "PtrHeadInt32NotRootString", data: struct { A *struct { A int32 `json:"a,string"` @@ -1058,15 +613,7 @@ null // PtrHeadInt32PtrNotRoot { - name: "PtrHeadInt32PtrNotRoot", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "PtrHeadInt32PtrNotRoot", data: struct { A *struct { A *int32 `json:"a"` @@ -1076,15 +623,7 @@ null }{A: int32ptr(1)})}, }, { - name: "PtrHeadInt32PtrNotRootOmitEmpty", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "PtrHeadInt32PtrNotRootOmitEmpty", data: struct { A *struct { A *int32 `json:"a,omitempty"` @@ -1094,15 +633,7 @@ null }{A: int32ptr(1)})}, }, { - name: "PtrHeadInt32PtrNotRootString", - expected: `{"A":{"a":"1"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - } -} -`, + name: "PtrHeadInt32PtrNotRootString", data: struct { A *struct { A *int32 `json:"a,string"` @@ -1114,15 +645,7 @@ null // PtrHeadInt32PtrNilNotRoot { - name: "PtrHeadInt32PtrNilNotRoot", - expected: `{"A":{"a":null}}`, - indentExpected: ` -{ - "A": { - "a": null - } -} -`, + name: "PtrHeadInt32PtrNilNotRoot", data: struct { A *struct { A *int32 `json:"a"` @@ -1132,13 +655,7 @@ null }{A: nil})}, }, { - name: "PtrHeadInt32PtrNilNotRootOmitEmpty", - expected: `{"A":{}}`, - indentExpected: ` -{ - "A": {} -} -`, + name: "PtrHeadInt32PtrNilNotRootOmitEmpty", data: struct { A *struct { A *int32 `json:"a,omitempty"` @@ -1148,15 +665,7 @@ null }{A: nil})}, }, { - name: "PtrHeadInt32PtrNilNotRootString", - expected: `{"A":{"a":null}}`, - indentExpected: ` -{ - "A": { - "a": null - } -} -`, + name: "PtrHeadInt32PtrNilNotRootString", data: struct { A *struct { A *int32 `json:"a,string"` @@ -1168,13 +677,7 @@ null // PtrHeadInt32NilNotRoot { - name: "PtrHeadInt32NilNotRoot", - expected: `{"A":null}`, - indentExpected: ` -{ - "A": null -} -`, + name: "PtrHeadInt32NilNotRoot", data: struct { A *struct { A *int32 `json:"a"` @@ -1182,11 +685,7 @@ null }{A: nil}, }, { - name: "PtrHeadInt32NilNotRootOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadInt32NilNotRootOmitEmpty", data: struct { A *struct { A *int32 `json:"a,omitempty"` @@ -1194,13 +693,7 @@ null }{A: nil}, }, { - name: "PtrHeadInt32NilNotRootString", - expected: `{"A":null}`, - indentExpected: ` -{ - "A": null -} -`, + name: "PtrHeadInt32NilNotRootString", data: struct { A *struct { A *int32 `json:"a,string"` @@ -1210,18 +703,7 @@ null // HeadInt32ZeroMultiFieldsNotRoot { - name: "HeadInt32ZeroMultiFieldsNotRoot", - expected: `{"A":{"a":0},"B":{"b":0}}`, - indentExpected: ` -{ - "A": { - "a": 0 - }, - "B": { - "b": 0 - } -} -`, + name: "HeadInt32ZeroMultiFieldsNotRoot", data: struct { A struct { A int32 `json:"a"` @@ -1232,14 +714,7 @@ null }{}, }, { - name: "HeadInt32ZeroMultiFieldsNotRootOmitEmpty", - expected: `{"A":{},"B":{}}`, - indentExpected: ` -{ - "A": {}, - "B": {} -} -`, + name: "HeadInt32ZeroMultiFieldsNotRootOmitEmpty", data: struct { A struct { A int32 `json:"a,omitempty"` @@ -1250,18 +725,7 @@ null }{}, }, { - name: "HeadInt32ZeroMultiFieldsNotRootString", - expected: `{"A":{"a":"0"},"B":{"b":"0"}}`, - indentExpected: ` -{ - "A": { - "a": "0" - }, - "B": { - "b": "0" - } -} -`, + name: "HeadInt32ZeroMultiFieldsNotRootString", data: struct { A struct { A int32 `json:"a,string"` @@ -1274,18 +738,7 @@ null // HeadInt32MultiFieldsNotRoot { - name: "HeadInt32MultiFieldsNotRoot", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "HeadInt32MultiFieldsNotRoot", data: struct { A struct { A int32 `json:"a"` @@ -1300,18 +753,7 @@ null }{B: 2}}, }, { - name: "HeadInt32MultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "HeadInt32MultiFieldsNotRootOmitEmpty", data: struct { A struct { A int32 `json:"a,omitempty"` @@ -1326,18 +768,7 @@ null }{B: 2}}, }, { - name: "HeadInt32MultiFieldsNotRootString", - expected: `{"A":{"a":"1"},"B":{"b":"2"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - }, - "B": { - "b": "2" - } -} -`, + name: "HeadInt32MultiFieldsNotRootString", data: struct { A struct { A int32 `json:"a,string"` @@ -1354,18 +785,7 @@ null // HeadInt32PtrMultiFieldsNotRoot { - name: "HeadInt32PtrMultiFieldsNotRoot", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "HeadInt32PtrMultiFieldsNotRoot", data: struct { A struct { A *int32 `json:"a"` @@ -1380,18 +800,7 @@ null }{B: int32ptr(2)}}, }, { - name: "HeadInt32PtrMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "HeadInt32PtrMultiFieldsNotRootOmitEmpty", data: struct { A struct { A *int32 `json:"a,omitempty"` @@ -1406,18 +815,7 @@ null }{B: int32ptr(2)}}, }, { - name: "HeadInt32PtrMultiFieldsNotRootString", - expected: `{"A":{"a":"1"},"B":{"b":"2"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - }, - "B": { - "b": "2" - } -} -`, + name: "HeadInt32PtrMultiFieldsNotRootString", data: struct { A struct { A *int32 `json:"a,string"` @@ -1434,18 +832,7 @@ null // HeadInt32PtrNilMultiFieldsNotRoot { - name: "HeadInt32PtrNilMultiFieldsNotRoot", - expected: `{"A":{"a":null},"B":{"b":null}}`, - indentExpected: ` -{ - "A": { - "a": null - }, - "B": { - "b": null - } -} -`, + name: "HeadInt32PtrNilMultiFieldsNotRoot", data: struct { A struct { A *int32 `json:"a"` @@ -1460,14 +847,7 @@ null }{B: nil}}, }, { - name: "HeadInt32PtrNilMultiFieldsNotRootOmitEmpty", - expected: `{"A":{},"B":{}}`, - indentExpected: ` -{ - "A": {}, - "B": {} -} -`, + name: "HeadInt32PtrNilMultiFieldsNotRootOmitEmpty", data: struct { A struct { A *int32 `json:"a,omitempty"` @@ -1482,18 +862,7 @@ null }{B: nil}}, }, { - name: "HeadInt32PtrNilMultiFieldsNotRootString", - expected: `{"A":{"a":null},"B":{"b":null}}`, - indentExpected: ` -{ - "A": { - "a": null - }, - "B": { - "b": null - } -} -`, + name: "HeadInt32PtrNilMultiFieldsNotRootString", data: struct { A struct { A *int32 `json:"a,string"` @@ -1510,18 +879,7 @@ null // PtrHeadInt32ZeroMultiFieldsNotRoot { - name: "PtrHeadInt32ZeroMultiFieldsNotRoot", - expected: `{"A":{"a":0},"B":{"b":0}}`, - indentExpected: ` -{ - "A": { - "a": 0 - }, - "B": { - "b": 0 - } -} -`, + name: "PtrHeadInt32ZeroMultiFieldsNotRoot", data: &struct { A struct { A int32 `json:"a"` @@ -1532,14 +890,7 @@ null }{}, }, { - name: "PtrHeadInt32ZeroMultiFieldsNotRootOmitEmpty", - expected: `{"A":{},"B":{}}`, - indentExpected: ` -{ - "A": {}, - "B": {} -} -`, + name: "PtrHeadInt32ZeroMultiFieldsNotRootOmitEmpty", data: &struct { A struct { A int32 `json:"a,omitempty"` @@ -1550,18 +901,7 @@ null }{}, }, { - name: "PtrHeadInt32ZeroMultiFieldsNotRootString", - expected: `{"A":{"a":"0"},"B":{"b":"0"}}`, - indentExpected: ` -{ - "A": { - "a": "0" - }, - "B": { - "b": "0" - } -} -`, + name: "PtrHeadInt32ZeroMultiFieldsNotRootString", data: &struct { A struct { A int32 `json:"a,string"` @@ -1574,18 +914,7 @@ null // PtrHeadInt32MultiFieldsNotRoot { - name: "PtrHeadInt32MultiFieldsNotRoot", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "PtrHeadInt32MultiFieldsNotRoot", data: &struct { A struct { A int32 `json:"a"` @@ -1600,18 +929,7 @@ null }{B: 2}}, }, { - name: "PtrHeadInt32MultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "PtrHeadInt32MultiFieldsNotRootOmitEmpty", data: &struct { A struct { A int32 `json:"a,omitempty"` @@ -1626,18 +944,7 @@ null }{B: 2}}, }, { - name: "PtrHeadInt32MultiFieldsNotRootString", - expected: `{"A":{"a":"1"},"B":{"b":"2"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - }, - "B": { - "b": "2" - } -} -`, + name: "PtrHeadInt32MultiFieldsNotRootString", data: &struct { A struct { A int32 `json:"a,string"` @@ -1654,18 +961,7 @@ null // PtrHeadInt32PtrMultiFieldsNotRoot { - name: "PtrHeadInt32PtrMultiFieldsNotRoot", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "PtrHeadInt32PtrMultiFieldsNotRoot", data: &struct { A *struct { A *int32 `json:"a"` @@ -1680,18 +976,7 @@ null }{B: int32ptr(2)})}, }, { - name: "PtrHeadInt32PtrMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "PtrHeadInt32PtrMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A *int32 `json:"a,omitempty"` @@ -1706,18 +991,7 @@ null }{B: int32ptr(2)})}, }, { - name: "PtrHeadInt32PtrMultiFieldsNotRootString", - expected: `{"A":{"a":"1"},"B":{"b":"2"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - }, - "B": { - "b": "2" - } -} -`, + name: "PtrHeadInt32PtrMultiFieldsNotRootString", data: &struct { A *struct { A *int32 `json:"a,string"` @@ -1734,14 +1008,7 @@ null // PtrHeadInt32PtrNilMultiFieldsNotRoot { - name: "PtrHeadInt32PtrNilMultiFieldsNotRoot", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadInt32PtrNilMultiFieldsNotRoot", data: &struct { A *struct { A *int32 `json:"a"` @@ -1752,11 +1019,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadInt32PtrNilMultiFieldsNotRootOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadInt32PtrNilMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A *int32 `json:"a,omitempty"` @@ -1767,14 +1030,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadInt32PtrNilMultiFieldsNotRootString", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadInt32PtrNilMultiFieldsNotRootString", data: &struct { A *struct { A *int32 `json:"a,string"` @@ -1787,11 +1043,7 @@ null // PtrHeadInt32NilMultiFieldsNotRoot { - name: "PtrHeadInt32NilMultiFieldsNotRoot", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt32NilMultiFieldsNotRoot", data: (*struct { A *struct { A *int32 `json:"a"` @@ -1802,11 +1054,7 @@ null })(nil), }, { - name: "PtrHeadInt32NilMultiFieldsNotRootOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt32NilMultiFieldsNotRootOmitEmpty", data: (*struct { A *struct { A *int32 `json:"a,omitempty"` @@ -1817,11 +1065,7 @@ null })(nil), }, { - name: "PtrHeadInt32NilMultiFieldsNotRootString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt32NilMultiFieldsNotRootString", data: (*struct { A *struct { A *int32 `json:"a,string"` @@ -1834,20 +1078,7 @@ null // PtrHeadInt32DoubleMultiFieldsNotRoot { - name: "PtrHeadInt32DoubleMultiFieldsNotRoot", - expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`, - indentExpected: ` -{ - "A": { - "a": 1, - "b": 2 - }, - "B": { - "a": 3, - "b": 4 - } -} -`, + name: "PtrHeadInt32DoubleMultiFieldsNotRoot", data: &struct { A *struct { A int32 `json:"a"` @@ -1866,20 +1097,7 @@ null }{A: 3, B: 4})}, }, { - name: "PtrHeadInt32DoubleMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`, - indentExpected: ` -{ - "A": { - "a": 1, - "b": 2 - }, - "B": { - "a": 3, - "b": 4 - } -} -`, + name: "PtrHeadInt32DoubleMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A int32 `json:"a,omitempty"` @@ -1898,20 +1116,7 @@ null }{A: 3, B: 4})}, }, { - name: "PtrHeadInt32DoubleMultiFieldsNotRootString", - expected: `{"A":{"a":"1","b":"2"},"B":{"a":"3","b":"4"}}`, - indentExpected: ` -{ - "A": { - "a": "1", - "b": "2" - }, - "B": { - "a": "3", - "b": "4" - } -} -`, + name: "PtrHeadInt32DoubleMultiFieldsNotRootString", data: &struct { A *struct { A int32 `json:"a,string"` @@ -1932,14 +1137,7 @@ null // PtrHeadInt32NilDoubleMultiFieldsNotRoot { - name: "PtrHeadInt32NilDoubleMultiFieldsNotRoot", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadInt32NilDoubleMultiFieldsNotRoot", data: &struct { A *struct { A int32 `json:"a"` @@ -1952,11 +1150,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadInt32NilDoubleMultiFieldsNotRootOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadInt32NilDoubleMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A int32 `json:"a,omitempty"` @@ -1969,14 +1163,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadInt32NilDoubleMultiFieldsNotRootString", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadInt32NilDoubleMultiFieldsNotRootString", data: &struct { A *struct { A int32 `json:"a,string"` @@ -1991,11 +1178,7 @@ null // PtrHeadInt32NilDoubleMultiFieldsNotRoot { - name: "PtrHeadInt32NilDoubleMultiFieldsNotRoot", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt32NilDoubleMultiFieldsNotRoot", data: (*struct { A *struct { A int32 `json:"a"` @@ -2008,11 +1191,7 @@ null })(nil), }, { - name: "PtrHeadInt32NilDoubleMultiFieldsNotRootOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt32NilDoubleMultiFieldsNotRootOmitEmpty", data: (*struct { A *struct { A int32 `json:"a,omitempty"` @@ -2025,11 +1204,7 @@ null })(nil), }, { - name: "PtrHeadInt32NilDoubleMultiFieldsNotRootString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt32NilDoubleMultiFieldsNotRootString", data: (*struct { A *struct { A int32 `json:"a,string"` @@ -2044,20 +1219,7 @@ null // PtrHeadInt32PtrDoubleMultiFieldsNotRoot { - name: "PtrHeadInt32PtrDoubleMultiFieldsNotRoot", - expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`, - indentExpected: ` -{ - "A": { - "a": 1, - "b": 2 - }, - "B": { - "a": 3, - "b": 4 - } -} -`, + name: "PtrHeadInt32PtrDoubleMultiFieldsNotRoot", data: &struct { A *struct { A *int32 `json:"a"` @@ -2076,20 +1238,7 @@ null }{A: int32ptr(3), B: int32ptr(4)})}, }, { - name: "PtrHeadInt32PtrDoubleMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`, - indentExpected: ` -{ - "A": { - "a": 1, - "b": 2 - }, - "B": { - "a": 3, - "b": 4 - } -} -`, + name: "PtrHeadInt32PtrDoubleMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A *int32 `json:"a,omitempty"` @@ -2108,20 +1257,7 @@ null }{A: int32ptr(3), B: int32ptr(4)})}, }, { - name: "PtrHeadInt32PtrDoubleMultiFieldsNotRootString", - expected: `{"A":{"a":"1","b":"2"},"B":{"a":"3","b":"4"}}`, - indentExpected: ` -{ - "A": { - "a": "1", - "b": "2" - }, - "B": { - "a": "3", - "b": "4" - } -} -`, + name: "PtrHeadInt32PtrDoubleMultiFieldsNotRootString", data: &struct { A *struct { A *int32 `json:"a,string"` @@ -2142,14 +1278,7 @@ null // PtrHeadInt32PtrNilDoubleMultiFieldsNotRoot { - name: "PtrHeadInt32PtrNilDoubleMultiFieldsNotRoot", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadInt32PtrNilDoubleMultiFieldsNotRoot", data: &struct { A *struct { A *int32 `json:"a"` @@ -2162,11 +1291,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadInt32PtrNilDoubleMultiFieldsNotRootOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadInt32PtrNilDoubleMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A *int32 `json:"a,omitempty"` @@ -2179,14 +1304,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadInt32PtrNilDoubleMultiFieldsNotRootString", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadInt32PtrNilDoubleMultiFieldsNotRootString", data: &struct { A *struct { A *int32 `json:"a,string"` @@ -2201,11 +1319,7 @@ null // PtrHeadInt32PtrNilDoubleMultiFieldsNotRoot { - name: "PtrHeadInt32PtrNilDoubleMultiFieldsNotRoot", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt32PtrNilDoubleMultiFieldsNotRoot", data: (*struct { A *struct { A *int32 `json:"a"` @@ -2218,11 +1332,7 @@ null })(nil), }, { - name: "PtrHeadInt32PtrNilDoubleMultiFieldsNotRootOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt32PtrNilDoubleMultiFieldsNotRootOmitEmpty", data: (*struct { A *struct { A *int32 `json:"a,omitempty"` @@ -2235,11 +1345,7 @@ null })(nil), }, { - name: "PtrHeadInt32PtrNilDoubleMultiFieldsNotRootString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt32PtrNilDoubleMultiFieldsNotRootString", data: (*struct { A *struct { A *int32 `json:"a,string"` @@ -2254,14 +1360,7 @@ null // AnonymousHeadInt32 { - name: "AnonymousHeadInt32", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "AnonymousHeadInt32", data: struct { structInt32 B int32 `json:"b"` @@ -2271,14 +1370,7 @@ null }, }, { - name: "AnonymousHeadInt32OmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "AnonymousHeadInt32OmitEmpty", data: struct { structInt32OmitEmpty B int32 `json:"b,omitempty"` @@ -2288,14 +1380,7 @@ null }, }, { - name: "AnonymousHeadInt32String", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "AnonymousHeadInt32String", data: struct { structInt32String B int32 `json:"b,string"` @@ -2307,14 +1392,7 @@ null // PtrAnonymousHeadInt32 { - name: "PtrAnonymousHeadInt32", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrAnonymousHeadInt32", data: struct { *structInt32 B int32 `json:"b"` @@ -2324,14 +1402,7 @@ null }, }, { - name: "PtrAnonymousHeadInt32OmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrAnonymousHeadInt32OmitEmpty", data: struct { *structInt32OmitEmpty B int32 `json:"b,omitempty"` @@ -2341,14 +1412,7 @@ null }, }, { - name: "PtrAnonymousHeadInt32String", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "PtrAnonymousHeadInt32String", data: struct { *structInt32String B int32 `json:"b,string"` @@ -2360,13 +1424,7 @@ null // NilPtrAnonymousHeadInt32 { - name: "NilPtrAnonymousHeadInt32", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "NilPtrAnonymousHeadInt32", data: struct { *structInt32 B int32 `json:"b"` @@ -2376,13 +1434,7 @@ null }, }, { - name: "NilPtrAnonymousHeadInt32OmitEmpty", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "NilPtrAnonymousHeadInt32OmitEmpty", data: struct { *structInt32OmitEmpty B int32 `json:"b,omitempty"` @@ -2392,13 +1444,7 @@ null }, }, { - name: "NilPtrAnonymousHeadInt32String", - expected: `{"b":"2"}`, - indentExpected: ` -{ - "b": "2" -} -`, + name: "NilPtrAnonymousHeadInt32String", data: struct { *structInt32String B int32 `json:"b,string"` @@ -2410,14 +1456,7 @@ null // AnonymousHeadInt32Ptr { - name: "AnonymousHeadInt32Ptr", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "AnonymousHeadInt32Ptr", data: struct { structInt32Ptr B *int32 `json:"b"` @@ -2427,14 +1466,7 @@ null }, }, { - name: "AnonymousHeadInt32PtrOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "AnonymousHeadInt32PtrOmitEmpty", data: struct { structInt32PtrOmitEmpty B *int32 `json:"b,omitempty"` @@ -2444,14 +1476,7 @@ null }, }, { - name: "AnonymousHeadInt32PtrString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "AnonymousHeadInt32PtrString", data: struct { structInt32PtrString B *int32 `json:"b,string"` @@ -2463,14 +1488,7 @@ null // AnonymousHeadInt32PtrNil { - name: "AnonymousHeadInt32PtrNil", - expected: `{"a":null,"b":2}`, - indentExpected: ` -{ - "a": null, - "b": 2 -} -`, + name: "AnonymousHeadInt32PtrNil", data: struct { structInt32Ptr B *int32 `json:"b"` @@ -2480,13 +1498,7 @@ null }, }, { - name: "AnonymousHeadInt32PtrNilOmitEmpty", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "AnonymousHeadInt32PtrNilOmitEmpty", data: struct { structInt32PtrOmitEmpty B *int32 `json:"b,omitempty"` @@ -2496,14 +1508,7 @@ null }, }, { - name: "AnonymousHeadInt32PtrNilString", - expected: `{"a":null,"b":"2"}`, - indentExpected: ` -{ - "a": null, - "b": "2" -} -`, + name: "AnonymousHeadInt32PtrNilString", data: struct { structInt32PtrString B *int32 `json:"b,string"` @@ -2515,14 +1520,7 @@ null // PtrAnonymousHeadInt32Ptr { - name: "PtrAnonymousHeadInt32Ptr", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrAnonymousHeadInt32Ptr", data: struct { *structInt32Ptr B *int32 `json:"b"` @@ -2532,14 +1530,7 @@ null }, }, { - name: "PtrAnonymousHeadInt32PtrOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrAnonymousHeadInt32PtrOmitEmpty", data: struct { *structInt32PtrOmitEmpty B *int32 `json:"b,omitempty"` @@ -2549,14 +1540,7 @@ null }, }, { - name: "PtrAnonymousHeadInt32PtrString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "PtrAnonymousHeadInt32PtrString", data: struct { *structInt32PtrString B *int32 `json:"b,string"` @@ -2568,13 +1552,7 @@ null // NilPtrAnonymousHeadInt32Ptr { - name: "NilPtrAnonymousHeadInt32Ptr", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "NilPtrAnonymousHeadInt32Ptr", data: struct { *structInt32Ptr B *int32 `json:"b"` @@ -2584,13 +1562,7 @@ null }, }, { - name: "NilPtrAnonymousHeadInt32PtrOmitEmpty", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "NilPtrAnonymousHeadInt32PtrOmitEmpty", data: struct { *structInt32PtrOmitEmpty B *int32 `json:"b,omitempty"` @@ -2600,13 +1572,7 @@ null }, }, { - name: "NilPtrAnonymousHeadInt32PtrString", - expected: `{"b":"2"}`, - indentExpected: ` -{ - "b": "2" -} -`, + name: "NilPtrAnonymousHeadInt32PtrString", data: struct { *structInt32PtrString B *int32 `json:"b,string"` @@ -2618,13 +1584,7 @@ null // AnonymousHeadInt32Only { - name: "AnonymousHeadInt32Only", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "AnonymousHeadInt32Only", data: struct { structInt32 }{ @@ -2632,13 +1592,7 @@ null }, }, { - name: "AnonymousHeadInt32OnlyOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "AnonymousHeadInt32OnlyOmitEmpty", data: struct { structInt32OmitEmpty }{ @@ -2646,13 +1600,7 @@ null }, }, { - name: "AnonymousHeadInt32OnlyString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "AnonymousHeadInt32OnlyString", data: struct { structInt32String }{ @@ -2662,13 +1610,7 @@ null // PtrAnonymousHeadInt32Only { - name: "PtrAnonymousHeadInt32Only", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrAnonymousHeadInt32Only", data: struct { *structInt32 }{ @@ -2676,13 +1618,7 @@ null }, }, { - name: "PtrAnonymousHeadInt32OnlyOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrAnonymousHeadInt32OnlyOmitEmpty", data: struct { *structInt32OmitEmpty }{ @@ -2690,13 +1626,7 @@ null }, }, { - name: "PtrAnonymousHeadInt32OnlyString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "PtrAnonymousHeadInt32OnlyString", data: struct { *structInt32String }{ @@ -2706,11 +1636,7 @@ null // NilPtrAnonymousHeadInt32Only { - name: "NilPtrAnonymousHeadInt32Only", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadInt32Only", data: struct { *structInt32 }{ @@ -2718,11 +1644,7 @@ null }, }, { - name: "NilPtrAnonymousHeadInt32OnlyOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadInt32OnlyOmitEmpty", data: struct { *structInt32OmitEmpty }{ @@ -2730,11 +1652,7 @@ null }, }, { - name: "NilPtrAnonymousHeadInt32OnlyString", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadInt32OnlyString", data: struct { *structInt32String }{ @@ -2744,13 +1662,7 @@ null // AnonymousHeadInt32PtrOnly { - name: "AnonymousHeadInt32PtrOnly", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "AnonymousHeadInt32PtrOnly", data: struct { structInt32Ptr }{ @@ -2758,13 +1670,7 @@ null }, }, { - name: "AnonymousHeadInt32PtrOnlyOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "AnonymousHeadInt32PtrOnlyOmitEmpty", data: struct { structInt32PtrOmitEmpty }{ @@ -2772,13 +1678,7 @@ null }, }, { - name: "AnonymousHeadInt32PtrOnlyString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "AnonymousHeadInt32PtrOnlyString", data: struct { structInt32PtrString }{ @@ -2788,13 +1688,7 @@ null // AnonymousHeadInt32PtrNilOnly { - name: "AnonymousHeadInt32PtrNilOnly", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "AnonymousHeadInt32PtrNilOnly", data: struct { structInt32Ptr }{ @@ -2802,11 +1696,7 @@ null }, }, { - name: "AnonymousHeadInt32PtrNilOnlyOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "AnonymousHeadInt32PtrNilOnlyOmitEmpty", data: struct { structInt32PtrOmitEmpty }{ @@ -2814,13 +1704,7 @@ null }, }, { - name: "AnonymousHeadInt32PtrNilOnlyString", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "AnonymousHeadInt32PtrNilOnlyString", data: struct { structInt32PtrString }{ @@ -2830,13 +1714,7 @@ null // PtrAnonymousHeadInt32PtrOnly { - name: "PtrAnonymousHeadInt32PtrOnly", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrAnonymousHeadInt32PtrOnly", data: struct { *structInt32Ptr }{ @@ -2844,13 +1722,7 @@ null }, }, { - name: "PtrAnonymousHeadInt32PtrOnlyOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrAnonymousHeadInt32PtrOnlyOmitEmpty", data: struct { *structInt32PtrOmitEmpty }{ @@ -2858,13 +1730,7 @@ null }, }, { - name: "PtrAnonymousHeadInt32PtrOnlyString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "PtrAnonymousHeadInt32PtrOnlyString", data: struct { *structInt32PtrString }{ @@ -2874,11 +1740,7 @@ null // NilPtrAnonymousHeadInt32PtrOnly { - name: "NilPtrAnonymousHeadInt32PtrOnly", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadInt32PtrOnly", data: struct { *structInt32Ptr }{ @@ -2886,11 +1748,7 @@ null }, }, { - name: "NilPtrAnonymousHeadInt32PtrOnlyOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadInt32PtrOnlyOmitEmpty", data: struct { *structInt32PtrOmitEmpty }{ @@ -2898,11 +1756,7 @@ null }, }, { - name: "NilPtrAnonymousHeadInt32PtrOnlyString", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadInt32PtrOnlyString", data: struct { *structInt32PtrString }{ @@ -2920,22 +1774,12 @@ null enc.SetIndent("", " ") } if err := enc.Encode(test.data); err != nil { - t.Fatalf("%s(htmlEscape:%T): %s: %s", test.name, htmlEscape, test.expected, err) + t.Fatalf("%s(htmlEscape:%T): %+v: %s", test.name, htmlEscape, test.data, err) } stdresult := encodeByEncodingJSON(test.data, indent, htmlEscape) if buf.String() != stdresult { t.Errorf("%s(htmlEscape:%T): doesn't compatible with encoding/json. expected %q but got %q", test.name, htmlEscape, stdresult, buf.String()) } - if indent { - got := "\n" + buf.String() - if got != test.indentExpected { - t.Fatalf("%s(htmlEscape:%T): expected %q but got %q", test.name, htmlEscape, test.indentExpected, got) - } - } else { - if strings.TrimRight(buf.String(), "\n") != test.expected { - t.Fatalf("%s(htmlEscape:%T): expected %q but got %q", test.name, htmlEscape, test.expected, buf.String()) - } - } } } }