From 7f406b738760e21275841d2a313714adc6064c6a Mon Sep 17 00:00:00 2001 From: Masaaki Goshima Date: Mon, 15 Feb 2021 02:08:05 +0900 Subject: [PATCH 01/15] Refactor cover_int_test.go --- cover_int_test.go | 1540 ++++++--------------------------------------- 1 file changed, 192 insertions(+), 1348 deletions(-) diff --git a/cover_int_test.go b/cover_int_test.go index 1456271..72af9d6 100644 --- a/cover_int_test.go +++ b/cover_int_test.go @@ -2,7 +2,6 @@ package json_test import ( "bytes" - "strings" "testing" "github.com/goccy/go-json" @@ -30,42 +29,24 @@ func TestCoverInt(t *testing.T) { } tests := []struct { - name string - expected string - indentExpected string - data interface{} + name string + data interface{} }{ // HeadIntZero { - name: "HeadIntZero", - expected: `{"a":0}`, - indentExpected: ` -{ - "a": 0 -} -`, + name: "HeadIntZero", data: struct { A int `json:"a"` }{}, }, { - name: "HeadIntZeroOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "HeadIntZeroOmitEmpty", data: struct { A int `json:"a,omitempty"` }{}, }, { - name: "HeadIntZeroString", - expected: `{"a":"0"}`, - indentExpected: ` -{ - "a": "0" -} -`, + name: "HeadIntZeroString", data: struct { A int `json:"a,string"` }{}, @@ -73,37 +54,19 @@ func TestCoverInt(t *testing.T) { // HeadInt { - name: "HeadInt", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "HeadInt", data: struct { A int `json:"a"` }{A: 1}, }, { - name: "HeadIntOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "HeadIntOmitEmpty", data: struct { A int `json:"a,omitempty"` }{A: 1}, }, { - name: "HeadIntString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "HeadIntString", data: struct { A int `json:"a,string"` }{A: 1}, @@ -111,37 +74,19 @@ func TestCoverInt(t *testing.T) { // HeadIntPtr { - name: "HeadIntPtr", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "HeadIntPtr", data: struct { A *int `json:"a"` }{A: intptr(1)}, }, { - name: "HeadIntPtrOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "HeadIntPtrOmitEmpty", data: struct { A *int `json:"a,omitempty"` }{A: intptr(1)}, }, { - name: "HeadIntPtrString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "HeadIntPtrString", data: struct { A *int `json:"a,string"` }{A: intptr(1)}, @@ -149,35 +94,19 @@ func TestCoverInt(t *testing.T) { // HeadIntPtrNil { - name: "HeadIntPtrNil", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "HeadIntPtrNil", data: struct { A *int `json:"a"` }{A: nil}, }, { - name: "HeadIntPtrNilOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "HeadIntPtrNilOmitEmpty", data: struct { A *int `json:"a,omitempty"` }{A: nil}, }, { - name: "HeadIntPtrNilString", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "HeadIntPtrNilString", data: struct { A *int `json:"a,string"` }{A: nil}, @@ -185,35 +114,19 @@ func TestCoverInt(t *testing.T) { // PtrHeadIntZero { - name: "PtrHeadIntZero", - expected: `{"a":0}`, - indentExpected: ` -{ - "a": 0 -} -`, + name: "PtrHeadIntZero", data: &struct { A int `json:"a"` }{}, }, { - name: "PtrHeadIntZeroOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadIntZeroOmitEmpty", data: &struct { A int `json:"a,omitempty"` }{}, }, { - name: "PtrHeadIntZeroString", - expected: `{"a":"0"}`, - indentExpected: ` -{ - "a": "0" -} -`, + name: "PtrHeadIntZeroString", data: &struct { A int `json:"a,string"` }{}, @@ -221,37 +134,19 @@ func TestCoverInt(t *testing.T) { // PtrHeadInt { - name: "PtrHeadInt", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrHeadInt", data: &struct { A int `json:"a"` }{A: 1}, }, { - name: "PtrHeadIntOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrHeadIntOmitEmpty", data: &struct { A int `json:"a,omitempty"` }{A: 1}, }, { - name: "PtrHeadIntString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "PtrHeadIntString", data: &struct { A int `json:"a,string"` }{A: 1}, @@ -259,37 +154,19 @@ func TestCoverInt(t *testing.T) { // PtrHeadIntPtr { - name: "PtrHeadIntPtr", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrHeadIntPtr", data: &struct { A *int `json:"a"` }{A: intptr(1)}, }, { - name: "PtrHeadIntPtrOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrHeadIntPtrOmitEmpty", data: &struct { A *int `json:"a,omitempty"` }{A: intptr(1)}, }, { - name: "PtrHeadIntPtrString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "PtrHeadIntPtrString", data: &struct { A *int `json:"a,string"` }{A: intptr(1)}, @@ -297,35 +174,19 @@ func TestCoverInt(t *testing.T) { // PtrHeadIntPtrNil { - name: "PtrHeadIntPtrNil", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "PtrHeadIntPtrNil", data: &struct { A *int `json:"a"` }{A: nil}, }, { - name: "PtrHeadIntPtrNilOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadIntPtrNilOmitEmpty", data: &struct { A *int `json:"a,omitempty"` }{A: nil}, }, { - name: "PtrHeadIntPtrNilString", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "PtrHeadIntPtrNilString", data: &struct { A *int `json:"a,string"` }{A: nil}, @@ -333,31 +194,19 @@ func TestCoverInt(t *testing.T) { // PtrHeadIntNil { - name: "PtrHeadIntNil", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadIntNil", data: (*struct { A *int `json:"a"` })(nil), }, { - name: "PtrHeadIntNilOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadIntNilOmitEmpty", data: (*struct { A *int `json:"a,omitempty"` })(nil), }, { - name: "PtrHeadIntNilString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadIntNilString", data: (*struct { A *int `json:"a,string"` })(nil), @@ -365,209 +214,125 @@ null // HeadIntZeroMultiFields { - name: "HeadIntZeroMultiFields", - expected: `{"a":0,"b":0}`, - indentExpected: ` -{ - "a": 0, - "b": 0 -} -`, + name: "HeadIntZeroMultiFields", data: struct { A int `json:"a"` B int `json:"b"` + C int `json:"c"` }{}, }, { - name: "HeadIntZeroMultiFieldsOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "HeadIntZeroMultiFieldsOmitEmpty", data: struct { A int `json:"a,omitempty"` B int `json:"b,omitempty"` + C int `json:"c,omitempty"` }{}, }, { - name: "HeadIntZeroMultiFields", - expected: `{"a":"0","b":"0"}`, - indentExpected: ` -{ - "a": "0", - "b": "0" -} -`, + name: "HeadIntZeroMultiFields", data: struct { A int `json:"a,string"` B int `json:"b,string"` + C int `json:"c,string"` }{}, }, // HeadIntMultiFields { - name: "HeadIntMultiFields", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "HeadIntMultiFields", data: struct { A int `json:"a"` B int `json:"b"` - }{A: 1, B: 2}, + C int `json:"c"` + }{A: 1, B: 2, C: 3}, }, { - name: "HeadIntMultiFieldsOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "HeadIntMultiFieldsOmitEmpty", data: struct { A int `json:"a,omitempty"` B int `json:"b,omitempty"` - }{A: 1, B: 2}, + C int `json:"c,omitempty"` + }{A: 1, B: 2, C: 3}, }, { - name: "HeadIntMultiFieldsString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "HeadIntMultiFieldsString", data: struct { A int `json:"a,string"` B int `json:"b,string"` - }{A: 1, B: 2}, + C int `json:"c,string"` + }{A: 1, B: 2, C: 3}, }, // HeadIntPtrMultiFields { - name: "HeadIntPtrMultiFields", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "HeadIntPtrMultiFields", data: struct { A *int `json:"a"` B *int `json:"b"` - }{A: intptr(1), B: intptr(2)}, + C *int `json:"c"` + }{A: intptr(1), B: intptr(2), C: intptr(3)}, }, { - name: "HeadIntPtrMultiFieldsOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "HeadIntPtrMultiFieldsOmitEmpty", data: struct { A *int `json:"a,omitempty"` B *int `json:"b,omitempty"` - }{A: intptr(1), B: intptr(2)}, + C *int `json:"c,omitempty"` + }{A: intptr(1), B: intptr(2), C: intptr(3)}, }, { - name: "HeadIntPtrMultiFieldsString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "HeadIntPtrMultiFieldsString", data: struct { A *int `json:"a,string"` B *int `json:"b,string"` - }{A: intptr(1), B: intptr(2)}, + C *int `json:"c,string"` + }{A: intptr(1), B: intptr(2), C: intptr(3)}, }, // HeadIntPtrNilMultiFields { - name: "HeadIntPtrNilMultiFields", - expected: `{"a":null,"b":null}`, - indentExpected: ` -{ - "a": null, - "b": null -} -`, + name: "HeadIntPtrNilMultiFields", data: struct { A *int `json:"a"` B *int `json:"b"` - }{A: nil, B: nil}, + C *int `json:"c"` + }{A: nil, B: nil, C: nil}, }, { - name: "HeadIntPtrNilMultiFieldsOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "HeadIntPtrNilMultiFieldsOmitEmpty", data: struct { A *int `json:"a,omitempty"` B *int `json:"b,omitempty"` - }{A: nil, B: nil}, + C *int `json:"c,omitempty"` + }{A: nil, B: nil, C: nil}, }, { - name: "HeadIntPtrNilMultiFieldsString", - expected: `{"a":null,"b":null}`, - indentExpected: ` -{ - "a": null, - "b": null -} -`, + name: "HeadIntPtrNilMultiFieldsString", data: struct { A *int `json:"a,string"` B *int `json:"b,string"` - }{A: nil, B: nil}, + C *int `json:"c,string"` + }{A: nil, B: nil, C: nil}, }, // PtrHeadIntZeroMultiFields { - name: "PtrHeadIntZeroMultiFields", - expected: `{"a":0,"b":0}`, - indentExpected: ` -{ - "a": 0, - "b": 0 -} -`, + name: "PtrHeadIntZeroMultiFields", data: &struct { A int `json:"a"` B int `json:"b"` }{}, }, { - name: "PtrHeadIntZeroMultiFieldsOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadIntZeroMultiFieldsOmitEmpty", data: &struct { A int `json:"a,omitempty"` B int `json:"b,omitempty"` }{}, }, { - name: "PtrHeadIntZeroMultiFieldsString", - expected: `{"a":"0","b":"0"}`, - indentExpected: ` -{ - "a": "0", - "b": "0" -} -`, + name: "PtrHeadIntZeroMultiFieldsString", data: &struct { A int `json:"a,string"` B int `json:"b,string"` @@ -576,42 +341,21 @@ null // PtrHeadIntMultiFields { - name: "PtrHeadIntMultiFields", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrHeadIntMultiFields", data: &struct { A int `json:"a"` B int `json:"b"` }{A: 1, B: 2}, }, { - name: "PtrHeadIntMultiFieldsOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrHeadIntMultiFieldsOmitEmpty", data: &struct { A int `json:"a,omitempty"` B int `json:"b,omitempty"` }{A: 1, B: 2}, }, { - name: "PtrHeadIntMultiFieldsString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "PtrHeadIntMultiFieldsString", data: &struct { A int `json:"a,string"` B int `json:"b,string"` @@ -620,42 +364,21 @@ null // PtrHeadIntPtrMultiFields { - name: "PtrHeadIntPtrMultiFields", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrHeadIntPtrMultiFields", data: &struct { A *int `json:"a"` B *int `json:"b"` }{A: intptr(1), B: intptr(2)}, }, { - name: "PtrHeadIntPtrMultiFieldsOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrHeadIntPtrMultiFieldsOmitEmpty", data: &struct { A *int `json:"a,omitempty"` B *int `json:"b,omitempty"` }{A: intptr(1), B: intptr(2)}, }, { - name: "PtrHeadIntPtrMultiFieldsString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "PtrHeadIntPtrMultiFieldsString", data: &struct { A *int `json:"a,string"` B *int `json:"b,string"` @@ -664,39 +387,21 @@ null // PtrHeadIntPtrNilMultiFields { - name: "PtrHeadIntPtrNilMultiFields", - expected: `{"a":null,"b":null}`, - indentExpected: ` -{ - "a": null, - "b": null -} -`, + name: "PtrHeadIntPtrNilMultiFields", data: &struct { A *int `json:"a"` B *int `json:"b"` }{A: nil, B: nil}, }, { - name: "PtrHeadIntPtrNilMultiFieldsOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadIntPtrNilMultiFieldsOmitEmpty", data: &struct { A *int `json:"a,omitempty"` B *int `json:"b,omitempty"` }{A: nil, B: nil}, }, { - name: "PtrHeadIntPtrNilMultiFieldsString", - expected: `{"a":null,"b":null}`, - indentExpected: ` -{ - "a": null, - "b": null -} -`, + name: "PtrHeadIntPtrNilMultiFieldsString", data: &struct { A *int `json:"a,string"` B *int `json:"b,string"` @@ -705,33 +410,21 @@ null // PtrHeadIntNilMultiFields { - name: "PtrHeadIntNilMultiFields", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadIntNilMultiFields", data: (*struct { A *int `json:"a"` B *int `json:"b"` })(nil), }, { - name: "PtrHeadIntNilMultiFieldsOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadIntNilMultiFieldsOmitEmpty", data: (*struct { A *int `json:"a,omitempty"` B *int `json:"b,omitempty"` })(nil), }, { - name: "PtrHeadIntNilMultiFieldsString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadIntNilMultiFieldsString", data: (*struct { A *int `json:"a,string"` B *int `json:"b,string"` @@ -740,15 +433,7 @@ null // HeadIntZeroNotRoot { - name: "HeadIntZeroNotRoot", - expected: `{"A":{"a":0}}`, - indentExpected: ` -{ - "A": { - "a": 0 - } -} -`, + name: "HeadIntZeroNotRoot", data: struct { A struct { A int `json:"a"` @@ -756,13 +441,7 @@ null }{}, }, { - name: "HeadIntZeroNotRootOmitEmpty", - expected: `{"A":{}}`, - indentExpected: ` -{ - "A": {} -} -`, + name: "HeadIntZeroNotRootOmitEmpty", data: struct { A struct { A int `json:"a,omitempty"` @@ -770,15 +449,7 @@ null }{}, }, { - name: "HeadIntZeroNotRootString", - expected: `{"A":{"a":"0"}}`, - indentExpected: ` -{ - "A": { - "a": "0" - } -} -`, + name: "HeadIntZeroNotRootString", data: struct { A struct { A int `json:"a,string"` @@ -788,15 +459,7 @@ null // HeadIntNotRoot { - name: "HeadIntNotRoot", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "HeadIntNotRoot", data: struct { A struct { A int `json:"a"` @@ -806,15 +469,7 @@ null }{A: 1}}, }, { - name: "HeadIntNotRootOmitEmpty", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "HeadIntNotRootOmitEmpty", data: struct { A struct { A int `json:"a,omitempty"` @@ -824,15 +479,7 @@ null }{A: 1}}, }, { - name: "HeadIntNotRootString", - expected: `{"A":{"a":"1"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - } -} -`, + name: "HeadIntNotRootString", data: struct { A struct { A int `json:"a,string"` @@ -844,15 +491,7 @@ null // HeadIntPtrNotRoot { - name: "HeadIntPtrNotRoot", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "HeadIntPtrNotRoot", data: struct { A struct { A *int `json:"a"` @@ -862,15 +501,7 @@ null }{intptr(1)}}, }, { - name: "HeadIntPtrNotRootOmitEmpty", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "HeadIntPtrNotRootOmitEmpty", data: struct { A struct { A *int `json:"a,omitempty"` @@ -880,15 +511,7 @@ null }{intptr(1)}}, }, { - name: "HeadIntPtrNotRootString", - expected: `{"A":{"a":"1"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - } -} -`, + name: "HeadIntPtrNotRootString", data: struct { A struct { A *int `json:"a,string"` @@ -900,15 +523,7 @@ null // HeadIntPtrNilNotRoot { - name: "HeadIntPtrNilNotRoot", - expected: `{"A":{"a":null}}`, - indentExpected: ` -{ - "A": { - "a": null - } -} -`, + name: "HeadIntPtrNilNotRoot", data: struct { A struct { A *int `json:"a"` @@ -916,13 +531,7 @@ null }{}, }, { - name: "HeadIntPtrNilNotRootOmitEmpty", - expected: `{"A":{}}`, - indentExpected: ` -{ - "A": {} -} -`, + name: "HeadIntPtrNilNotRootOmitEmpty", data: struct { A struct { A *int `json:"a,omitempty"` @@ -930,15 +539,7 @@ null }{}, }, { - name: "HeadIntPtrNilNotRootString", - expected: `{"A":{"a":null}}`, - indentExpected: ` -{ - "A": { - "a": null - } -} -`, + name: "HeadIntPtrNilNotRootString", data: struct { A struct { A *int `json:"a,string"` @@ -948,15 +549,7 @@ null // PtrHeadIntZeroNotRoot { - name: "PtrHeadIntZeroNotRoot", - expected: `{"A":{"a":0}}`, - indentExpected: ` -{ - "A": { - "a": 0 - } -} -`, + name: "PtrHeadIntZeroNotRoot", data: struct { A *struct { A int `json:"a"` @@ -966,13 +559,7 @@ null })}, }, { - name: "PtrHeadIntZeroNotRootOmitEmpty", - expected: `{"A":{}}`, - indentExpected: ` -{ - "A": {} -} -`, + name: "PtrHeadIntZeroNotRootOmitEmpty", data: struct { A *struct { A int `json:"a,omitempty"` @@ -982,15 +569,7 @@ null })}, }, { - name: "PtrHeadIntZeroNotRootString", - expected: `{"A":{"a":"0"}}`, - indentExpected: ` -{ - "A": { - "a": "0" - } -} -`, + name: "PtrHeadIntZeroNotRootString", data: struct { A *struct { A int `json:"a,string"` @@ -1002,15 +581,7 @@ null // PtrHeadIntNotRoot { - name: "PtrHeadIntNotRoot", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "PtrHeadIntNotRoot", data: struct { A *struct { A int `json:"a"` @@ -1020,15 +591,7 @@ null }{A: 1})}, }, { - name: "PtrHeadIntNotRootOmitEmpty", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "PtrHeadIntNotRootOmitEmpty", data: struct { A *struct { A int `json:"a,omitempty"` @@ -1038,15 +601,7 @@ null }{A: 1})}, }, { - name: "PtrHeadIntNotRootString", - expected: `{"A":{"a":"1"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - } -} -`, + name: "PtrHeadIntNotRootString", data: struct { A *struct { A int `json:"a,string"` @@ -1058,15 +613,7 @@ null // PtrHeadIntPtrNotRoot { - name: "PtrHeadIntPtrNotRoot", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "PtrHeadIntPtrNotRoot", data: struct { A *struct { A *int `json:"a"` @@ -1076,15 +623,7 @@ null }{A: intptr(1)})}, }, { - name: "PtrHeadIntPtrNotRootOmitEmpty", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "PtrHeadIntPtrNotRootOmitEmpty", data: struct { A *struct { A *int `json:"a,omitempty"` @@ -1094,15 +633,7 @@ null }{A: intptr(1)})}, }, { - name: "PtrHeadIntPtrNotRootString", - expected: `{"A":{"a":"1"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - } -} -`, + name: "PtrHeadIntPtrNotRootString", data: struct { A *struct { A *int `json:"a,string"` @@ -1114,15 +645,7 @@ null // PtrHeadIntPtrNilNotRoot { - name: "PtrHeadIntPtrNilNotRoot", - expected: `{"A":{"a":null}}`, - indentExpected: ` -{ - "A": { - "a": null - } -} -`, + name: "PtrHeadIntPtrNilNotRoot", data: struct { A *struct { A *int `json:"a"` @@ -1132,13 +655,7 @@ null }{A: nil})}, }, { - name: "PtrHeadIntPtrNilNotRootOmitEmpty", - expected: `{"A":{}}`, - indentExpected: ` -{ - "A": {} -} -`, + name: "PtrHeadIntPtrNilNotRootOmitEmpty", data: struct { A *struct { A *int `json:"a,omitempty"` @@ -1148,15 +665,7 @@ null }{A: nil})}, }, { - name: "PtrHeadIntPtrNilNotRootString", - expected: `{"A":{"a":null}}`, - indentExpected: ` -{ - "A": { - "a": null - } -} -`, + name: "PtrHeadIntPtrNilNotRootString", data: struct { A *struct { A *int `json:"a,string"` @@ -1168,13 +677,7 @@ null // PtrHeadIntNilNotRoot { - name: "PtrHeadIntNilNotRoot", - expected: `{"A":null}`, - indentExpected: ` -{ - "A": null -} -`, + name: "PtrHeadIntNilNotRoot", data: struct { A *struct { A *int `json:"a"` @@ -1182,11 +685,7 @@ null }{A: nil}, }, { - name: "PtrHeadIntNilNotRootOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadIntNilNotRootOmitEmpty", data: struct { A *struct { A *int `json:"a,omitempty"` @@ -1194,13 +693,7 @@ null }{A: nil}, }, { - name: "PtrHeadIntNilNotRootString", - expected: `{"A":null}`, - indentExpected: ` -{ - "A": null -} -`, + name: "PtrHeadIntNilNotRootString", data: struct { A *struct { A *int `json:"a,string"` @@ -1210,18 +703,7 @@ null // HeadIntZeroMultiFieldsNotRoot { - name: "HeadIntZeroMultiFieldsNotRoot", - expected: `{"A":{"a":0},"B":{"b":0}}`, - indentExpected: ` -{ - "A": { - "a": 0 - }, - "B": { - "b": 0 - } -} -`, + name: "HeadIntZeroMultiFieldsNotRoot", data: struct { A struct { A int `json:"a"` @@ -1232,14 +714,7 @@ null }{}, }, { - name: "HeadIntZeroMultiFieldsNotRootOmitEmpty", - expected: `{"A":{},"B":{}}`, - indentExpected: ` -{ - "A": {}, - "B": {} -} -`, + name: "HeadIntZeroMultiFieldsNotRootOmitEmpty", data: struct { A struct { A int `json:"a,omitempty"` @@ -1250,18 +725,7 @@ null }{}, }, { - name: "HeadIntZeroMultiFieldsNotRootString", - expected: `{"A":{"a":"0"},"B":{"b":"0"}}`, - indentExpected: ` -{ - "A": { - "a": "0" - }, - "B": { - "b": "0" - } -} -`, + name: "HeadIntZeroMultiFieldsNotRootString", data: struct { A struct { A int `json:"a,string"` @@ -1274,18 +738,7 @@ null // HeadIntMultiFieldsNotRoot { - name: "HeadIntMultiFieldsNotRoot", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "HeadIntMultiFieldsNotRoot", data: struct { A struct { A int `json:"a"` @@ -1300,18 +753,7 @@ null }{B: 2}}, }, { - name: "HeadIntMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "HeadIntMultiFieldsNotRootOmitEmpty", data: struct { A struct { A int `json:"a,omitempty"` @@ -1326,18 +768,7 @@ null }{B: 2}}, }, { - name: "HeadIntMultiFieldsNotRootString", - expected: `{"A":{"a":"1"},"B":{"b":"2"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - }, - "B": { - "b": "2" - } -} -`, + name: "HeadIntMultiFieldsNotRootString", data: struct { A struct { A int `json:"a,string"` @@ -1354,18 +785,7 @@ null // HeadIntPtrMultiFieldsNotRoot { - name: "HeadIntPtrMultiFieldsNotRoot", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "HeadIntPtrMultiFieldsNotRoot", data: struct { A struct { A *int `json:"a"` @@ -1380,18 +800,7 @@ null }{B: intptr(2)}}, }, { - name: "HeadIntPtrMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "HeadIntPtrMultiFieldsNotRootOmitEmpty", data: struct { A struct { A *int `json:"a,omitempty"` @@ -1406,18 +815,7 @@ null }{B: intptr(2)}}, }, { - name: "HeadIntPtrMultiFieldsNotRootString", - expected: `{"A":{"a":"1"},"B":{"b":"2"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - }, - "B": { - "b": "2" - } -} -`, + name: "HeadIntPtrMultiFieldsNotRootString", data: struct { A struct { A *int `json:"a,string"` @@ -1434,18 +832,7 @@ null // HeadIntPtrNilMultiFieldsNotRoot { - name: "HeadIntPtrNilMultiFieldsNotRoot", - expected: `{"A":{"a":null},"B":{"b":null}}`, - indentExpected: ` -{ - "A": { - "a": null - }, - "B": { - "b": null - } -} -`, + name: "HeadIntPtrNilMultiFieldsNotRoot", data: struct { A struct { A *int `json:"a"` @@ -1460,14 +847,7 @@ null }{B: nil}}, }, { - name: "HeadIntPtrNilMultiFieldsNotRootOmitEmpty", - expected: `{"A":{},"B":{}}`, - indentExpected: ` -{ - "A": {}, - "B": {} -} -`, + name: "HeadIntPtrNilMultiFieldsNotRootOmitEmpty", data: struct { A struct { A *int `json:"a,omitempty"` @@ -1482,18 +862,7 @@ null }{B: nil}}, }, { - name: "HeadIntPtrNilMultiFieldsNotRootString", - expected: `{"A":{"a":null},"B":{"b":null}}`, - indentExpected: ` -{ - "A": { - "a": null - }, - "B": { - "b": null - } -} -`, + name: "HeadIntPtrNilMultiFieldsNotRootString", data: struct { A struct { A *int `json:"a,string"` @@ -1510,18 +879,7 @@ null // PtrHeadIntZeroMultiFieldsNotRoot { - name: "PtrHeadIntZeroMultiFieldsNotRoot", - expected: `{"A":{"a":0},"B":{"b":0}}`, - indentExpected: ` -{ - "A": { - "a": 0 - }, - "B": { - "b": 0 - } -} -`, + name: "PtrHeadIntZeroMultiFieldsNotRoot", data: &struct { A struct { A int `json:"a"` @@ -1532,14 +890,7 @@ null }{}, }, { - name: "PtrHeadIntZeroMultiFieldsNotRootOmitEmpty", - expected: `{"A":{},"B":{}}`, - indentExpected: ` -{ - "A": {}, - "B": {} -} -`, + name: "PtrHeadIntZeroMultiFieldsNotRootOmitEmpty", data: &struct { A struct { A int `json:"a,omitempty"` @@ -1550,18 +901,7 @@ null }{}, }, { - name: "PtrHeadIntZeroMultiFieldsNotRootString", - expected: `{"A":{"a":"0"},"B":{"b":"0"}}`, - indentExpected: ` -{ - "A": { - "a": "0" - }, - "B": { - "b": "0" - } -} -`, + name: "PtrHeadIntZeroMultiFieldsNotRootString", data: &struct { A struct { A int `json:"a,string"` @@ -1574,18 +914,7 @@ null // PtrHeadIntMultiFieldsNotRoot { - name: "PtrHeadIntMultiFieldsNotRoot", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "PtrHeadIntMultiFieldsNotRoot", data: &struct { A struct { A int `json:"a"` @@ -1600,18 +929,7 @@ null }{B: 2}}, }, { - name: "PtrHeadIntMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "PtrHeadIntMultiFieldsNotRootOmitEmpty", data: &struct { A struct { A int `json:"a,omitempty"` @@ -1626,18 +944,7 @@ null }{B: 2}}, }, { - name: "PtrHeadIntMultiFieldsNotRootString", - expected: `{"A":{"a":"1"},"B":{"b":"2"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - }, - "B": { - "b": "2" - } -} -`, + name: "PtrHeadIntMultiFieldsNotRootString", data: &struct { A struct { A int `json:"a,string"` @@ -1654,18 +961,7 @@ null // PtrHeadIntPtrMultiFieldsNotRoot { - name: "PtrHeadIntPtrMultiFieldsNotRoot", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "PtrHeadIntPtrMultiFieldsNotRoot", data: &struct { A *struct { A *int `json:"a"` @@ -1680,18 +976,7 @@ null }{B: intptr(2)})}, }, { - name: "PtrHeadIntPtrMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "PtrHeadIntPtrMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A *int `json:"a,omitempty"` @@ -1706,18 +991,7 @@ null }{B: intptr(2)})}, }, { - name: "PtrHeadIntPtrMultiFieldsNotRootString", - expected: `{"A":{"a":"1"},"B":{"b":"2"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - }, - "B": { - "b": "2" - } -} -`, + name: "PtrHeadIntPtrMultiFieldsNotRootString", data: &struct { A *struct { A *int `json:"a,string"` @@ -1734,14 +1008,7 @@ null // PtrHeadIntPtrNilMultiFieldsNotRoot { - name: "PtrHeadIntPtrNilMultiFieldsNotRoot", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadIntPtrNilMultiFieldsNotRoot", data: &struct { A *struct { A *int `json:"a"` @@ -1752,11 +1019,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadIntPtrNilMultiFieldsNotRootOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadIntPtrNilMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A *int `json:"a,omitempty"` @@ -1767,14 +1030,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadIntPtrNilMultiFieldsNotRootString", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadIntPtrNilMultiFieldsNotRootString", data: &struct { A *struct { A *int `json:"a,string"` @@ -1787,11 +1043,7 @@ null // PtrHeadIntNilMultiFieldsNotRoot { - name: "PtrHeadIntNilMultiFieldsNotRoot", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadIntNilMultiFieldsNotRoot", data: (*struct { A *struct { A *int `json:"a"` @@ -1802,11 +1054,7 @@ null })(nil), }, { - name: "PtrHeadIntNilMultiFieldsNotRootOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadIntNilMultiFieldsNotRootOmitEmpty", data: (*struct { A *struct { A *int `json:"a,omitempty"` @@ -1817,11 +1065,7 @@ null })(nil), }, { - name: "PtrHeadIntNilMultiFieldsNotRootString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadIntNilMultiFieldsNotRootString", data: (*struct { A *struct { A *int `json:"a,string"` @@ -1834,20 +1078,7 @@ null // PtrHeadIntDoubleMultiFieldsNotRoot { - name: "PtrHeadIntDoubleMultiFieldsNotRoot", - expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`, - indentExpected: ` -{ - "A": { - "a": 1, - "b": 2 - }, - "B": { - "a": 3, - "b": 4 - } -} -`, + name: "PtrHeadIntDoubleMultiFieldsNotRoot", data: &struct { A *struct { A int `json:"a"` @@ -1866,20 +1097,7 @@ null }{A: 3, B: 4})}, }, { - name: "PtrHeadIntDoubleMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`, - indentExpected: ` -{ - "A": { - "a": 1, - "b": 2 - }, - "B": { - "a": 3, - "b": 4 - } -} -`, + name: "PtrHeadIntDoubleMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A int `json:"a,omitempty"` @@ -1898,20 +1116,7 @@ null }{A: 3, B: 4})}, }, { - name: "PtrHeadIntDoubleMultiFieldsNotRootString", - expected: `{"A":{"a":"1","b":"2"},"B":{"a":"3","b":"4"}}`, - indentExpected: ` -{ - "A": { - "a": "1", - "b": "2" - }, - "B": { - "a": "3", - "b": "4" - } -} -`, + name: "PtrHeadIntDoubleMultiFieldsNotRootString", data: &struct { A *struct { A int `json:"a,string"` @@ -1932,14 +1137,7 @@ null // PtrHeadIntNilDoubleMultiFieldsNotRoot { - name: "PtrHeadIntNilDoubleMultiFieldsNotRoot", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadIntNilDoubleMultiFieldsNotRoot", data: &struct { A *struct { A int `json:"a"` @@ -1952,11 +1150,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadIntNilDoubleMultiFieldsNotRootOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadIntNilDoubleMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A int `json:"a,omitempty"` @@ -1969,14 +1163,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadIntNilDoubleMultiFieldsNotRootString", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadIntNilDoubleMultiFieldsNotRootString", data: &struct { A *struct { A int `json:"a,string"` @@ -1991,11 +1178,7 @@ null // PtrHeadIntNilDoubleMultiFieldsNotRoot { - name: "PtrHeadIntNilDoubleMultiFieldsNotRoot", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadIntNilDoubleMultiFieldsNotRoot", data: (*struct { A *struct { A int `json:"a"` @@ -2008,11 +1191,7 @@ null })(nil), }, { - name: "PtrHeadIntNilDoubleMultiFieldsNotRootOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadIntNilDoubleMultiFieldsNotRootOmitEmpty", data: (*struct { A *struct { A int `json:"a,omitempty"` @@ -2025,11 +1204,7 @@ null })(nil), }, { - name: "PtrHeadIntNilDoubleMultiFieldsNotRootString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadIntNilDoubleMultiFieldsNotRootString", data: (*struct { A *struct { A int `json:"a,string"` @@ -2044,20 +1219,7 @@ null // PtrHeadIntPtrDoubleMultiFieldsNotRoot { - name: "PtrHeadIntPtrDoubleMultiFieldsNotRoot", - expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`, - indentExpected: ` -{ - "A": { - "a": 1, - "b": 2 - }, - "B": { - "a": 3, - "b": 4 - } -} -`, + name: "PtrHeadIntPtrDoubleMultiFieldsNotRoot", data: &struct { A *struct { A *int `json:"a"` @@ -2076,20 +1238,7 @@ null }{A: intptr(3), B: intptr(4)})}, }, { - name: "PtrHeadIntPtrDoubleMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`, - indentExpected: ` -{ - "A": { - "a": 1, - "b": 2 - }, - "B": { - "a": 3, - "b": 4 - } -} -`, + name: "PtrHeadIntPtrDoubleMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A *int `json:"a,omitempty"` @@ -2108,20 +1257,7 @@ null }{A: intptr(3), B: intptr(4)})}, }, { - name: "PtrHeadIntPtrDoubleMultiFieldsNotRootString", - expected: `{"A":{"a":"1","b":"2"},"B":{"a":"3","b":"4"}}`, - indentExpected: ` -{ - "A": { - "a": "1", - "b": "2" - }, - "B": { - "a": "3", - "b": "4" - } -} -`, + name: "PtrHeadIntPtrDoubleMultiFieldsNotRootString", data: &struct { A *struct { A *int `json:"a,string"` @@ -2142,14 +1278,7 @@ null // PtrHeadIntPtrNilDoubleMultiFieldsNotRoot { - name: "PtrHeadIntPtrNilDoubleMultiFieldsNotRoot", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadIntPtrNilDoubleMultiFieldsNotRoot", data: &struct { A *struct { A *int `json:"a"` @@ -2162,11 +1291,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadIntPtrNilDoubleMultiFieldsNotRootOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadIntPtrNilDoubleMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A *int `json:"a,omitempty"` @@ -2179,14 +1304,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadIntPtrNilDoubleMultiFieldsNotRootString", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadIntPtrNilDoubleMultiFieldsNotRootString", data: &struct { A *struct { A *int `json:"a,string"` @@ -2201,11 +1319,7 @@ null // PtrHeadIntPtrNilDoubleMultiFieldsNotRoot { - name: "PtrHeadIntPtrNilDoubleMultiFieldsNotRoot", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadIntPtrNilDoubleMultiFieldsNotRoot", data: (*struct { A *struct { A *int `json:"a"` @@ -2218,11 +1332,7 @@ null })(nil), }, { - name: "PtrHeadIntPtrNilDoubleMultiFieldsNotRootOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadIntPtrNilDoubleMultiFieldsNotRootOmitEmpty", data: (*struct { A *struct { A *int `json:"a,omitempty"` @@ -2235,11 +1345,7 @@ null })(nil), }, { - name: "PtrHeadIntPtrNilDoubleMultiFieldsNotRootString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadIntPtrNilDoubleMultiFieldsNotRootString", data: (*struct { A *struct { A *int `json:"a,string"` @@ -2254,14 +1360,7 @@ null // AnonymousHeadInt { - name: "AnonymousHeadInt", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "AnonymousHeadInt", data: struct { structInt B int `json:"b"` @@ -2271,14 +1370,7 @@ null }, }, { - name: "AnonymousHeadIntOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "AnonymousHeadIntOmitEmpty", data: struct { structIntOmitEmpty B int `json:"b,omitempty"` @@ -2288,14 +1380,7 @@ null }, }, { - name: "AnonymousHeadIntString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "AnonymousHeadIntString", data: struct { structIntString B int `json:"b,string"` @@ -2307,14 +1392,7 @@ null // PtrAnonymousHeadInt { - name: "PtrAnonymousHeadInt", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrAnonymousHeadInt", data: struct { *structInt B int `json:"b"` @@ -2324,14 +1402,7 @@ null }, }, { - name: "PtrAnonymousHeadIntOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrAnonymousHeadIntOmitEmpty", data: struct { *structIntOmitEmpty B int `json:"b,omitempty"` @@ -2341,14 +1412,7 @@ null }, }, { - name: "PtrAnonymousHeadIntString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "PtrAnonymousHeadIntString", data: struct { *structIntString B int `json:"b,string"` @@ -2360,13 +1424,7 @@ null // NilPtrAnonymousHeadInt { - name: "NilPtrAnonymousHeadInt", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "NilPtrAnonymousHeadInt", data: struct { *structInt B int `json:"b"` @@ -2376,13 +1434,7 @@ null }, }, { - name: "NilPtrAnonymousHeadIntOmitEmpty", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "NilPtrAnonymousHeadIntOmitEmpty", data: struct { *structIntOmitEmpty B int `json:"b,omitempty"` @@ -2392,13 +1444,7 @@ null }, }, { - name: "NilPtrAnonymousHeadIntString", - expected: `{"b":"2"}`, - indentExpected: ` -{ - "b": "2" -} -`, + name: "NilPtrAnonymousHeadIntString", data: struct { *structIntString B int `json:"b,string"` @@ -2410,14 +1456,7 @@ null // AnonymousHeadIntPtr { - name: "AnonymousHeadIntPtr", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "AnonymousHeadIntPtr", data: struct { structIntPtr B *int `json:"b"` @@ -2427,14 +1466,7 @@ null }, }, { - name: "AnonymousHeadIntPtrOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "AnonymousHeadIntPtrOmitEmpty", data: struct { structIntPtrOmitEmpty B *int `json:"b,omitempty"` @@ -2444,14 +1476,7 @@ null }, }, { - name: "AnonymousHeadIntPtrString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "AnonymousHeadIntPtrString", data: struct { structIntPtrString B *int `json:"b,string"` @@ -2463,14 +1488,7 @@ null // AnonymousHeadIntPtrNil { - name: "AnonymousHeadIntPtrNil", - expected: `{"a":null,"b":2}`, - indentExpected: ` -{ - "a": null, - "b": 2 -} -`, + name: "AnonymousHeadIntPtrNil", data: struct { structIntPtr B *int `json:"b"` @@ -2480,13 +1498,7 @@ null }, }, { - name: "AnonymousHeadIntPtrNilOmitEmpty", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "AnonymousHeadIntPtrNilOmitEmpty", data: struct { structIntPtrOmitEmpty B *int `json:"b,omitempty"` @@ -2496,14 +1508,7 @@ null }, }, { - name: "AnonymousHeadIntPtrNilString", - expected: `{"a":null,"b":"2"}`, - indentExpected: ` -{ - "a": null, - "b": "2" -} -`, + name: "AnonymousHeadIntPtrNilString", data: struct { structIntPtrString B *int `json:"b,string"` @@ -2515,14 +1520,7 @@ null // PtrAnonymousHeadIntPtr { - name: "PtrAnonymousHeadIntPtr", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrAnonymousHeadIntPtr", data: struct { *structIntPtr B *int `json:"b"` @@ -2532,14 +1530,7 @@ null }, }, { - name: "PtrAnonymousHeadIntPtrOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrAnonymousHeadIntPtrOmitEmpty", data: struct { *structIntPtrOmitEmpty B *int `json:"b,omitempty"` @@ -2549,14 +1540,7 @@ null }, }, { - name: "PtrAnonymousHeadIntPtrString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "PtrAnonymousHeadIntPtrString", data: struct { *structIntPtrString B *int `json:"b,string"` @@ -2568,13 +1552,7 @@ null // NilPtrAnonymousHeadIntPtr { - name: "NilPtrAnonymousHeadIntPtr", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "NilPtrAnonymousHeadIntPtr", data: struct { *structIntPtr B *int `json:"b"` @@ -2584,13 +1562,7 @@ null }, }, { - name: "NilPtrAnonymousHeadIntPtrOmitEmpty", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "NilPtrAnonymousHeadIntPtrOmitEmpty", data: struct { *structIntPtrOmitEmpty B *int `json:"b,omitempty"` @@ -2600,13 +1572,7 @@ null }, }, { - name: "NilPtrAnonymousHeadIntPtrString", - expected: `{"b":"2"}`, - indentExpected: ` -{ - "b": "2" -} -`, + name: "NilPtrAnonymousHeadIntPtrString", data: struct { *structIntPtrString B *int `json:"b,string"` @@ -2618,13 +1584,7 @@ null // AnonymousHeadIntOnly { - name: "AnonymousHeadIntOnly", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "AnonymousHeadIntOnly", data: struct { structInt }{ @@ -2632,13 +1592,7 @@ null }, }, { - name: "AnonymousHeadIntOnlyOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "AnonymousHeadIntOnlyOmitEmpty", data: struct { structIntOmitEmpty }{ @@ -2646,13 +1600,7 @@ null }, }, { - name: "AnonymousHeadIntOnlyString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "AnonymousHeadIntOnlyString", data: struct { structIntString }{ @@ -2662,13 +1610,7 @@ null // PtrAnonymousHeadIntOnly { - name: "PtrAnonymousHeadIntOnly", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrAnonymousHeadIntOnly", data: struct { *structInt }{ @@ -2676,13 +1618,7 @@ null }, }, { - name: "PtrAnonymousHeadIntOnlyOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrAnonymousHeadIntOnlyOmitEmpty", data: struct { *structIntOmitEmpty }{ @@ -2690,13 +1626,7 @@ null }, }, { - name: "PtrAnonymousHeadIntOnlyString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "PtrAnonymousHeadIntOnlyString", data: struct { *structIntString }{ @@ -2706,11 +1636,7 @@ null // NilPtrAnonymousHeadIntOnly { - name: "NilPtrAnonymousHeadIntOnly", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadIntOnly", data: struct { *structInt }{ @@ -2718,11 +1644,7 @@ null }, }, { - name: "NilPtrAnonymousHeadIntOnlyOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadIntOnlyOmitEmpty", data: struct { *structIntOmitEmpty }{ @@ -2730,11 +1652,7 @@ null }, }, { - name: "NilPtrAnonymousHeadIntOnlyString", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadIntOnlyString", data: struct { *structIntString }{ @@ -2744,13 +1662,7 @@ null // AnonymousHeadIntPtrOnly { - name: "AnonymousHeadIntPtrOnly", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "AnonymousHeadIntPtrOnly", data: struct { structIntPtr }{ @@ -2758,13 +1670,7 @@ null }, }, { - name: "AnonymousHeadIntPtrOnlyOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "AnonymousHeadIntPtrOnlyOmitEmpty", data: struct { structIntPtrOmitEmpty }{ @@ -2772,13 +1678,7 @@ null }, }, { - name: "AnonymousHeadIntPtrOnlyString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "AnonymousHeadIntPtrOnlyString", data: struct { structIntPtrString }{ @@ -2788,13 +1688,7 @@ null // AnonymousHeadIntPtrNilOnly { - name: "AnonymousHeadIntPtrNilOnly", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "AnonymousHeadIntPtrNilOnly", data: struct { structIntPtr }{ @@ -2802,11 +1696,7 @@ null }, }, { - name: "AnonymousHeadIntPtrNilOnlyOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "AnonymousHeadIntPtrNilOnlyOmitEmpty", data: struct { structIntPtrOmitEmpty }{ @@ -2814,13 +1704,7 @@ null }, }, { - name: "AnonymousHeadIntPtrNilOnlyString", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "AnonymousHeadIntPtrNilOnlyString", data: struct { structIntPtrString }{ @@ -2830,13 +1714,7 @@ null // PtrAnonymousHeadIntPtrOnly { - name: "PtrAnonymousHeadIntPtrOnly", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrAnonymousHeadIntPtrOnly", data: struct { *structIntPtr }{ @@ -2844,13 +1722,7 @@ null }, }, { - name: "PtrAnonymousHeadIntPtrOnlyOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrAnonymousHeadIntPtrOnlyOmitEmpty", data: struct { *structIntPtrOmitEmpty }{ @@ -2858,13 +1730,7 @@ null }, }, { - name: "PtrAnonymousHeadIntPtrOnlyString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "PtrAnonymousHeadIntPtrOnlyString", data: struct { *structIntPtrString }{ @@ -2874,11 +1740,7 @@ null // NilPtrAnonymousHeadIntPtrOnly { - name: "NilPtrAnonymousHeadIntPtrOnly", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadIntPtrOnly", data: struct { *structIntPtr }{ @@ -2886,11 +1748,7 @@ null }, }, { - name: "NilPtrAnonymousHeadIntPtrOnlyOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadIntPtrOnlyOmitEmpty", data: struct { *structIntPtrOmitEmpty }{ @@ -2898,11 +1756,7 @@ null }, }, { - name: "NilPtrAnonymousHeadIntPtrOnlyString", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadIntPtrOnlyString", data: struct { *structIntPtrString }{ @@ -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()) - } - } } } } From cfffa103ce709eb1a43b37c1e58339e3a3f2b970 Mon Sep 17 00:00:00 2001 From: Masaaki Goshima Date: Mon, 15 Feb 2021 02:08:22 +0900 Subject: [PATCH 02/15] Refactor cover_int8_test.go --- cover_int8_test.go | 1540 ++++++-------------------------------------- 1 file changed, 192 insertions(+), 1348 deletions(-) diff --git a/cover_int8_test.go b/cover_int8_test.go index 617efa3..7b39edc 100644 --- a/cover_int8_test.go +++ b/cover_int8_test.go @@ -2,7 +2,6 @@ package json_test import ( "bytes" - "strings" "testing" "github.com/goccy/go-json" @@ -30,42 +29,24 @@ func TestCoverInt8(t *testing.T) { } tests := []struct { - name string - expected string - indentExpected string - data interface{} + name string + data interface{} }{ // HeadInt8Zero { - name: "HeadInt8Zero", - expected: `{"a":0}`, - indentExpected: ` -{ - "a": 0 -} -`, + name: "HeadInt8Zero", data: struct { A int8 `json:"a"` }{}, }, { - name: "HeadInt8ZeroOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "HeadInt8ZeroOmitEmpty", data: struct { A int8 `json:"a,omitempty"` }{}, }, { - name: "HeadInt8ZeroString", - expected: `{"a":"0"}`, - indentExpected: ` -{ - "a": "0" -} -`, + name: "HeadInt8ZeroString", data: struct { A int8 `json:"a,string"` }{}, @@ -73,37 +54,19 @@ func TestCoverInt8(t *testing.T) { // HeadInt8 { - name: "HeadInt8", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "HeadInt8", data: struct { A int8 `json:"a"` }{A: 1}, }, { - name: "HeadInt8OmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "HeadInt8OmitEmpty", data: struct { A int8 `json:"a,omitempty"` }{A: 1}, }, { - name: "HeadInt8String", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "HeadInt8String", data: struct { A int8 `json:"a,string"` }{A: 1}, @@ -111,37 +74,19 @@ func TestCoverInt8(t *testing.T) { // HeadInt8Ptr { - name: "HeadInt8Ptr", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "HeadInt8Ptr", data: struct { A *int8 `json:"a"` }{A: int8ptr(1)}, }, { - name: "HeadInt8PtrOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "HeadInt8PtrOmitEmpty", data: struct { A *int8 `json:"a,omitempty"` }{A: int8ptr(1)}, }, { - name: "HeadInt8PtrString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "HeadInt8PtrString", data: struct { A *int8 `json:"a,string"` }{A: int8ptr(1)}, @@ -149,35 +94,19 @@ func TestCoverInt8(t *testing.T) { // HeadInt8PtrNil { - name: "HeadInt8PtrNil", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "HeadInt8PtrNil", data: struct { A *int8 `json:"a"` }{A: nil}, }, { - name: "HeadInt8PtrNilOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "HeadInt8PtrNilOmitEmpty", data: struct { A *int8 `json:"a,omitempty"` }{A: nil}, }, { - name: "HeadInt8PtrNilString", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "HeadInt8PtrNilString", data: struct { A *int8 `json:"a,string"` }{A: nil}, @@ -185,35 +114,19 @@ func TestCoverInt8(t *testing.T) { // PtrHeadInt8Zero { - name: "PtrHeadInt8Zero", - expected: `{"a":0}`, - indentExpected: ` -{ - "a": 0 -} -`, + name: "PtrHeadInt8Zero", data: &struct { A int8 `json:"a"` }{}, }, { - name: "PtrHeadInt8ZeroOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadInt8ZeroOmitEmpty", data: &struct { A int8 `json:"a,omitempty"` }{}, }, { - name: "PtrHeadInt8ZeroString", - expected: `{"a":"0"}`, - indentExpected: ` -{ - "a": "0" -} -`, + name: "PtrHeadInt8ZeroString", data: &struct { A int8 `json:"a,string"` }{}, @@ -221,37 +134,19 @@ func TestCoverInt8(t *testing.T) { // PtrHeadInt8 { - name: "PtrHeadInt8", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrHeadInt8", data: &struct { A int8 `json:"a"` }{A: 1}, }, { - name: "PtrHeadInt8OmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrHeadInt8OmitEmpty", data: &struct { A int8 `json:"a,omitempty"` }{A: 1}, }, { - name: "PtrHeadInt8String", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "PtrHeadInt8String", data: &struct { A int8 `json:"a,string"` }{A: 1}, @@ -259,37 +154,19 @@ func TestCoverInt8(t *testing.T) { // PtrHeadInt8Ptr { - name: "PtrHeadInt8Ptr", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrHeadInt8Ptr", data: &struct { A *int8 `json:"a"` }{A: int8ptr(1)}, }, { - name: "PtrHeadInt8PtrOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrHeadInt8PtrOmitEmpty", data: &struct { A *int8 `json:"a,omitempty"` }{A: int8ptr(1)}, }, { - name: "PtrHeadInt8PtrString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "PtrHeadInt8PtrString", data: &struct { A *int8 `json:"a,string"` }{A: int8ptr(1)}, @@ -297,35 +174,19 @@ func TestCoverInt8(t *testing.T) { // PtrHeadInt8PtrNil { - name: "PtrHeadInt8PtrNil", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "PtrHeadInt8PtrNil", data: &struct { A *int8 `json:"a"` }{A: nil}, }, { - name: "PtrHeadInt8PtrNilOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadInt8PtrNilOmitEmpty", data: &struct { A *int8 `json:"a,omitempty"` }{A: nil}, }, { - name: "PtrHeadInt8PtrNilString", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "PtrHeadInt8PtrNilString", data: &struct { A *int8 `json:"a,string"` }{A: nil}, @@ -333,31 +194,19 @@ func TestCoverInt8(t *testing.T) { // PtrHeadInt8Nil { - name: "PtrHeadInt8Nil", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt8Nil", data: (*struct { A *int8 `json:"a"` })(nil), }, { - name: "PtrHeadInt8NilOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt8NilOmitEmpty", data: (*struct { A *int8 `json:"a,omitempty"` })(nil), }, { - name: "PtrHeadInt8NilString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt8NilString", data: (*struct { A *int8 `json:"a,string"` })(nil), @@ -365,209 +214,125 @@ null // HeadInt8ZeroMultiFields { - name: "HeadInt8ZeroMultiFields", - expected: `{"a":0,"b":0}`, - indentExpected: ` -{ - "a": 0, - "b": 0 -} -`, + name: "HeadInt8ZeroMultiFields", data: struct { A int8 `json:"a"` B int8 `json:"b"` + C int8 `json:"c"` }{}, }, { - name: "HeadInt8ZeroMultiFieldsOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "HeadInt8ZeroMultiFieldsOmitEmpty", data: struct { A int8 `json:"a,omitempty"` B int8 `json:"b,omitempty"` + C int8 `json:"c,omitempty"` }{}, }, { - name: "HeadInt8ZeroMultiFields", - expected: `{"a":"0","b":"0"}`, - indentExpected: ` -{ - "a": "0", - "b": "0" -} -`, + name: "HeadInt8ZeroMultiFields", data: struct { A int8 `json:"a,string"` B int8 `json:"b,string"` + C int8 `json:"c,string"` }{}, }, // HeadInt8MultiFields { - name: "HeadInt8MultiFields", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "HeadInt8MultiFields", data: struct { A int8 `json:"a"` B int8 `json:"b"` - }{A: 1, B: 2}, + C int8 `json:"c"` + }{A: 1, B: 2, C: 3}, }, { - name: "HeadInt8MultiFieldsOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "HeadInt8MultiFieldsOmitEmpty", data: struct { A int8 `json:"a,omitempty"` B int8 `json:"b,omitempty"` - }{A: 1, B: 2}, + C int8 `json:"c,omitempty"` + }{A: 1, B: 2, C: 3}, }, { - name: "HeadInt8MultiFieldsString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "HeadInt8MultiFieldsString", data: struct { A int8 `json:"a,string"` B int8 `json:"b,string"` - }{A: 1, B: 2}, + C int8 `json:"c,string"` + }{A: 1, B: 2, C: 3}, }, // HeadInt8PtrMultiFields { - name: "HeadInt8PtrMultiFields", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "HeadInt8PtrMultiFields", data: struct { A *int8 `json:"a"` B *int8 `json:"b"` - }{A: int8ptr(1), B: int8ptr(2)}, + C *int8 `json:"c"` + }{A: int8ptr(1), B: int8ptr(2), C: int8ptr(3)}, }, { - name: "HeadInt8PtrMultiFieldsOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "HeadInt8PtrMultiFieldsOmitEmpty", data: struct { A *int8 `json:"a,omitempty"` B *int8 `json:"b,omitempty"` - }{A: int8ptr(1), B: int8ptr(2)}, + C *int8 `json:"c,omitempty"` + }{A: int8ptr(1), B: int8ptr(2), C: int8ptr(3)}, }, { - name: "HeadInt8PtrMultiFieldsString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "HeadInt8PtrMultiFieldsString", data: struct { A *int8 `json:"a,string"` B *int8 `json:"b,string"` - }{A: int8ptr(1), B: int8ptr(2)}, + C *int8 `json:"c,string"` + }{A: int8ptr(1), B: int8ptr(2), C: int8ptr(3)}, }, // HeadInt8PtrNilMultiFields { - name: "HeadInt8PtrNilMultiFields", - expected: `{"a":null,"b":null}`, - indentExpected: ` -{ - "a": null, - "b": null -} -`, + name: "HeadInt8PtrNilMultiFields", data: struct { A *int8 `json:"a"` B *int8 `json:"b"` - }{A: nil, B: nil}, + C *int8 `json:"c"` + }{A: nil, B: nil, C: nil}, }, { - name: "HeadInt8PtrNilMultiFieldsOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "HeadInt8PtrNilMultiFieldsOmitEmpty", data: struct { A *int8 `json:"a,omitempty"` B *int8 `json:"b,omitempty"` - }{A: nil, B: nil}, + C *int8 `json:"c,omitempty"` + }{A: nil, B: nil, C: nil}, }, { - name: "HeadInt8PtrNilMultiFieldsString", - expected: `{"a":null,"b":null}`, - indentExpected: ` -{ - "a": null, - "b": null -} -`, + name: "HeadInt8PtrNilMultiFieldsString", data: struct { A *int8 `json:"a,string"` B *int8 `json:"b,string"` - }{A: nil, B: nil}, + C *int8 `json:"c,string"` + }{A: nil, B: nil, C: nil}, }, // PtrHeadInt8ZeroMultiFields { - name: "PtrHeadInt8ZeroMultiFields", - expected: `{"a":0,"b":0}`, - indentExpected: ` -{ - "a": 0, - "b": 0 -} -`, + name: "PtrHeadInt8ZeroMultiFields", data: &struct { A int8 `json:"a"` B int8 `json:"b"` }{}, }, { - name: "PtrHeadInt8ZeroMultiFieldsOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadInt8ZeroMultiFieldsOmitEmpty", data: &struct { A int8 `json:"a,omitempty"` B int8 `json:"b,omitempty"` }{}, }, { - name: "PtrHeadInt8ZeroMultiFieldsString", - expected: `{"a":"0","b":"0"}`, - indentExpected: ` -{ - "a": "0", - "b": "0" -} -`, + name: "PtrHeadInt8ZeroMultiFieldsString", data: &struct { A int8 `json:"a,string"` B int8 `json:"b,string"` @@ -576,42 +341,21 @@ null // PtrHeadInt8MultiFields { - name: "PtrHeadInt8MultiFields", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrHeadInt8MultiFields", data: &struct { A int8 `json:"a"` B int8 `json:"b"` }{A: 1, B: 2}, }, { - name: "PtrHeadInt8MultiFieldsOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrHeadInt8MultiFieldsOmitEmpty", data: &struct { A int8 `json:"a,omitempty"` B int8 `json:"b,omitempty"` }{A: 1, B: 2}, }, { - name: "PtrHeadInt8MultiFieldsString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "PtrHeadInt8MultiFieldsString", data: &struct { A int8 `json:"a,string"` B int8 `json:"b,string"` @@ -620,42 +364,21 @@ null // PtrHeadInt8PtrMultiFields { - name: "PtrHeadInt8PtrMultiFields", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrHeadInt8PtrMultiFields", data: &struct { A *int8 `json:"a"` B *int8 `json:"b"` }{A: int8ptr(1), B: int8ptr(2)}, }, { - name: "PtrHeadInt8PtrMultiFieldsOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrHeadInt8PtrMultiFieldsOmitEmpty", data: &struct { A *int8 `json:"a,omitempty"` B *int8 `json:"b,omitempty"` }{A: int8ptr(1), B: int8ptr(2)}, }, { - name: "PtrHeadInt8PtrMultiFieldsString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "PtrHeadInt8PtrMultiFieldsString", data: &struct { A *int8 `json:"a,string"` B *int8 `json:"b,string"` @@ -664,39 +387,21 @@ null // PtrHeadInt8PtrNilMultiFields { - name: "PtrHeadInt8PtrNilMultiFields", - expected: `{"a":null,"b":null}`, - indentExpected: ` -{ - "a": null, - "b": null -} -`, + name: "PtrHeadInt8PtrNilMultiFields", data: &struct { A *int8 `json:"a"` B *int8 `json:"b"` }{A: nil, B: nil}, }, { - name: "PtrHeadInt8PtrNilMultiFieldsOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadInt8PtrNilMultiFieldsOmitEmpty", data: &struct { A *int8 `json:"a,omitempty"` B *int8 `json:"b,omitempty"` }{A: nil, B: nil}, }, { - name: "PtrHeadInt8PtrNilMultiFieldsString", - expected: `{"a":null,"b":null}`, - indentExpected: ` -{ - "a": null, - "b": null -} -`, + name: "PtrHeadInt8PtrNilMultiFieldsString", data: &struct { A *int8 `json:"a,string"` B *int8 `json:"b,string"` @@ -705,33 +410,21 @@ null // PtrHeadInt8NilMultiFields { - name: "PtrHeadInt8NilMultiFields", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt8NilMultiFields", data: (*struct { A *int8 `json:"a"` B *int8 `json:"b"` })(nil), }, { - name: "PtrHeadInt8NilMultiFieldsOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt8NilMultiFieldsOmitEmpty", data: (*struct { A *int8 `json:"a,omitempty"` B *int8 `json:"b,omitempty"` })(nil), }, { - name: "PtrHeadInt8NilMultiFieldsString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt8NilMultiFieldsString", data: (*struct { A *int8 `json:"a,string"` B *int8 `json:"b,string"` @@ -740,15 +433,7 @@ null // HeadInt8ZeroNotRoot { - name: "HeadInt8ZeroNotRoot", - expected: `{"A":{"a":0}}`, - indentExpected: ` -{ - "A": { - "a": 0 - } -} -`, + name: "HeadInt8ZeroNotRoot", data: struct { A struct { A int8 `json:"a"` @@ -756,13 +441,7 @@ null }{}, }, { - name: "HeadInt8ZeroNotRootOmitEmpty", - expected: `{"A":{}}`, - indentExpected: ` -{ - "A": {} -} -`, + name: "HeadInt8ZeroNotRootOmitEmpty", data: struct { A struct { A int8 `json:"a,omitempty"` @@ -770,15 +449,7 @@ null }{}, }, { - name: "HeadInt8ZeroNotRootString", - expected: `{"A":{"a":"0"}}`, - indentExpected: ` -{ - "A": { - "a": "0" - } -} -`, + name: "HeadInt8ZeroNotRootString", data: struct { A struct { A int8 `json:"a,string"` @@ -788,15 +459,7 @@ null // HeadInt8NotRoot { - name: "HeadInt8NotRoot", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "HeadInt8NotRoot", data: struct { A struct { A int8 `json:"a"` @@ -806,15 +469,7 @@ null }{A: 1}}, }, { - name: "HeadInt8NotRootOmitEmpty", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "HeadInt8NotRootOmitEmpty", data: struct { A struct { A int8 `json:"a,omitempty"` @@ -824,15 +479,7 @@ null }{A: 1}}, }, { - name: "HeadInt8NotRootString", - expected: `{"A":{"a":"1"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - } -} -`, + name: "HeadInt8NotRootString", data: struct { A struct { A int8 `json:"a,string"` @@ -844,15 +491,7 @@ null // HeadInt8PtrNotRoot { - name: "HeadInt8PtrNotRoot", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "HeadInt8PtrNotRoot", data: struct { A struct { A *int8 `json:"a"` @@ -862,15 +501,7 @@ null }{int8ptr(1)}}, }, { - name: "HeadInt8PtrNotRootOmitEmpty", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "HeadInt8PtrNotRootOmitEmpty", data: struct { A struct { A *int8 `json:"a,omitempty"` @@ -880,15 +511,7 @@ null }{int8ptr(1)}}, }, { - name: "HeadInt8PtrNotRootString", - expected: `{"A":{"a":"1"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - } -} -`, + name: "HeadInt8PtrNotRootString", data: struct { A struct { A *int8 `json:"a,string"` @@ -900,15 +523,7 @@ null // HeadInt8PtrNilNotRoot { - name: "HeadInt8PtrNilNotRoot", - expected: `{"A":{"a":null}}`, - indentExpected: ` -{ - "A": { - "a": null - } -} -`, + name: "HeadInt8PtrNilNotRoot", data: struct { A struct { A *int8 `json:"a"` @@ -916,13 +531,7 @@ null }{}, }, { - name: "HeadInt8PtrNilNotRootOmitEmpty", - expected: `{"A":{}}`, - indentExpected: ` -{ - "A": {} -} -`, + name: "HeadInt8PtrNilNotRootOmitEmpty", data: struct { A struct { A *int8 `json:"a,omitempty"` @@ -930,15 +539,7 @@ null }{}, }, { - name: "HeadInt8PtrNilNotRootString", - expected: `{"A":{"a":null}}`, - indentExpected: ` -{ - "A": { - "a": null - } -} -`, + name: "HeadInt8PtrNilNotRootString", data: struct { A struct { A *int8 `json:"a,string"` @@ -948,15 +549,7 @@ null // PtrHeadInt8ZeroNotRoot { - name: "PtrHeadInt8ZeroNotRoot", - expected: `{"A":{"a":0}}`, - indentExpected: ` -{ - "A": { - "a": 0 - } -} -`, + name: "PtrHeadInt8ZeroNotRoot", data: struct { A *struct { A int8 `json:"a"` @@ -966,13 +559,7 @@ null })}, }, { - name: "PtrHeadInt8ZeroNotRootOmitEmpty", - expected: `{"A":{}}`, - indentExpected: ` -{ - "A": {} -} -`, + name: "PtrHeadInt8ZeroNotRootOmitEmpty", data: struct { A *struct { A int8 `json:"a,omitempty"` @@ -982,15 +569,7 @@ null })}, }, { - name: "PtrHeadInt8ZeroNotRootString", - expected: `{"A":{"a":"0"}}`, - indentExpected: ` -{ - "A": { - "a": "0" - } -} -`, + name: "PtrHeadInt8ZeroNotRootString", data: struct { A *struct { A int8 `json:"a,string"` @@ -1002,15 +581,7 @@ null // PtrHeadInt8NotRoot { - name: "PtrHeadInt8NotRoot", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "PtrHeadInt8NotRoot", data: struct { A *struct { A int8 `json:"a"` @@ -1020,15 +591,7 @@ null }{A: 1})}, }, { - name: "PtrHeadInt8NotRootOmitEmpty", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "PtrHeadInt8NotRootOmitEmpty", data: struct { A *struct { A int8 `json:"a,omitempty"` @@ -1038,15 +601,7 @@ null }{A: 1})}, }, { - name: "PtrHeadInt8NotRootString", - expected: `{"A":{"a":"1"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - } -} -`, + name: "PtrHeadInt8NotRootString", data: struct { A *struct { A int8 `json:"a,string"` @@ -1058,15 +613,7 @@ null // PtrHeadInt8PtrNotRoot { - name: "PtrHeadInt8PtrNotRoot", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "PtrHeadInt8PtrNotRoot", data: struct { A *struct { A *int8 `json:"a"` @@ -1076,15 +623,7 @@ null }{A: int8ptr(1)})}, }, { - name: "PtrHeadInt8PtrNotRootOmitEmpty", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "PtrHeadInt8PtrNotRootOmitEmpty", data: struct { A *struct { A *int8 `json:"a,omitempty"` @@ -1094,15 +633,7 @@ null }{A: int8ptr(1)})}, }, { - name: "PtrHeadInt8PtrNotRootString", - expected: `{"A":{"a":"1"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - } -} -`, + name: "PtrHeadInt8PtrNotRootString", data: struct { A *struct { A *int8 `json:"a,string"` @@ -1114,15 +645,7 @@ null // PtrHeadInt8PtrNilNotRoot { - name: "PtrHeadInt8PtrNilNotRoot", - expected: `{"A":{"a":null}}`, - indentExpected: ` -{ - "A": { - "a": null - } -} -`, + name: "PtrHeadInt8PtrNilNotRoot", data: struct { A *struct { A *int8 `json:"a"` @@ -1132,13 +655,7 @@ null }{A: nil})}, }, { - name: "PtrHeadInt8PtrNilNotRootOmitEmpty", - expected: `{"A":{}}`, - indentExpected: ` -{ - "A": {} -} -`, + name: "PtrHeadInt8PtrNilNotRootOmitEmpty", data: struct { A *struct { A *int8 `json:"a,omitempty"` @@ -1148,15 +665,7 @@ null }{A: nil})}, }, { - name: "PtrHeadInt8PtrNilNotRootString", - expected: `{"A":{"a":null}}`, - indentExpected: ` -{ - "A": { - "a": null - } -} -`, + name: "PtrHeadInt8PtrNilNotRootString", data: struct { A *struct { A *int8 `json:"a,string"` @@ -1168,13 +677,7 @@ null // PtrHeadInt8NilNotRoot { - name: "PtrHeadInt8NilNotRoot", - expected: `{"A":null}`, - indentExpected: ` -{ - "A": null -} -`, + name: "PtrHeadInt8NilNotRoot", data: struct { A *struct { A *int8 `json:"a"` @@ -1182,11 +685,7 @@ null }{A: nil}, }, { - name: "PtrHeadInt8NilNotRootOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadInt8NilNotRootOmitEmpty", data: struct { A *struct { A *int8 `json:"a,omitempty"` @@ -1194,13 +693,7 @@ null }{A: nil}, }, { - name: "PtrHeadInt8NilNotRootString", - expected: `{"A":null}`, - indentExpected: ` -{ - "A": null -} -`, + name: "PtrHeadInt8NilNotRootString", data: struct { A *struct { A *int8 `json:"a,string"` @@ -1210,18 +703,7 @@ null // HeadInt8ZeroMultiFieldsNotRoot { - name: "HeadInt8ZeroMultiFieldsNotRoot", - expected: `{"A":{"a":0},"B":{"b":0}}`, - indentExpected: ` -{ - "A": { - "a": 0 - }, - "B": { - "b": 0 - } -} -`, + name: "HeadInt8ZeroMultiFieldsNotRoot", data: struct { A struct { A int8 `json:"a"` @@ -1232,14 +714,7 @@ null }{}, }, { - name: "HeadInt8ZeroMultiFieldsNotRootOmitEmpty", - expected: `{"A":{},"B":{}}`, - indentExpected: ` -{ - "A": {}, - "B": {} -} -`, + name: "HeadInt8ZeroMultiFieldsNotRootOmitEmpty", data: struct { A struct { A int8 `json:"a,omitempty"` @@ -1250,18 +725,7 @@ null }{}, }, { - name: "HeadInt8ZeroMultiFieldsNotRootString", - expected: `{"A":{"a":"0"},"B":{"b":"0"}}`, - indentExpected: ` -{ - "A": { - "a": "0" - }, - "B": { - "b": "0" - } -} -`, + name: "HeadInt8ZeroMultiFieldsNotRootString", data: struct { A struct { A int8 `json:"a,string"` @@ -1274,18 +738,7 @@ null // HeadInt8MultiFieldsNotRoot { - name: "HeadInt8MultiFieldsNotRoot", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "HeadInt8MultiFieldsNotRoot", data: struct { A struct { A int8 `json:"a"` @@ -1300,18 +753,7 @@ null }{B: 2}}, }, { - name: "HeadInt8MultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "HeadInt8MultiFieldsNotRootOmitEmpty", data: struct { A struct { A int8 `json:"a,omitempty"` @@ -1326,18 +768,7 @@ null }{B: 2}}, }, { - name: "HeadInt8MultiFieldsNotRootString", - expected: `{"A":{"a":"1"},"B":{"b":"2"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - }, - "B": { - "b": "2" - } -} -`, + name: "HeadInt8MultiFieldsNotRootString", data: struct { A struct { A int8 `json:"a,string"` @@ -1354,18 +785,7 @@ null // HeadInt8PtrMultiFieldsNotRoot { - name: "HeadInt8PtrMultiFieldsNotRoot", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "HeadInt8PtrMultiFieldsNotRoot", data: struct { A struct { A *int8 `json:"a"` @@ -1380,18 +800,7 @@ null }{B: int8ptr(2)}}, }, { - name: "HeadInt8PtrMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "HeadInt8PtrMultiFieldsNotRootOmitEmpty", data: struct { A struct { A *int8 `json:"a,omitempty"` @@ -1406,18 +815,7 @@ null }{B: int8ptr(2)}}, }, { - name: "HeadInt8PtrMultiFieldsNotRootString", - expected: `{"A":{"a":"1"},"B":{"b":"2"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - }, - "B": { - "b": "2" - } -} -`, + name: "HeadInt8PtrMultiFieldsNotRootString", data: struct { A struct { A *int8 `json:"a,string"` @@ -1434,18 +832,7 @@ null // HeadInt8PtrNilMultiFieldsNotRoot { - name: "HeadInt8PtrNilMultiFieldsNotRoot", - expected: `{"A":{"a":null},"B":{"b":null}}`, - indentExpected: ` -{ - "A": { - "a": null - }, - "B": { - "b": null - } -} -`, + name: "HeadInt8PtrNilMultiFieldsNotRoot", data: struct { A struct { A *int8 `json:"a"` @@ -1460,14 +847,7 @@ null }{B: nil}}, }, { - name: "HeadInt8PtrNilMultiFieldsNotRootOmitEmpty", - expected: `{"A":{},"B":{}}`, - indentExpected: ` -{ - "A": {}, - "B": {} -} -`, + name: "HeadInt8PtrNilMultiFieldsNotRootOmitEmpty", data: struct { A struct { A *int8 `json:"a,omitempty"` @@ -1482,18 +862,7 @@ null }{B: nil}}, }, { - name: "HeadInt8PtrNilMultiFieldsNotRootString", - expected: `{"A":{"a":null},"B":{"b":null}}`, - indentExpected: ` -{ - "A": { - "a": null - }, - "B": { - "b": null - } -} -`, + name: "HeadInt8PtrNilMultiFieldsNotRootString", data: struct { A struct { A *int8 `json:"a,string"` @@ -1510,18 +879,7 @@ null // PtrHeadInt8ZeroMultiFieldsNotRoot { - name: "PtrHeadInt8ZeroMultiFieldsNotRoot", - expected: `{"A":{"a":0},"B":{"b":0}}`, - indentExpected: ` -{ - "A": { - "a": 0 - }, - "B": { - "b": 0 - } -} -`, + name: "PtrHeadInt8ZeroMultiFieldsNotRoot", data: &struct { A struct { A int8 `json:"a"` @@ -1532,14 +890,7 @@ null }{}, }, { - name: "PtrHeadInt8ZeroMultiFieldsNotRootOmitEmpty", - expected: `{"A":{},"B":{}}`, - indentExpected: ` -{ - "A": {}, - "B": {} -} -`, + name: "PtrHeadInt8ZeroMultiFieldsNotRootOmitEmpty", data: &struct { A struct { A int8 `json:"a,omitempty"` @@ -1550,18 +901,7 @@ null }{}, }, { - name: "PtrHeadInt8ZeroMultiFieldsNotRootString", - expected: `{"A":{"a":"0"},"B":{"b":"0"}}`, - indentExpected: ` -{ - "A": { - "a": "0" - }, - "B": { - "b": "0" - } -} -`, + name: "PtrHeadInt8ZeroMultiFieldsNotRootString", data: &struct { A struct { A int8 `json:"a,string"` @@ -1574,18 +914,7 @@ null // PtrHeadInt8MultiFieldsNotRoot { - name: "PtrHeadInt8MultiFieldsNotRoot", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "PtrHeadInt8MultiFieldsNotRoot", data: &struct { A struct { A int8 `json:"a"` @@ -1600,18 +929,7 @@ null }{B: 2}}, }, { - name: "PtrHeadInt8MultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "PtrHeadInt8MultiFieldsNotRootOmitEmpty", data: &struct { A struct { A int8 `json:"a,omitempty"` @@ -1626,18 +944,7 @@ null }{B: 2}}, }, { - name: "PtrHeadInt8MultiFieldsNotRootString", - expected: `{"A":{"a":"1"},"B":{"b":"2"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - }, - "B": { - "b": "2" - } -} -`, + name: "PtrHeadInt8MultiFieldsNotRootString", data: &struct { A struct { A int8 `json:"a,string"` @@ -1654,18 +961,7 @@ null // PtrHeadInt8PtrMultiFieldsNotRoot { - name: "PtrHeadInt8PtrMultiFieldsNotRoot", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "PtrHeadInt8PtrMultiFieldsNotRoot", data: &struct { A *struct { A *int8 `json:"a"` @@ -1680,18 +976,7 @@ null }{B: int8ptr(2)})}, }, { - name: "PtrHeadInt8PtrMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "PtrHeadInt8PtrMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A *int8 `json:"a,omitempty"` @@ -1706,18 +991,7 @@ null }{B: int8ptr(2)})}, }, { - name: "PtrHeadInt8PtrMultiFieldsNotRootString", - expected: `{"A":{"a":"1"},"B":{"b":"2"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - }, - "B": { - "b": "2" - } -} -`, + name: "PtrHeadInt8PtrMultiFieldsNotRootString", data: &struct { A *struct { A *int8 `json:"a,string"` @@ -1734,14 +1008,7 @@ null // PtrHeadInt8PtrNilMultiFieldsNotRoot { - name: "PtrHeadInt8PtrNilMultiFieldsNotRoot", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadInt8PtrNilMultiFieldsNotRoot", data: &struct { A *struct { A *int8 `json:"a"` @@ -1752,11 +1019,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadInt8PtrNilMultiFieldsNotRootOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadInt8PtrNilMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A *int8 `json:"a,omitempty"` @@ -1767,14 +1030,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadInt8PtrNilMultiFieldsNotRootString", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadInt8PtrNilMultiFieldsNotRootString", data: &struct { A *struct { A *int8 `json:"a,string"` @@ -1787,11 +1043,7 @@ null // PtrHeadInt8NilMultiFieldsNotRoot { - name: "PtrHeadInt8NilMultiFieldsNotRoot", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt8NilMultiFieldsNotRoot", data: (*struct { A *struct { A *int8 `json:"a"` @@ -1802,11 +1054,7 @@ null })(nil), }, { - name: "PtrHeadInt8NilMultiFieldsNotRootOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt8NilMultiFieldsNotRootOmitEmpty", data: (*struct { A *struct { A *int8 `json:"a,omitempty"` @@ -1817,11 +1065,7 @@ null })(nil), }, { - name: "PtrHeadInt8NilMultiFieldsNotRootString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt8NilMultiFieldsNotRootString", data: (*struct { A *struct { A *int8 `json:"a,string"` @@ -1834,20 +1078,7 @@ null // PtrHeadInt8DoubleMultiFieldsNotRoot { - name: "PtrHeadInt8DoubleMultiFieldsNotRoot", - expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`, - indentExpected: ` -{ - "A": { - "a": 1, - "b": 2 - }, - "B": { - "a": 3, - "b": 4 - } -} -`, + name: "PtrHeadInt8DoubleMultiFieldsNotRoot", data: &struct { A *struct { A int8 `json:"a"` @@ -1866,20 +1097,7 @@ null }{A: 3, B: 4})}, }, { - name: "PtrHeadInt8DoubleMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`, - indentExpected: ` -{ - "A": { - "a": 1, - "b": 2 - }, - "B": { - "a": 3, - "b": 4 - } -} -`, + name: "PtrHeadInt8DoubleMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A int8 `json:"a,omitempty"` @@ -1898,20 +1116,7 @@ null }{A: 3, B: 4})}, }, { - name: "PtrHeadInt8DoubleMultiFieldsNotRootString", - expected: `{"A":{"a":"1","b":"2"},"B":{"a":"3","b":"4"}}`, - indentExpected: ` -{ - "A": { - "a": "1", - "b": "2" - }, - "B": { - "a": "3", - "b": "4" - } -} -`, + name: "PtrHeadInt8DoubleMultiFieldsNotRootString", data: &struct { A *struct { A int8 `json:"a,string"` @@ -1932,14 +1137,7 @@ null // PtrHeadInt8NilDoubleMultiFieldsNotRoot { - name: "PtrHeadInt8NilDoubleMultiFieldsNotRoot", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadInt8NilDoubleMultiFieldsNotRoot", data: &struct { A *struct { A int8 `json:"a"` @@ -1952,11 +1150,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadInt8NilDoubleMultiFieldsNotRootOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadInt8NilDoubleMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A int8 `json:"a,omitempty"` @@ -1969,14 +1163,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadInt8NilDoubleMultiFieldsNotRootString", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadInt8NilDoubleMultiFieldsNotRootString", data: &struct { A *struct { A int8 `json:"a,string"` @@ -1991,11 +1178,7 @@ null // PtrHeadInt8NilDoubleMultiFieldsNotRoot { - name: "PtrHeadInt8NilDoubleMultiFieldsNotRoot", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt8NilDoubleMultiFieldsNotRoot", data: (*struct { A *struct { A int8 `json:"a"` @@ -2008,11 +1191,7 @@ null })(nil), }, { - name: "PtrHeadInt8NilDoubleMultiFieldsNotRootOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt8NilDoubleMultiFieldsNotRootOmitEmpty", data: (*struct { A *struct { A int8 `json:"a,omitempty"` @@ -2025,11 +1204,7 @@ null })(nil), }, { - name: "PtrHeadInt8NilDoubleMultiFieldsNotRootString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt8NilDoubleMultiFieldsNotRootString", data: (*struct { A *struct { A int8 `json:"a,string"` @@ -2044,20 +1219,7 @@ null // PtrHeadInt8PtrDoubleMultiFieldsNotRoot { - name: "PtrHeadInt8PtrDoubleMultiFieldsNotRoot", - expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`, - indentExpected: ` -{ - "A": { - "a": 1, - "b": 2 - }, - "B": { - "a": 3, - "b": 4 - } -} -`, + name: "PtrHeadInt8PtrDoubleMultiFieldsNotRoot", data: &struct { A *struct { A *int8 `json:"a"` @@ -2076,20 +1238,7 @@ null }{A: int8ptr(3), B: int8ptr(4)})}, }, { - name: "PtrHeadInt8PtrDoubleMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`, - indentExpected: ` -{ - "A": { - "a": 1, - "b": 2 - }, - "B": { - "a": 3, - "b": 4 - } -} -`, + name: "PtrHeadInt8PtrDoubleMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A *int8 `json:"a,omitempty"` @@ -2108,20 +1257,7 @@ null }{A: int8ptr(3), B: int8ptr(4)})}, }, { - name: "PtrHeadInt8PtrDoubleMultiFieldsNotRootString", - expected: `{"A":{"a":"1","b":"2"},"B":{"a":"3","b":"4"}}`, - indentExpected: ` -{ - "A": { - "a": "1", - "b": "2" - }, - "B": { - "a": "3", - "b": "4" - } -} -`, + name: "PtrHeadInt8PtrDoubleMultiFieldsNotRootString", data: &struct { A *struct { A *int8 `json:"a,string"` @@ -2142,14 +1278,7 @@ null // PtrHeadInt8PtrNilDoubleMultiFieldsNotRoot { - name: "PtrHeadInt8PtrNilDoubleMultiFieldsNotRoot", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadInt8PtrNilDoubleMultiFieldsNotRoot", data: &struct { A *struct { A *int8 `json:"a"` @@ -2162,11 +1291,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadInt8PtrNilDoubleMultiFieldsNotRootOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadInt8PtrNilDoubleMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A *int8 `json:"a,omitempty"` @@ -2179,14 +1304,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadInt8PtrNilDoubleMultiFieldsNotRootString", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadInt8PtrNilDoubleMultiFieldsNotRootString", data: &struct { A *struct { A *int8 `json:"a,string"` @@ -2201,11 +1319,7 @@ null // PtrHeadInt8PtrNilDoubleMultiFieldsNotRoot { - name: "PtrHeadInt8PtrNilDoubleMultiFieldsNotRoot", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt8PtrNilDoubleMultiFieldsNotRoot", data: (*struct { A *struct { A *int8 `json:"a"` @@ -2218,11 +1332,7 @@ null })(nil), }, { - name: "PtrHeadInt8PtrNilDoubleMultiFieldsNotRootOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt8PtrNilDoubleMultiFieldsNotRootOmitEmpty", data: (*struct { A *struct { A *int8 `json:"a,omitempty"` @@ -2235,11 +1345,7 @@ null })(nil), }, { - name: "PtrHeadInt8PtrNilDoubleMultiFieldsNotRootString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt8PtrNilDoubleMultiFieldsNotRootString", data: (*struct { A *struct { A *int8 `json:"a,string"` @@ -2254,14 +1360,7 @@ null // AnonymousHeadInt8 { - name: "AnonymousHeadInt8", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "AnonymousHeadInt8", data: struct { structInt8 B int8 `json:"b"` @@ -2271,14 +1370,7 @@ null }, }, { - name: "AnonymousHeadInt8OmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "AnonymousHeadInt8OmitEmpty", data: struct { structInt8OmitEmpty B int8 `json:"b,omitempty"` @@ -2288,14 +1380,7 @@ null }, }, { - name: "AnonymousHeadInt8String", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "AnonymousHeadInt8String", data: struct { structInt8String B int8 `json:"b,string"` @@ -2307,14 +1392,7 @@ null // PtrAnonymousHeadInt8 { - name: "PtrAnonymousHeadInt8", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrAnonymousHeadInt8", data: struct { *structInt8 B int8 `json:"b"` @@ -2324,14 +1402,7 @@ null }, }, { - name: "PtrAnonymousHeadInt8OmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrAnonymousHeadInt8OmitEmpty", data: struct { *structInt8OmitEmpty B int8 `json:"b,omitempty"` @@ -2341,14 +1412,7 @@ null }, }, { - name: "PtrAnonymousHeadInt8String", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "PtrAnonymousHeadInt8String", data: struct { *structInt8String B int8 `json:"b,string"` @@ -2360,13 +1424,7 @@ null // NilPtrAnonymousHeadInt8 { - name: "NilPtrAnonymousHeadInt8", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "NilPtrAnonymousHeadInt8", data: struct { *structInt8 B int8 `json:"b"` @@ -2376,13 +1434,7 @@ null }, }, { - name: "NilPtrAnonymousHeadInt8OmitEmpty", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "NilPtrAnonymousHeadInt8OmitEmpty", data: struct { *structInt8OmitEmpty B int8 `json:"b,omitempty"` @@ -2392,13 +1444,7 @@ null }, }, { - name: "NilPtrAnonymousHeadInt8String", - expected: `{"b":"2"}`, - indentExpected: ` -{ - "b": "2" -} -`, + name: "NilPtrAnonymousHeadInt8String", data: struct { *structInt8String B int8 `json:"b,string"` @@ -2410,14 +1456,7 @@ null // AnonymousHeadInt8Ptr { - name: "AnonymousHeadInt8Ptr", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "AnonymousHeadInt8Ptr", data: struct { structInt8Ptr B *int8 `json:"b"` @@ -2427,14 +1466,7 @@ null }, }, { - name: "AnonymousHeadInt8PtrOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "AnonymousHeadInt8PtrOmitEmpty", data: struct { structInt8PtrOmitEmpty B *int8 `json:"b,omitempty"` @@ -2444,14 +1476,7 @@ null }, }, { - name: "AnonymousHeadInt8PtrString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "AnonymousHeadInt8PtrString", data: struct { structInt8PtrString B *int8 `json:"b,string"` @@ -2463,14 +1488,7 @@ null // AnonymousHeadInt8PtrNil { - name: "AnonymousHeadInt8PtrNil", - expected: `{"a":null,"b":2}`, - indentExpected: ` -{ - "a": null, - "b": 2 -} -`, + name: "AnonymousHeadInt8PtrNil", data: struct { structInt8Ptr B *int8 `json:"b"` @@ -2480,13 +1498,7 @@ null }, }, { - name: "AnonymousHeadInt8PtrNilOmitEmpty", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "AnonymousHeadInt8PtrNilOmitEmpty", data: struct { structInt8PtrOmitEmpty B *int8 `json:"b,omitempty"` @@ -2496,14 +1508,7 @@ null }, }, { - name: "AnonymousHeadInt8PtrNilString", - expected: `{"a":null,"b":"2"}`, - indentExpected: ` -{ - "a": null, - "b": "2" -} -`, + name: "AnonymousHeadInt8PtrNilString", data: struct { structInt8PtrString B *int8 `json:"b,string"` @@ -2515,14 +1520,7 @@ null // PtrAnonymousHeadInt8Ptr { - name: "PtrAnonymousHeadInt8Ptr", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrAnonymousHeadInt8Ptr", data: struct { *structInt8Ptr B *int8 `json:"b"` @@ -2532,14 +1530,7 @@ null }, }, { - name: "PtrAnonymousHeadInt8PtrOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrAnonymousHeadInt8PtrOmitEmpty", data: struct { *structInt8PtrOmitEmpty B *int8 `json:"b,omitempty"` @@ -2549,14 +1540,7 @@ null }, }, { - name: "PtrAnonymousHeadInt8PtrString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "PtrAnonymousHeadInt8PtrString", data: struct { *structInt8PtrString B *int8 `json:"b,string"` @@ -2568,13 +1552,7 @@ null // NilPtrAnonymousHeadInt8Ptr { - name: "NilPtrAnonymousHeadInt8Ptr", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "NilPtrAnonymousHeadInt8Ptr", data: struct { *structInt8Ptr B *int8 `json:"b"` @@ -2584,13 +1562,7 @@ null }, }, { - name: "NilPtrAnonymousHeadInt8PtrOmitEmpty", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "NilPtrAnonymousHeadInt8PtrOmitEmpty", data: struct { *structInt8PtrOmitEmpty B *int8 `json:"b,omitempty"` @@ -2600,13 +1572,7 @@ null }, }, { - name: "NilPtrAnonymousHeadInt8PtrString", - expected: `{"b":"2"}`, - indentExpected: ` -{ - "b": "2" -} -`, + name: "NilPtrAnonymousHeadInt8PtrString", data: struct { *structInt8PtrString B *int8 `json:"b,string"` @@ -2618,13 +1584,7 @@ null // AnonymousHeadInt8Only { - name: "AnonymousHeadInt8Only", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "AnonymousHeadInt8Only", data: struct { structInt8 }{ @@ -2632,13 +1592,7 @@ null }, }, { - name: "AnonymousHeadInt8OnlyOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "AnonymousHeadInt8OnlyOmitEmpty", data: struct { structInt8OmitEmpty }{ @@ -2646,13 +1600,7 @@ null }, }, { - name: "AnonymousHeadInt8OnlyString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "AnonymousHeadInt8OnlyString", data: struct { structInt8String }{ @@ -2662,13 +1610,7 @@ null // PtrAnonymousHeadInt8Only { - name: "PtrAnonymousHeadInt8Only", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrAnonymousHeadInt8Only", data: struct { *structInt8 }{ @@ -2676,13 +1618,7 @@ null }, }, { - name: "PtrAnonymousHeadInt8OnlyOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrAnonymousHeadInt8OnlyOmitEmpty", data: struct { *structInt8OmitEmpty }{ @@ -2690,13 +1626,7 @@ null }, }, { - name: "PtrAnonymousHeadInt8OnlyString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "PtrAnonymousHeadInt8OnlyString", data: struct { *structInt8String }{ @@ -2706,11 +1636,7 @@ null // NilPtrAnonymousHeadInt8Only { - name: "NilPtrAnonymousHeadInt8Only", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadInt8Only", data: struct { *structInt8 }{ @@ -2718,11 +1644,7 @@ null }, }, { - name: "NilPtrAnonymousHeadInt8OnlyOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadInt8OnlyOmitEmpty", data: struct { *structInt8OmitEmpty }{ @@ -2730,11 +1652,7 @@ null }, }, { - name: "NilPtrAnonymousHeadInt8OnlyString", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadInt8OnlyString", data: struct { *structInt8String }{ @@ -2744,13 +1662,7 @@ null // AnonymousHeadInt8PtrOnly { - name: "AnonymousHeadInt8PtrOnly", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "AnonymousHeadInt8PtrOnly", data: struct { structInt8Ptr }{ @@ -2758,13 +1670,7 @@ null }, }, { - name: "AnonymousHeadInt8PtrOnlyOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "AnonymousHeadInt8PtrOnlyOmitEmpty", data: struct { structInt8PtrOmitEmpty }{ @@ -2772,13 +1678,7 @@ null }, }, { - name: "AnonymousHeadInt8PtrOnlyString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "AnonymousHeadInt8PtrOnlyString", data: struct { structInt8PtrString }{ @@ -2788,13 +1688,7 @@ null // AnonymousHeadInt8PtrNilOnly { - name: "AnonymousHeadInt8PtrNilOnly", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "AnonymousHeadInt8PtrNilOnly", data: struct { structInt8Ptr }{ @@ -2802,11 +1696,7 @@ null }, }, { - name: "AnonymousHeadInt8PtrNilOnlyOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "AnonymousHeadInt8PtrNilOnlyOmitEmpty", data: struct { structInt8PtrOmitEmpty }{ @@ -2814,13 +1704,7 @@ null }, }, { - name: "AnonymousHeadInt8PtrNilOnlyString", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "AnonymousHeadInt8PtrNilOnlyString", data: struct { structInt8PtrString }{ @@ -2830,13 +1714,7 @@ null // PtrAnonymousHeadInt8PtrOnly { - name: "PtrAnonymousHeadInt8PtrOnly", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrAnonymousHeadInt8PtrOnly", data: struct { *structInt8Ptr }{ @@ -2844,13 +1722,7 @@ null }, }, { - name: "PtrAnonymousHeadInt8PtrOnlyOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrAnonymousHeadInt8PtrOnlyOmitEmpty", data: struct { *structInt8PtrOmitEmpty }{ @@ -2858,13 +1730,7 @@ null }, }, { - name: "PtrAnonymousHeadInt8PtrOnlyString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "PtrAnonymousHeadInt8PtrOnlyString", data: struct { *structInt8PtrString }{ @@ -2874,11 +1740,7 @@ null // NilPtrAnonymousHeadInt8PtrOnly { - name: "NilPtrAnonymousHeadInt8PtrOnly", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadInt8PtrOnly", data: struct { *structInt8Ptr }{ @@ -2886,11 +1748,7 @@ null }, }, { - name: "NilPtrAnonymousHeadInt8PtrOnlyOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadInt8PtrOnlyOmitEmpty", data: struct { *structInt8PtrOmitEmpty }{ @@ -2898,11 +1756,7 @@ null }, }, { - name: "NilPtrAnonymousHeadInt8PtrOnlyString", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadInt8PtrOnlyString", data: struct { *structInt8PtrString }{ @@ -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()) - } - } } } } From 6486503b70c09c56c4dad04a2516adef78c0cd58 Mon Sep 17 00:00:00 2001 From: Masaaki Goshima Date: Mon, 15 Feb 2021 02:21:08 +0900 Subject: [PATCH 03/15] Refactor cover_int16_test.go --- cover_int16_test.go | 1540 ++++++------------------------------------- 1 file changed, 192 insertions(+), 1348 deletions(-) diff --git a/cover_int16_test.go b/cover_int16_test.go index 933bdc5..55c98ed 100644 --- a/cover_int16_test.go +++ b/cover_int16_test.go @@ -2,7 +2,6 @@ package json_test import ( "bytes" - "strings" "testing" "github.com/goccy/go-json" @@ -30,42 +29,24 @@ func TestCoverInt16(t *testing.T) { } tests := []struct { - name string - expected string - indentExpected string - data interface{} + name string + data interface{} }{ // HeadInt16Zero { - name: "HeadInt16Zero", - expected: `{"a":0}`, - indentExpected: ` -{ - "a": 0 -} -`, + name: "HeadInt16Zero", data: struct { A int16 `json:"a"` }{}, }, { - name: "HeadInt16ZeroOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "HeadInt16ZeroOmitEmpty", data: struct { A int16 `json:"a,omitempty"` }{}, }, { - name: "HeadInt16ZeroString", - expected: `{"a":"0"}`, - indentExpected: ` -{ - "a": "0" -} -`, + name: "HeadInt16ZeroString", data: struct { A int16 `json:"a,string"` }{}, @@ -73,37 +54,19 @@ func TestCoverInt16(t *testing.T) { // HeadInt16 { - name: "HeadInt16", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "HeadInt16", data: struct { A int16 `json:"a"` }{A: 1}, }, { - name: "HeadInt16OmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "HeadInt16OmitEmpty", data: struct { A int16 `json:"a,omitempty"` }{A: 1}, }, { - name: "HeadInt16String", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "HeadInt16String", data: struct { A int16 `json:"a,string"` }{A: 1}, @@ -111,37 +74,19 @@ func TestCoverInt16(t *testing.T) { // HeadInt16Ptr { - name: "HeadInt16Ptr", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "HeadInt16Ptr", data: struct { A *int16 `json:"a"` }{A: int16ptr(1)}, }, { - name: "HeadInt16PtrOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "HeadInt16PtrOmitEmpty", data: struct { A *int16 `json:"a,omitempty"` }{A: int16ptr(1)}, }, { - name: "HeadInt16PtrString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "HeadInt16PtrString", data: struct { A *int16 `json:"a,string"` }{A: int16ptr(1)}, @@ -149,35 +94,19 @@ func TestCoverInt16(t *testing.T) { // HeadInt16PtrNil { - name: "HeadInt16PtrNil", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "HeadInt16PtrNil", data: struct { A *int16 `json:"a"` }{A: nil}, }, { - name: "HeadInt16PtrNilOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "HeadInt16PtrNilOmitEmpty", data: struct { A *int16 `json:"a,omitempty"` }{A: nil}, }, { - name: "HeadInt16PtrNilString", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "HeadInt16PtrNilString", data: struct { A *int16 `json:"a,string"` }{A: nil}, @@ -185,35 +114,19 @@ func TestCoverInt16(t *testing.T) { // PtrHeadInt16Zero { - name: "PtrHeadInt16Zero", - expected: `{"a":0}`, - indentExpected: ` -{ - "a": 0 -} -`, + name: "PtrHeadInt16Zero", data: &struct { A int16 `json:"a"` }{}, }, { - name: "PtrHeadInt16ZeroOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadInt16ZeroOmitEmpty", data: &struct { A int16 `json:"a,omitempty"` }{}, }, { - name: "PtrHeadInt16ZeroString", - expected: `{"a":"0"}`, - indentExpected: ` -{ - "a": "0" -} -`, + name: "PtrHeadInt16ZeroString", data: &struct { A int16 `json:"a,string"` }{}, @@ -221,37 +134,19 @@ func TestCoverInt16(t *testing.T) { // PtrHeadInt16 { - name: "PtrHeadInt16", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrHeadInt16", data: &struct { A int16 `json:"a"` }{A: 1}, }, { - name: "PtrHeadInt16OmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrHeadInt16OmitEmpty", data: &struct { A int16 `json:"a,omitempty"` }{A: 1}, }, { - name: "PtrHeadInt16String", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "PtrHeadInt16String", data: &struct { A int16 `json:"a,string"` }{A: 1}, @@ -259,37 +154,19 @@ func TestCoverInt16(t *testing.T) { // PtrHeadInt16Ptr { - name: "PtrHeadInt16Ptr", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrHeadInt16Ptr", data: &struct { A *int16 `json:"a"` }{A: int16ptr(1)}, }, { - name: "PtrHeadInt16PtrOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrHeadInt16PtrOmitEmpty", data: &struct { A *int16 `json:"a,omitempty"` }{A: int16ptr(1)}, }, { - name: "PtrHeadInt16PtrString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "PtrHeadInt16PtrString", data: &struct { A *int16 `json:"a,string"` }{A: int16ptr(1)}, @@ -297,35 +174,19 @@ func TestCoverInt16(t *testing.T) { // PtrHeadInt16PtrNil { - name: "PtrHeadInt16PtrNil", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "PtrHeadInt16PtrNil", data: &struct { A *int16 `json:"a"` }{A: nil}, }, { - name: "PtrHeadInt16PtrNilOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadInt16PtrNilOmitEmpty", data: &struct { A *int16 `json:"a,omitempty"` }{A: nil}, }, { - name: "PtrHeadInt16PtrNilString", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "PtrHeadInt16PtrNilString", data: &struct { A *int16 `json:"a,string"` }{A: nil}, @@ -333,31 +194,19 @@ func TestCoverInt16(t *testing.T) { // PtrHeadInt16Nil { - name: "PtrHeadInt16Nil", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt16Nil", data: (*struct { A *int16 `json:"a"` })(nil), }, { - name: "PtrHeadInt16NilOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt16NilOmitEmpty", data: (*struct { A *int16 `json:"a,omitempty"` })(nil), }, { - name: "PtrHeadInt16NilString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt16NilString", data: (*struct { A *int16 `json:"a,string"` })(nil), @@ -365,209 +214,125 @@ null // HeadInt16ZeroMultiFields { - name: "HeadInt16ZeroMultiFields", - expected: `{"a":0,"b":0}`, - indentExpected: ` -{ - "a": 0, - "b": 0 -} -`, + name: "HeadInt16ZeroMultiFields", data: struct { A int16 `json:"a"` B int16 `json:"b"` + C int16 `json:"c"` }{}, }, { - name: "HeadInt16ZeroMultiFieldsOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "HeadInt16ZeroMultiFieldsOmitEmpty", data: struct { A int16 `json:"a,omitempty"` B int16 `json:"b,omitempty"` + C int16 `json:"c,omitempty"` }{}, }, { - name: "HeadInt16ZeroMultiFields", - expected: `{"a":"0","b":"0"}`, - indentExpected: ` -{ - "a": "0", - "b": "0" -} -`, + name: "HeadInt16ZeroMultiFields", data: struct { A int16 `json:"a,string"` B int16 `json:"b,string"` + C int16 `json:"c,string"` }{}, }, // HeadInt16MultiFields { - name: "HeadInt16MultiFields", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "HeadInt16MultiFields", data: struct { A int16 `json:"a"` B int16 `json:"b"` - }{A: 1, B: 2}, + C int16 `json:"c"` + }{A: 1, B: 2, C: 3}, }, { - name: "HeadInt16MultiFieldsOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "HeadInt16MultiFieldsOmitEmpty", data: struct { A int16 `json:"a,omitempty"` B int16 `json:"b,omitempty"` - }{A: 1, B: 2}, + C int16 `json:"c,omitempty"` + }{A: 1, B: 2, C: 3}, }, { - name: "HeadInt16MultiFieldsString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "HeadInt16MultiFieldsString", data: struct { A int16 `json:"a,string"` B int16 `json:"b,string"` - }{A: 1, B: 2}, + C int16 `json:"c,string"` + }{A: 1, B: 2, C: 3}, }, // HeadInt16PtrMultiFields { - name: "HeadInt16PtrMultiFields", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "HeadInt16PtrMultiFields", data: struct { A *int16 `json:"a"` B *int16 `json:"b"` - }{A: int16ptr(1), B: int16ptr(2)}, + C *int16 `json:"c"` + }{A: int16ptr(1), B: int16ptr(2), C: int16ptr(3)}, }, { - name: "HeadInt16PtrMultiFieldsOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "HeadInt16PtrMultiFieldsOmitEmpty", data: struct { A *int16 `json:"a,omitempty"` B *int16 `json:"b,omitempty"` - }{A: int16ptr(1), B: int16ptr(2)}, + C *int16 `json:"c,omitempty"` + }{A: int16ptr(1), B: int16ptr(2), C: int16ptr(3)}, }, { - name: "HeadInt16PtrMultiFieldsString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "HeadInt16PtrMultiFieldsString", data: struct { A *int16 `json:"a,string"` B *int16 `json:"b,string"` - }{A: int16ptr(1), B: int16ptr(2)}, + C *int16 `json:"c,string"` + }{A: int16ptr(1), B: int16ptr(2), C: int16ptr(3)}, }, // HeadInt16PtrNilMultiFields { - name: "HeadInt16PtrNilMultiFields", - expected: `{"a":null,"b":null}`, - indentExpected: ` -{ - "a": null, - "b": null -} -`, + name: "HeadInt16PtrNilMultiFields", data: struct { A *int16 `json:"a"` B *int16 `json:"b"` - }{A: nil, B: nil}, + C *int16 `json:"c"` + }{A: nil, B: nil, C: nil}, }, { - name: "HeadInt16PtrNilMultiFieldsOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "HeadInt16PtrNilMultiFieldsOmitEmpty", data: struct { A *int16 `json:"a,omitempty"` B *int16 `json:"b,omitempty"` - }{A: nil, B: nil}, + C *int16 `json:"c,omitempty"` + }{A: nil, B: nil, C: nil}, }, { - name: "HeadInt16PtrNilMultiFieldsString", - expected: `{"a":null,"b":null}`, - indentExpected: ` -{ - "a": null, - "b": null -} -`, + name: "HeadInt16PtrNilMultiFieldsString", data: struct { A *int16 `json:"a,string"` B *int16 `json:"b,string"` - }{A: nil, B: nil}, + C *int16 `json:"c,string"` + }{A: nil, B: nil, C: nil}, }, // PtrHeadInt16ZeroMultiFields { - name: "PtrHeadInt16ZeroMultiFields", - expected: `{"a":0,"b":0}`, - indentExpected: ` -{ - "a": 0, - "b": 0 -} -`, + name: "PtrHeadInt16ZeroMultiFields", data: &struct { A int16 `json:"a"` B int16 `json:"b"` }{}, }, { - name: "PtrHeadInt16ZeroMultiFieldsOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadInt16ZeroMultiFieldsOmitEmpty", data: &struct { A int16 `json:"a,omitempty"` B int16 `json:"b,omitempty"` }{}, }, { - name: "PtrHeadInt16ZeroMultiFieldsString", - expected: `{"a":"0","b":"0"}`, - indentExpected: ` -{ - "a": "0", - "b": "0" -} -`, + name: "PtrHeadInt16ZeroMultiFieldsString", data: &struct { A int16 `json:"a,string"` B int16 `json:"b,string"` @@ -576,42 +341,21 @@ null // PtrHeadInt16MultiFields { - name: "PtrHeadInt16MultiFields", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrHeadInt16MultiFields", data: &struct { A int16 `json:"a"` B int16 `json:"b"` }{A: 1, B: 2}, }, { - name: "PtrHeadInt16MultiFieldsOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrHeadInt16MultiFieldsOmitEmpty", data: &struct { A int16 `json:"a,omitempty"` B int16 `json:"b,omitempty"` }{A: 1, B: 2}, }, { - name: "PtrHeadInt16MultiFieldsString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "PtrHeadInt16MultiFieldsString", data: &struct { A int16 `json:"a,string"` B int16 `json:"b,string"` @@ -620,42 +364,21 @@ null // PtrHeadInt16PtrMultiFields { - name: "PtrHeadInt16PtrMultiFields", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrHeadInt16PtrMultiFields", data: &struct { A *int16 `json:"a"` B *int16 `json:"b"` }{A: int16ptr(1), B: int16ptr(2)}, }, { - name: "PtrHeadInt16PtrMultiFieldsOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrHeadInt16PtrMultiFieldsOmitEmpty", data: &struct { A *int16 `json:"a,omitempty"` B *int16 `json:"b,omitempty"` }{A: int16ptr(1), B: int16ptr(2)}, }, { - name: "PtrHeadInt16PtrMultiFieldsString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "PtrHeadInt16PtrMultiFieldsString", data: &struct { A *int16 `json:"a,string"` B *int16 `json:"b,string"` @@ -664,39 +387,21 @@ null // PtrHeadInt16PtrNilMultiFields { - name: "PtrHeadInt16PtrNilMultiFields", - expected: `{"a":null,"b":null}`, - indentExpected: ` -{ - "a": null, - "b": null -} -`, + name: "PtrHeadInt16PtrNilMultiFields", data: &struct { A *int16 `json:"a"` B *int16 `json:"b"` }{A: nil, B: nil}, }, { - name: "PtrHeadInt16PtrNilMultiFieldsOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadInt16PtrNilMultiFieldsOmitEmpty", data: &struct { A *int16 `json:"a,omitempty"` B *int16 `json:"b,omitempty"` }{A: nil, B: nil}, }, { - name: "PtrHeadInt16PtrNilMultiFieldsString", - expected: `{"a":null,"b":null}`, - indentExpected: ` -{ - "a": null, - "b": null -} -`, + name: "PtrHeadInt16PtrNilMultiFieldsString", data: &struct { A *int16 `json:"a,string"` B *int16 `json:"b,string"` @@ -705,33 +410,21 @@ null // PtrHeadInt16NilMultiFields { - name: "PtrHeadInt16NilMultiFields", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt16NilMultiFields", data: (*struct { A *int16 `json:"a"` B *int16 `json:"b"` })(nil), }, { - name: "PtrHeadInt16NilMultiFieldsOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt16NilMultiFieldsOmitEmpty", data: (*struct { A *int16 `json:"a,omitempty"` B *int16 `json:"b,omitempty"` })(nil), }, { - name: "PtrHeadInt16NilMultiFieldsString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt16NilMultiFieldsString", data: (*struct { A *int16 `json:"a,string"` B *int16 `json:"b,string"` @@ -740,15 +433,7 @@ null // HeadInt16ZeroNotRoot { - name: "HeadInt16ZeroNotRoot", - expected: `{"A":{"a":0}}`, - indentExpected: ` -{ - "A": { - "a": 0 - } -} -`, + name: "HeadInt16ZeroNotRoot", data: struct { A struct { A int16 `json:"a"` @@ -756,13 +441,7 @@ null }{}, }, { - name: "HeadInt16ZeroNotRootOmitEmpty", - expected: `{"A":{}}`, - indentExpected: ` -{ - "A": {} -} -`, + name: "HeadInt16ZeroNotRootOmitEmpty", data: struct { A struct { A int16 `json:"a,omitempty"` @@ -770,15 +449,7 @@ null }{}, }, { - name: "HeadInt16ZeroNotRootString", - expected: `{"A":{"a":"0"}}`, - indentExpected: ` -{ - "A": { - "a": "0" - } -} -`, + name: "HeadInt16ZeroNotRootString", data: struct { A struct { A int16 `json:"a,string"` @@ -788,15 +459,7 @@ null // HeadInt16NotRoot { - name: "HeadInt16NotRoot", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "HeadInt16NotRoot", data: struct { A struct { A int16 `json:"a"` @@ -806,15 +469,7 @@ null }{A: 1}}, }, { - name: "HeadInt16NotRootOmitEmpty", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "HeadInt16NotRootOmitEmpty", data: struct { A struct { A int16 `json:"a,omitempty"` @@ -824,15 +479,7 @@ null }{A: 1}}, }, { - name: "HeadInt16NotRootString", - expected: `{"A":{"a":"1"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - } -} -`, + name: "HeadInt16NotRootString", data: struct { A struct { A int16 `json:"a,string"` @@ -844,15 +491,7 @@ null // HeadInt16PtrNotRoot { - name: "HeadInt16PtrNotRoot", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "HeadInt16PtrNotRoot", data: struct { A struct { A *int16 `json:"a"` @@ -862,15 +501,7 @@ null }{int16ptr(1)}}, }, { - name: "HeadInt16PtrNotRootOmitEmpty", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "HeadInt16PtrNotRootOmitEmpty", data: struct { A struct { A *int16 `json:"a,omitempty"` @@ -880,15 +511,7 @@ null }{int16ptr(1)}}, }, { - name: "HeadInt16PtrNotRootString", - expected: `{"A":{"a":"1"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - } -} -`, + name: "HeadInt16PtrNotRootString", data: struct { A struct { A *int16 `json:"a,string"` @@ -900,15 +523,7 @@ null // HeadInt16PtrNilNotRoot { - name: "HeadInt16PtrNilNotRoot", - expected: `{"A":{"a":null}}`, - indentExpected: ` -{ - "A": { - "a": null - } -} -`, + name: "HeadInt16PtrNilNotRoot", data: struct { A struct { A *int16 `json:"a"` @@ -916,13 +531,7 @@ null }{}, }, { - name: "HeadInt16PtrNilNotRootOmitEmpty", - expected: `{"A":{}}`, - indentExpected: ` -{ - "A": {} -} -`, + name: "HeadInt16PtrNilNotRootOmitEmpty", data: struct { A struct { A *int16 `json:"a,omitempty"` @@ -930,15 +539,7 @@ null }{}, }, { - name: "HeadInt16PtrNilNotRootString", - expected: `{"A":{"a":null}}`, - indentExpected: ` -{ - "A": { - "a": null - } -} -`, + name: "HeadInt16PtrNilNotRootString", data: struct { A struct { A *int16 `json:"a,string"` @@ -948,15 +549,7 @@ null // PtrHeadInt16ZeroNotRoot { - name: "PtrHeadInt16ZeroNotRoot", - expected: `{"A":{"a":0}}`, - indentExpected: ` -{ - "A": { - "a": 0 - } -} -`, + name: "PtrHeadInt16ZeroNotRoot", data: struct { A *struct { A int16 `json:"a"` @@ -966,13 +559,7 @@ null })}, }, { - name: "PtrHeadInt16ZeroNotRootOmitEmpty", - expected: `{"A":{}}`, - indentExpected: ` -{ - "A": {} -} -`, + name: "PtrHeadInt16ZeroNotRootOmitEmpty", data: struct { A *struct { A int16 `json:"a,omitempty"` @@ -982,15 +569,7 @@ null })}, }, { - name: "PtrHeadInt16ZeroNotRootString", - expected: `{"A":{"a":"0"}}`, - indentExpected: ` -{ - "A": { - "a": "0" - } -} -`, + name: "PtrHeadInt16ZeroNotRootString", data: struct { A *struct { A int16 `json:"a,string"` @@ -1002,15 +581,7 @@ null // PtrHeadInt16NotRoot { - name: "PtrHeadInt16NotRoot", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "PtrHeadInt16NotRoot", data: struct { A *struct { A int16 `json:"a"` @@ -1020,15 +591,7 @@ null }{A: 1})}, }, { - name: "PtrHeadInt16NotRootOmitEmpty", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "PtrHeadInt16NotRootOmitEmpty", data: struct { A *struct { A int16 `json:"a,omitempty"` @@ -1038,15 +601,7 @@ null }{A: 1})}, }, { - name: "PtrHeadInt16NotRootString", - expected: `{"A":{"a":"1"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - } -} -`, + name: "PtrHeadInt16NotRootString", data: struct { A *struct { A int16 `json:"a,string"` @@ -1058,15 +613,7 @@ null // PtrHeadInt16PtrNotRoot { - name: "PtrHeadInt16PtrNotRoot", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "PtrHeadInt16PtrNotRoot", data: struct { A *struct { A *int16 `json:"a"` @@ -1076,15 +623,7 @@ null }{A: int16ptr(1)})}, }, { - name: "PtrHeadInt16PtrNotRootOmitEmpty", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "PtrHeadInt16PtrNotRootOmitEmpty", data: struct { A *struct { A *int16 `json:"a,omitempty"` @@ -1094,15 +633,7 @@ null }{A: int16ptr(1)})}, }, { - name: "PtrHeadInt16PtrNotRootString", - expected: `{"A":{"a":"1"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - } -} -`, + name: "PtrHeadInt16PtrNotRootString", data: struct { A *struct { A *int16 `json:"a,string"` @@ -1114,15 +645,7 @@ null // PtrHeadInt16PtrNilNotRoot { - name: "PtrHeadInt16PtrNilNotRoot", - expected: `{"A":{"a":null}}`, - indentExpected: ` -{ - "A": { - "a": null - } -} -`, + name: "PtrHeadInt16PtrNilNotRoot", data: struct { A *struct { A *int16 `json:"a"` @@ -1132,13 +655,7 @@ null }{A: nil})}, }, { - name: "PtrHeadInt16PtrNilNotRootOmitEmpty", - expected: `{"A":{}}`, - indentExpected: ` -{ - "A": {} -} -`, + name: "PtrHeadInt16PtrNilNotRootOmitEmpty", data: struct { A *struct { A *int16 `json:"a,omitempty"` @@ -1148,15 +665,7 @@ null }{A: nil})}, }, { - name: "PtrHeadInt16PtrNilNotRootString", - expected: `{"A":{"a":null}}`, - indentExpected: ` -{ - "A": { - "a": null - } -} -`, + name: "PtrHeadInt16PtrNilNotRootString", data: struct { A *struct { A *int16 `json:"a,string"` @@ -1168,13 +677,7 @@ null // PtrHeadInt16NilNotRoot { - name: "PtrHeadInt16NilNotRoot", - expected: `{"A":null}`, - indentExpected: ` -{ - "A": null -} -`, + name: "PtrHeadInt16NilNotRoot", data: struct { A *struct { A *int16 `json:"a"` @@ -1182,11 +685,7 @@ null }{A: nil}, }, { - name: "PtrHeadInt16NilNotRootOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadInt16NilNotRootOmitEmpty", data: struct { A *struct { A *int16 `json:"a,omitempty"` @@ -1194,13 +693,7 @@ null }{A: nil}, }, { - name: "PtrHeadInt16NilNotRootString", - expected: `{"A":null}`, - indentExpected: ` -{ - "A": null -} -`, + name: "PtrHeadInt16NilNotRootString", data: struct { A *struct { A *int16 `json:"a,string"` @@ -1210,18 +703,7 @@ null // HeadInt16ZeroMultiFieldsNotRoot { - name: "HeadInt16ZeroMultiFieldsNotRoot", - expected: `{"A":{"a":0},"B":{"b":0}}`, - indentExpected: ` -{ - "A": { - "a": 0 - }, - "B": { - "b": 0 - } -} -`, + name: "HeadInt16ZeroMultiFieldsNotRoot", data: struct { A struct { A int16 `json:"a"` @@ -1232,14 +714,7 @@ null }{}, }, { - name: "HeadInt16ZeroMultiFieldsNotRootOmitEmpty", - expected: `{"A":{},"B":{}}`, - indentExpected: ` -{ - "A": {}, - "B": {} -} -`, + name: "HeadInt16ZeroMultiFieldsNotRootOmitEmpty", data: struct { A struct { A int16 `json:"a,omitempty"` @@ -1250,18 +725,7 @@ null }{}, }, { - name: "HeadInt16ZeroMultiFieldsNotRootString", - expected: `{"A":{"a":"0"},"B":{"b":"0"}}`, - indentExpected: ` -{ - "A": { - "a": "0" - }, - "B": { - "b": "0" - } -} -`, + name: "HeadInt16ZeroMultiFieldsNotRootString", data: struct { A struct { A int16 `json:"a,string"` @@ -1274,18 +738,7 @@ null // HeadInt16MultiFieldsNotRoot { - name: "HeadInt16MultiFieldsNotRoot", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "HeadInt16MultiFieldsNotRoot", data: struct { A struct { A int16 `json:"a"` @@ -1300,18 +753,7 @@ null }{B: 2}}, }, { - name: "HeadInt16MultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "HeadInt16MultiFieldsNotRootOmitEmpty", data: struct { A struct { A int16 `json:"a,omitempty"` @@ -1326,18 +768,7 @@ null }{B: 2}}, }, { - name: "HeadInt16MultiFieldsNotRootString", - expected: `{"A":{"a":"1"},"B":{"b":"2"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - }, - "B": { - "b": "2" - } -} -`, + name: "HeadInt16MultiFieldsNotRootString", data: struct { A struct { A int16 `json:"a,string"` @@ -1354,18 +785,7 @@ null // HeadInt16PtrMultiFieldsNotRoot { - name: "HeadInt16PtrMultiFieldsNotRoot", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "HeadInt16PtrMultiFieldsNotRoot", data: struct { A struct { A *int16 `json:"a"` @@ -1380,18 +800,7 @@ null }{B: int16ptr(2)}}, }, { - name: "HeadInt16PtrMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "HeadInt16PtrMultiFieldsNotRootOmitEmpty", data: struct { A struct { A *int16 `json:"a,omitempty"` @@ -1406,18 +815,7 @@ null }{B: int16ptr(2)}}, }, { - name: "HeadInt16PtrMultiFieldsNotRootString", - expected: `{"A":{"a":"1"},"B":{"b":"2"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - }, - "B": { - "b": "2" - } -} -`, + name: "HeadInt16PtrMultiFieldsNotRootString", data: struct { A struct { A *int16 `json:"a,string"` @@ -1434,18 +832,7 @@ null // HeadInt16PtrNilMultiFieldsNotRoot { - name: "HeadInt16PtrNilMultiFieldsNotRoot", - expected: `{"A":{"a":null},"B":{"b":null}}`, - indentExpected: ` -{ - "A": { - "a": null - }, - "B": { - "b": null - } -} -`, + name: "HeadInt16PtrNilMultiFieldsNotRoot", data: struct { A struct { A *int16 `json:"a"` @@ -1460,14 +847,7 @@ null }{B: nil}}, }, { - name: "HeadInt16PtrNilMultiFieldsNotRootOmitEmpty", - expected: `{"A":{},"B":{}}`, - indentExpected: ` -{ - "A": {}, - "B": {} -} -`, + name: "HeadInt16PtrNilMultiFieldsNotRootOmitEmpty", data: struct { A struct { A *int16 `json:"a,omitempty"` @@ -1482,18 +862,7 @@ null }{B: nil}}, }, { - name: "HeadInt16PtrNilMultiFieldsNotRootString", - expected: `{"A":{"a":null},"B":{"b":null}}`, - indentExpected: ` -{ - "A": { - "a": null - }, - "B": { - "b": null - } -} -`, + name: "HeadInt16PtrNilMultiFieldsNotRootString", data: struct { A struct { A *int16 `json:"a,string"` @@ -1510,18 +879,7 @@ null // PtrHeadInt16ZeroMultiFieldsNotRoot { - name: "PtrHeadInt16ZeroMultiFieldsNotRoot", - expected: `{"A":{"a":0},"B":{"b":0}}`, - indentExpected: ` -{ - "A": { - "a": 0 - }, - "B": { - "b": 0 - } -} -`, + name: "PtrHeadInt16ZeroMultiFieldsNotRoot", data: &struct { A struct { A int16 `json:"a"` @@ -1532,14 +890,7 @@ null }{}, }, { - name: "PtrHeadInt16ZeroMultiFieldsNotRootOmitEmpty", - expected: `{"A":{},"B":{}}`, - indentExpected: ` -{ - "A": {}, - "B": {} -} -`, + name: "PtrHeadInt16ZeroMultiFieldsNotRootOmitEmpty", data: &struct { A struct { A int16 `json:"a,omitempty"` @@ -1550,18 +901,7 @@ null }{}, }, { - name: "PtrHeadInt16ZeroMultiFieldsNotRootString", - expected: `{"A":{"a":"0"},"B":{"b":"0"}}`, - indentExpected: ` -{ - "A": { - "a": "0" - }, - "B": { - "b": "0" - } -} -`, + name: "PtrHeadInt16ZeroMultiFieldsNotRootString", data: &struct { A struct { A int16 `json:"a,string"` @@ -1574,18 +914,7 @@ null // PtrHeadInt16MultiFieldsNotRoot { - name: "PtrHeadInt16MultiFieldsNotRoot", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "PtrHeadInt16MultiFieldsNotRoot", data: &struct { A struct { A int16 `json:"a"` @@ -1600,18 +929,7 @@ null }{B: 2}}, }, { - name: "PtrHeadInt16MultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "PtrHeadInt16MultiFieldsNotRootOmitEmpty", data: &struct { A struct { A int16 `json:"a,omitempty"` @@ -1626,18 +944,7 @@ null }{B: 2}}, }, { - name: "PtrHeadInt16MultiFieldsNotRootString", - expected: `{"A":{"a":"1"},"B":{"b":"2"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - }, - "B": { - "b": "2" - } -} -`, + name: "PtrHeadInt16MultiFieldsNotRootString", data: &struct { A struct { A int16 `json:"a,string"` @@ -1654,18 +961,7 @@ null // PtrHeadInt16PtrMultiFieldsNotRoot { - name: "PtrHeadInt16PtrMultiFieldsNotRoot", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "PtrHeadInt16PtrMultiFieldsNotRoot", data: &struct { A *struct { A *int16 `json:"a"` @@ -1680,18 +976,7 @@ null }{B: int16ptr(2)})}, }, { - name: "PtrHeadInt16PtrMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "PtrHeadInt16PtrMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A *int16 `json:"a,omitempty"` @@ -1706,18 +991,7 @@ null }{B: int16ptr(2)})}, }, { - name: "PtrHeadInt16PtrMultiFieldsNotRootString", - expected: `{"A":{"a":"1"},"B":{"b":"2"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - }, - "B": { - "b": "2" - } -} -`, + name: "PtrHeadInt16PtrMultiFieldsNotRootString", data: &struct { A *struct { A *int16 `json:"a,string"` @@ -1734,14 +1008,7 @@ null // PtrHeadInt16PtrNilMultiFieldsNotRoot { - name: "PtrHeadInt16PtrNilMultiFieldsNotRoot", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadInt16PtrNilMultiFieldsNotRoot", data: &struct { A *struct { A *int16 `json:"a"` @@ -1752,11 +1019,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadInt16PtrNilMultiFieldsNotRootOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadInt16PtrNilMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A *int16 `json:"a,omitempty"` @@ -1767,14 +1030,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadInt16PtrNilMultiFieldsNotRootString", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadInt16PtrNilMultiFieldsNotRootString", data: &struct { A *struct { A *int16 `json:"a,string"` @@ -1787,11 +1043,7 @@ null // PtrHeadInt16NilMultiFieldsNotRoot { - name: "PtrHeadInt16NilMultiFieldsNotRoot", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt16NilMultiFieldsNotRoot", data: (*struct { A *struct { A *int16 `json:"a"` @@ -1802,11 +1054,7 @@ null })(nil), }, { - name: "PtrHeadInt16NilMultiFieldsNotRootOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt16NilMultiFieldsNotRootOmitEmpty", data: (*struct { A *struct { A *int16 `json:"a,omitempty"` @@ -1817,11 +1065,7 @@ null })(nil), }, { - name: "PtrHeadInt16NilMultiFieldsNotRootString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt16NilMultiFieldsNotRootString", data: (*struct { A *struct { A *int16 `json:"a,string"` @@ -1834,20 +1078,7 @@ null // PtrHeadInt16DoubleMultiFieldsNotRoot { - name: "PtrHeadInt16DoubleMultiFieldsNotRoot", - expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`, - indentExpected: ` -{ - "A": { - "a": 1, - "b": 2 - }, - "B": { - "a": 3, - "b": 4 - } -} -`, + name: "PtrHeadInt16DoubleMultiFieldsNotRoot", data: &struct { A *struct { A int16 `json:"a"` @@ -1866,20 +1097,7 @@ null }{A: 3, B: 4})}, }, { - name: "PtrHeadInt16DoubleMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`, - indentExpected: ` -{ - "A": { - "a": 1, - "b": 2 - }, - "B": { - "a": 3, - "b": 4 - } -} -`, + name: "PtrHeadInt16DoubleMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A int16 `json:"a,omitempty"` @@ -1898,20 +1116,7 @@ null }{A: 3, B: 4})}, }, { - name: "PtrHeadInt16DoubleMultiFieldsNotRootString", - expected: `{"A":{"a":"1","b":"2"},"B":{"a":"3","b":"4"}}`, - indentExpected: ` -{ - "A": { - "a": "1", - "b": "2" - }, - "B": { - "a": "3", - "b": "4" - } -} -`, + name: "PtrHeadInt16DoubleMultiFieldsNotRootString", data: &struct { A *struct { A int16 `json:"a,string"` @@ -1932,14 +1137,7 @@ null // PtrHeadInt16NilDoubleMultiFieldsNotRoot { - name: "PtrHeadInt16NilDoubleMultiFieldsNotRoot", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadInt16NilDoubleMultiFieldsNotRoot", data: &struct { A *struct { A int16 `json:"a"` @@ -1952,11 +1150,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadInt16NilDoubleMultiFieldsNotRootOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadInt16NilDoubleMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A int16 `json:"a,omitempty"` @@ -1969,14 +1163,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadInt16NilDoubleMultiFieldsNotRootString", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadInt16NilDoubleMultiFieldsNotRootString", data: &struct { A *struct { A int16 `json:"a,string"` @@ -1991,11 +1178,7 @@ null // PtrHeadInt16NilDoubleMultiFieldsNotRoot { - name: "PtrHeadInt16NilDoubleMultiFieldsNotRoot", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt16NilDoubleMultiFieldsNotRoot", data: (*struct { A *struct { A int16 `json:"a"` @@ -2008,11 +1191,7 @@ null })(nil), }, { - name: "PtrHeadInt16NilDoubleMultiFieldsNotRootOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt16NilDoubleMultiFieldsNotRootOmitEmpty", data: (*struct { A *struct { A int16 `json:"a,omitempty"` @@ -2025,11 +1204,7 @@ null })(nil), }, { - name: "PtrHeadInt16NilDoubleMultiFieldsNotRootString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt16NilDoubleMultiFieldsNotRootString", data: (*struct { A *struct { A int16 `json:"a,string"` @@ -2044,20 +1219,7 @@ null // PtrHeadInt16PtrDoubleMultiFieldsNotRoot { - name: "PtrHeadInt16PtrDoubleMultiFieldsNotRoot", - expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`, - indentExpected: ` -{ - "A": { - "a": 1, - "b": 2 - }, - "B": { - "a": 3, - "b": 4 - } -} -`, + name: "PtrHeadInt16PtrDoubleMultiFieldsNotRoot", data: &struct { A *struct { A *int16 `json:"a"` @@ -2076,20 +1238,7 @@ null }{A: int16ptr(3), B: int16ptr(4)})}, }, { - name: "PtrHeadInt16PtrDoubleMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`, - indentExpected: ` -{ - "A": { - "a": 1, - "b": 2 - }, - "B": { - "a": 3, - "b": 4 - } -} -`, + name: "PtrHeadInt16PtrDoubleMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A *int16 `json:"a,omitempty"` @@ -2108,20 +1257,7 @@ null }{A: int16ptr(3), B: int16ptr(4)})}, }, { - name: "PtrHeadInt16PtrDoubleMultiFieldsNotRootString", - expected: `{"A":{"a":"1","b":"2"},"B":{"a":"3","b":"4"}}`, - indentExpected: ` -{ - "A": { - "a": "1", - "b": "2" - }, - "B": { - "a": "3", - "b": "4" - } -} -`, + name: "PtrHeadInt16PtrDoubleMultiFieldsNotRootString", data: &struct { A *struct { A *int16 `json:"a,string"` @@ -2142,14 +1278,7 @@ null // PtrHeadInt16PtrNilDoubleMultiFieldsNotRoot { - name: "PtrHeadInt16PtrNilDoubleMultiFieldsNotRoot", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadInt16PtrNilDoubleMultiFieldsNotRoot", data: &struct { A *struct { A *int16 `json:"a"` @@ -2162,11 +1291,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadInt16PtrNilDoubleMultiFieldsNotRootOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadInt16PtrNilDoubleMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A *int16 `json:"a,omitempty"` @@ -2179,14 +1304,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadInt16PtrNilDoubleMultiFieldsNotRootString", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadInt16PtrNilDoubleMultiFieldsNotRootString", data: &struct { A *struct { A *int16 `json:"a,string"` @@ -2201,11 +1319,7 @@ null // PtrHeadInt16PtrNilDoubleMultiFieldsNotRoot { - name: "PtrHeadInt16PtrNilDoubleMultiFieldsNotRoot", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt16PtrNilDoubleMultiFieldsNotRoot", data: (*struct { A *struct { A *int16 `json:"a"` @@ -2218,11 +1332,7 @@ null })(nil), }, { - name: "PtrHeadInt16PtrNilDoubleMultiFieldsNotRootOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt16PtrNilDoubleMultiFieldsNotRootOmitEmpty", data: (*struct { A *struct { A *int16 `json:"a,omitempty"` @@ -2235,11 +1345,7 @@ null })(nil), }, { - name: "PtrHeadInt16PtrNilDoubleMultiFieldsNotRootString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt16PtrNilDoubleMultiFieldsNotRootString", data: (*struct { A *struct { A *int16 `json:"a,string"` @@ -2254,14 +1360,7 @@ null // AnonymousHeadInt16 { - name: "AnonymousHeadInt16", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "AnonymousHeadInt16", data: struct { structInt16 B int16 `json:"b"` @@ -2271,14 +1370,7 @@ null }, }, { - name: "AnonymousHeadInt16OmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "AnonymousHeadInt16OmitEmpty", data: struct { structInt16OmitEmpty B int16 `json:"b,omitempty"` @@ -2288,14 +1380,7 @@ null }, }, { - name: "AnonymousHeadInt16String", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "AnonymousHeadInt16String", data: struct { structInt16String B int16 `json:"b,string"` @@ -2307,14 +1392,7 @@ null // PtrAnonymousHeadInt16 { - name: "PtrAnonymousHeadInt16", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrAnonymousHeadInt16", data: struct { *structInt16 B int16 `json:"b"` @@ -2324,14 +1402,7 @@ null }, }, { - name: "PtrAnonymousHeadInt16OmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrAnonymousHeadInt16OmitEmpty", data: struct { *structInt16OmitEmpty B int16 `json:"b,omitempty"` @@ -2341,14 +1412,7 @@ null }, }, { - name: "PtrAnonymousHeadInt16String", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "PtrAnonymousHeadInt16String", data: struct { *structInt16String B int16 `json:"b,string"` @@ -2360,13 +1424,7 @@ null // NilPtrAnonymousHeadInt16 { - name: "NilPtrAnonymousHeadInt16", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "NilPtrAnonymousHeadInt16", data: struct { *structInt16 B int16 `json:"b"` @@ -2376,13 +1434,7 @@ null }, }, { - name: "NilPtrAnonymousHeadInt16OmitEmpty", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "NilPtrAnonymousHeadInt16OmitEmpty", data: struct { *structInt16OmitEmpty B int16 `json:"b,omitempty"` @@ -2392,13 +1444,7 @@ null }, }, { - name: "NilPtrAnonymousHeadInt16String", - expected: `{"b":"2"}`, - indentExpected: ` -{ - "b": "2" -} -`, + name: "NilPtrAnonymousHeadInt16String", data: struct { *structInt16String B int16 `json:"b,string"` @@ -2410,14 +1456,7 @@ null // AnonymousHeadInt16Ptr { - name: "AnonymousHeadInt16Ptr", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "AnonymousHeadInt16Ptr", data: struct { structInt16Ptr B *int16 `json:"b"` @@ -2427,14 +1466,7 @@ null }, }, { - name: "AnonymousHeadInt16PtrOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "AnonymousHeadInt16PtrOmitEmpty", data: struct { structInt16PtrOmitEmpty B *int16 `json:"b,omitempty"` @@ -2444,14 +1476,7 @@ null }, }, { - name: "AnonymousHeadInt16PtrString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "AnonymousHeadInt16PtrString", data: struct { structInt16PtrString B *int16 `json:"b,string"` @@ -2463,14 +1488,7 @@ null // AnonymousHeadInt16PtrNil { - name: "AnonymousHeadInt16PtrNil", - expected: `{"a":null,"b":2}`, - indentExpected: ` -{ - "a": null, - "b": 2 -} -`, + name: "AnonymousHeadInt16PtrNil", data: struct { structInt16Ptr B *int16 `json:"b"` @@ -2480,13 +1498,7 @@ null }, }, { - name: "AnonymousHeadInt16PtrNilOmitEmpty", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "AnonymousHeadInt16PtrNilOmitEmpty", data: struct { structInt16PtrOmitEmpty B *int16 `json:"b,omitempty"` @@ -2496,14 +1508,7 @@ null }, }, { - name: "AnonymousHeadInt16PtrNilString", - expected: `{"a":null,"b":"2"}`, - indentExpected: ` -{ - "a": null, - "b": "2" -} -`, + name: "AnonymousHeadInt16PtrNilString", data: struct { structInt16PtrString B *int16 `json:"b,string"` @@ -2515,14 +1520,7 @@ null // PtrAnonymousHeadInt16Ptr { - name: "PtrAnonymousHeadInt16Ptr", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrAnonymousHeadInt16Ptr", data: struct { *structInt16Ptr B *int16 `json:"b"` @@ -2532,14 +1530,7 @@ null }, }, { - name: "PtrAnonymousHeadInt16PtrOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrAnonymousHeadInt16PtrOmitEmpty", data: struct { *structInt16PtrOmitEmpty B *int16 `json:"b,omitempty"` @@ -2549,14 +1540,7 @@ null }, }, { - name: "PtrAnonymousHeadInt16PtrString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "PtrAnonymousHeadInt16PtrString", data: struct { *structInt16PtrString B *int16 `json:"b,string"` @@ -2568,13 +1552,7 @@ null // NilPtrAnonymousHeadInt16Ptr { - name: "NilPtrAnonymousHeadInt16Ptr", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "NilPtrAnonymousHeadInt16Ptr", data: struct { *structInt16Ptr B *int16 `json:"b"` @@ -2584,13 +1562,7 @@ null }, }, { - name: "NilPtrAnonymousHeadInt16PtrOmitEmpty", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "NilPtrAnonymousHeadInt16PtrOmitEmpty", data: struct { *structInt16PtrOmitEmpty B *int16 `json:"b,omitempty"` @@ -2600,13 +1572,7 @@ null }, }, { - name: "NilPtrAnonymousHeadInt16PtrString", - expected: `{"b":"2"}`, - indentExpected: ` -{ - "b": "2" -} -`, + name: "NilPtrAnonymousHeadInt16PtrString", data: struct { *structInt16PtrString B *int16 `json:"b,string"` @@ -2618,13 +1584,7 @@ null // AnonymousHeadInt16Only { - name: "AnonymousHeadInt16Only", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "AnonymousHeadInt16Only", data: struct { structInt16 }{ @@ -2632,13 +1592,7 @@ null }, }, { - name: "AnonymousHeadInt16OnlyOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "AnonymousHeadInt16OnlyOmitEmpty", data: struct { structInt16OmitEmpty }{ @@ -2646,13 +1600,7 @@ null }, }, { - name: "AnonymousHeadInt16OnlyString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "AnonymousHeadInt16OnlyString", data: struct { structInt16String }{ @@ -2662,13 +1610,7 @@ null // PtrAnonymousHeadInt16Only { - name: "PtrAnonymousHeadInt16Only", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrAnonymousHeadInt16Only", data: struct { *structInt16 }{ @@ -2676,13 +1618,7 @@ null }, }, { - name: "PtrAnonymousHeadInt16OnlyOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrAnonymousHeadInt16OnlyOmitEmpty", data: struct { *structInt16OmitEmpty }{ @@ -2690,13 +1626,7 @@ null }, }, { - name: "PtrAnonymousHeadInt16OnlyString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "PtrAnonymousHeadInt16OnlyString", data: struct { *structInt16String }{ @@ -2706,11 +1636,7 @@ null // NilPtrAnonymousHeadInt16Only { - name: "NilPtrAnonymousHeadInt16Only", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadInt16Only", data: struct { *structInt16 }{ @@ -2718,11 +1644,7 @@ null }, }, { - name: "NilPtrAnonymousHeadInt16OnlyOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadInt16OnlyOmitEmpty", data: struct { *structInt16OmitEmpty }{ @@ -2730,11 +1652,7 @@ null }, }, { - name: "NilPtrAnonymousHeadInt16OnlyString", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadInt16OnlyString", data: struct { *structInt16String }{ @@ -2744,13 +1662,7 @@ null // AnonymousHeadInt16PtrOnly { - name: "AnonymousHeadInt16PtrOnly", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "AnonymousHeadInt16PtrOnly", data: struct { structInt16Ptr }{ @@ -2758,13 +1670,7 @@ null }, }, { - name: "AnonymousHeadInt16PtrOnlyOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "AnonymousHeadInt16PtrOnlyOmitEmpty", data: struct { structInt16PtrOmitEmpty }{ @@ -2772,13 +1678,7 @@ null }, }, { - name: "AnonymousHeadInt16PtrOnlyString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "AnonymousHeadInt16PtrOnlyString", data: struct { structInt16PtrString }{ @@ -2788,13 +1688,7 @@ null // AnonymousHeadInt16PtrNilOnly { - name: "AnonymousHeadInt16PtrNilOnly", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "AnonymousHeadInt16PtrNilOnly", data: struct { structInt16Ptr }{ @@ -2802,11 +1696,7 @@ null }, }, { - name: "AnonymousHeadInt16PtrNilOnlyOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "AnonymousHeadInt16PtrNilOnlyOmitEmpty", data: struct { structInt16PtrOmitEmpty }{ @@ -2814,13 +1704,7 @@ null }, }, { - name: "AnonymousHeadInt16PtrNilOnlyString", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "AnonymousHeadInt16PtrNilOnlyString", data: struct { structInt16PtrString }{ @@ -2830,13 +1714,7 @@ null // PtrAnonymousHeadInt16PtrOnly { - name: "PtrAnonymousHeadInt16PtrOnly", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrAnonymousHeadInt16PtrOnly", data: struct { *structInt16Ptr }{ @@ -2844,13 +1722,7 @@ null }, }, { - name: "PtrAnonymousHeadInt16PtrOnlyOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrAnonymousHeadInt16PtrOnlyOmitEmpty", data: struct { *structInt16PtrOmitEmpty }{ @@ -2858,13 +1730,7 @@ null }, }, { - name: "PtrAnonymousHeadInt16PtrOnlyString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "PtrAnonymousHeadInt16PtrOnlyString", data: struct { *structInt16PtrString }{ @@ -2874,11 +1740,7 @@ null // NilPtrAnonymousHeadInt16PtrOnly { - name: "NilPtrAnonymousHeadInt16PtrOnly", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadInt16PtrOnly", data: struct { *structInt16Ptr }{ @@ -2886,11 +1748,7 @@ null }, }, { - name: "NilPtrAnonymousHeadInt16PtrOnlyOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadInt16PtrOnlyOmitEmpty", data: struct { *structInt16PtrOmitEmpty }{ @@ -2898,11 +1756,7 @@ null }, }, { - name: "NilPtrAnonymousHeadInt16PtrOnlyString", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadInt16PtrOnlyString", data: struct { *structInt16PtrString }{ @@ -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()) - } - } } } } From 06fd86dc559fc7c3f3fd1d5b506e2a1b9b24b739 Mon Sep 17 00:00:00 2001 From: Masaaki Goshima Date: Mon, 15 Feb 2021 02:53:12 +0900 Subject: [PATCH 04/15] Refactor cover_int32_test.go --- cover_int32_test.go | 1540 ++++++------------------------------------- 1 file changed, 192 insertions(+), 1348 deletions(-) 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()) - } - } } } } From e3eae7bbb62785cfc3c24c7095a872c197afe469 Mon Sep 17 00:00:00 2001 From: Masaaki Goshima Date: Mon, 15 Feb 2021 11:20:23 +0900 Subject: [PATCH 05/15] Refactor cover_int64_test.go --- cover_int64_test.go | 1540 ++++++------------------------------------- 1 file changed, 192 insertions(+), 1348 deletions(-) diff --git a/cover_int64_test.go b/cover_int64_test.go index 18cf876..dd64ca2 100644 --- a/cover_int64_test.go +++ b/cover_int64_test.go @@ -2,7 +2,6 @@ package json_test import ( "bytes" - "strings" "testing" "github.com/goccy/go-json" @@ -30,42 +29,24 @@ func TestCoverInt64(t *testing.T) { } tests := []struct { - name string - expected string - indentExpected string - data interface{} + name string + data interface{} }{ // HeadInt64Zero { - name: "HeadInt64Zero", - expected: `{"a":0}`, - indentExpected: ` -{ - "a": 0 -} -`, + name: "HeadInt64Zero", data: struct { A int64 `json:"a"` }{}, }, { - name: "HeadInt64ZeroOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "HeadInt64ZeroOmitEmpty", data: struct { A int64 `json:"a,omitempty"` }{}, }, { - name: "HeadInt64ZeroString", - expected: `{"a":"0"}`, - indentExpected: ` -{ - "a": "0" -} -`, + name: "HeadInt64ZeroString", data: struct { A int64 `json:"a,string"` }{}, @@ -73,37 +54,19 @@ func TestCoverInt64(t *testing.T) { // HeadInt64 { - name: "HeadInt64", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "HeadInt64", data: struct { A int64 `json:"a"` }{A: 1}, }, { - name: "HeadInt64OmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "HeadInt64OmitEmpty", data: struct { A int64 `json:"a,omitempty"` }{A: 1}, }, { - name: "HeadInt64String", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "HeadInt64String", data: struct { A int64 `json:"a,string"` }{A: 1}, @@ -111,37 +74,19 @@ func TestCoverInt64(t *testing.T) { // HeadInt64Ptr { - name: "HeadInt64Ptr", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "HeadInt64Ptr", data: struct { A *int64 `json:"a"` }{A: int64ptr(1)}, }, { - name: "HeadInt64PtrOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "HeadInt64PtrOmitEmpty", data: struct { A *int64 `json:"a,omitempty"` }{A: int64ptr(1)}, }, { - name: "HeadInt64PtrString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "HeadInt64PtrString", data: struct { A *int64 `json:"a,string"` }{A: int64ptr(1)}, @@ -149,35 +94,19 @@ func TestCoverInt64(t *testing.T) { // HeadInt64PtrNil { - name: "HeadInt64PtrNil", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "HeadInt64PtrNil", data: struct { A *int64 `json:"a"` }{A: nil}, }, { - name: "HeadInt64PtrNilOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "HeadInt64PtrNilOmitEmpty", data: struct { A *int64 `json:"a,omitempty"` }{A: nil}, }, { - name: "HeadInt64PtrNilString", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "HeadInt64PtrNilString", data: struct { A *int64 `json:"a,string"` }{A: nil}, @@ -185,35 +114,19 @@ func TestCoverInt64(t *testing.T) { // PtrHeadInt64Zero { - name: "PtrHeadInt64Zero", - expected: `{"a":0}`, - indentExpected: ` -{ - "a": 0 -} -`, + name: "PtrHeadInt64Zero", data: &struct { A int64 `json:"a"` }{}, }, { - name: "PtrHeadInt64ZeroOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadInt64ZeroOmitEmpty", data: &struct { A int64 `json:"a,omitempty"` }{}, }, { - name: "PtrHeadInt64ZeroString", - expected: `{"a":"0"}`, - indentExpected: ` -{ - "a": "0" -} -`, + name: "PtrHeadInt64ZeroString", data: &struct { A int64 `json:"a,string"` }{}, @@ -221,37 +134,19 @@ func TestCoverInt64(t *testing.T) { // PtrHeadInt64 { - name: "PtrHeadInt64", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrHeadInt64", data: &struct { A int64 `json:"a"` }{A: 1}, }, { - name: "PtrHeadInt64OmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrHeadInt64OmitEmpty", data: &struct { A int64 `json:"a,omitempty"` }{A: 1}, }, { - name: "PtrHeadInt64String", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "PtrHeadInt64String", data: &struct { A int64 `json:"a,string"` }{A: 1}, @@ -259,37 +154,19 @@ func TestCoverInt64(t *testing.T) { // PtrHeadInt64Ptr { - name: "PtrHeadInt64Ptr", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrHeadInt64Ptr", data: &struct { A *int64 `json:"a"` }{A: int64ptr(1)}, }, { - name: "PtrHeadInt64PtrOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrHeadInt64PtrOmitEmpty", data: &struct { A *int64 `json:"a,omitempty"` }{A: int64ptr(1)}, }, { - name: "PtrHeadInt64PtrString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "PtrHeadInt64PtrString", data: &struct { A *int64 `json:"a,string"` }{A: int64ptr(1)}, @@ -297,35 +174,19 @@ func TestCoverInt64(t *testing.T) { // PtrHeadInt64PtrNil { - name: "PtrHeadInt64PtrNil", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "PtrHeadInt64PtrNil", data: &struct { A *int64 `json:"a"` }{A: nil}, }, { - name: "PtrHeadInt64PtrNilOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadInt64PtrNilOmitEmpty", data: &struct { A *int64 `json:"a,omitempty"` }{A: nil}, }, { - name: "PtrHeadInt64PtrNilString", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "PtrHeadInt64PtrNilString", data: &struct { A *int64 `json:"a,string"` }{A: nil}, @@ -333,31 +194,19 @@ func TestCoverInt64(t *testing.T) { // PtrHeadInt64Nil { - name: "PtrHeadInt64Nil", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt64Nil", data: (*struct { A *int64 `json:"a"` })(nil), }, { - name: "PtrHeadInt64NilOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt64NilOmitEmpty", data: (*struct { A *int64 `json:"a,omitempty"` })(nil), }, { - name: "PtrHeadInt64NilString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt64NilString", data: (*struct { A *int64 `json:"a,string"` })(nil), @@ -365,209 +214,125 @@ null // HeadInt64ZeroMultiFields { - name: "HeadInt64ZeroMultiFields", - expected: `{"a":0,"b":0}`, - indentExpected: ` -{ - "a": 0, - "b": 0 -} -`, + name: "HeadInt64ZeroMultiFields", data: struct { A int64 `json:"a"` B int64 `json:"b"` + C int64 `json:"c"` }{}, }, { - name: "HeadInt64ZeroMultiFieldsOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "HeadInt64ZeroMultiFieldsOmitEmpty", data: struct { A int64 `json:"a,omitempty"` B int64 `json:"b,omitempty"` + C int64 `json:"c,omitempty"` }{}, }, { - name: "HeadInt64ZeroMultiFields", - expected: `{"a":"0","b":"0"}`, - indentExpected: ` -{ - "a": "0", - "b": "0" -} -`, + name: "HeadInt64ZeroMultiFields", data: struct { A int64 `json:"a,string"` B int64 `json:"b,string"` + C int64 `json:"c,string"` }{}, }, // HeadInt64MultiFields { - name: "HeadInt64MultiFields", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "HeadInt64MultiFields", data: struct { A int64 `json:"a"` B int64 `json:"b"` - }{A: 1, B: 2}, + C int64 `json:"c"` + }{A: 1, B: 2, C: 3}, }, { - name: "HeadInt64MultiFieldsOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "HeadInt64MultiFieldsOmitEmpty", data: struct { A int64 `json:"a,omitempty"` B int64 `json:"b,omitempty"` - }{A: 1, B: 2}, + C int64 `json:"c,omitempty"` + }{A: 1, B: 2, C: 3}, }, { - name: "HeadInt64MultiFieldsString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "HeadInt64MultiFieldsString", data: struct { A int64 `json:"a,string"` B int64 `json:"b,string"` - }{A: 1, B: 2}, + C int64 `json:"c,string"` + }{A: 1, B: 2, C: 3}, }, // HeadInt64PtrMultiFields { - name: "HeadInt64PtrMultiFields", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "HeadInt64PtrMultiFields", data: struct { A *int64 `json:"a"` B *int64 `json:"b"` - }{A: int64ptr(1), B: int64ptr(2)}, + C *int64 `json:"c"` + }{A: int64ptr(1), B: int64ptr(2), C: int64ptr(3)}, }, { - name: "HeadInt64PtrMultiFieldsOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "HeadInt64PtrMultiFieldsOmitEmpty", data: struct { A *int64 `json:"a,omitempty"` B *int64 `json:"b,omitempty"` - }{A: int64ptr(1), B: int64ptr(2)}, + C *int64 `json:"c,omitempty"` + }{A: int64ptr(1), B: int64ptr(2), C: int64ptr(3)}, }, { - name: "HeadInt64PtrMultiFieldsString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "HeadInt64PtrMultiFieldsString", data: struct { A *int64 `json:"a,string"` B *int64 `json:"b,string"` - }{A: int64ptr(1), B: int64ptr(2)}, + C *int64 `json:"c,string"` + }{A: int64ptr(1), B: int64ptr(2), C: int64ptr(3)}, }, // HeadInt64PtrNilMultiFields { - name: "HeadInt64PtrNilMultiFields", - expected: `{"a":null,"b":null}`, - indentExpected: ` -{ - "a": null, - "b": null -} -`, + name: "HeadInt64PtrNilMultiFields", data: struct { A *int64 `json:"a"` B *int64 `json:"b"` - }{A: nil, B: nil}, + C *int64 `json:"c"` + }{A: nil, B: nil, C: nil}, }, { - name: "HeadInt64PtrNilMultiFieldsOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "HeadInt64PtrNilMultiFieldsOmitEmpty", data: struct { A *int64 `json:"a,omitempty"` B *int64 `json:"b,omitempty"` - }{A: nil, B: nil}, + C *int64 `json:"c,omitempty"` + }{A: nil, B: nil, C: nil}, }, { - name: "HeadInt64PtrNilMultiFieldsString", - expected: `{"a":null,"b":null}`, - indentExpected: ` -{ - "a": null, - "b": null -} -`, + name: "HeadInt64PtrNilMultiFieldsString", data: struct { A *int64 `json:"a,string"` B *int64 `json:"b,string"` - }{A: nil, B: nil}, + C *int64 `json:"c,string"` + }{A: nil, B: nil, C: nil}, }, // PtrHeadInt64ZeroMultiFields { - name: "PtrHeadInt64ZeroMultiFields", - expected: `{"a":0,"b":0}`, - indentExpected: ` -{ - "a": 0, - "b": 0 -} -`, + name: "PtrHeadInt64ZeroMultiFields", data: &struct { A int64 `json:"a"` B int64 `json:"b"` }{}, }, { - name: "PtrHeadInt64ZeroMultiFieldsOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadInt64ZeroMultiFieldsOmitEmpty", data: &struct { A int64 `json:"a,omitempty"` B int64 `json:"b,omitempty"` }{}, }, { - name: "PtrHeadInt64ZeroMultiFieldsString", - expected: `{"a":"0","b":"0"}`, - indentExpected: ` -{ - "a": "0", - "b": "0" -} -`, + name: "PtrHeadInt64ZeroMultiFieldsString", data: &struct { A int64 `json:"a,string"` B int64 `json:"b,string"` @@ -576,42 +341,21 @@ null // PtrHeadInt64MultiFields { - name: "PtrHeadInt64MultiFields", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrHeadInt64MultiFields", data: &struct { A int64 `json:"a"` B int64 `json:"b"` }{A: 1, B: 2}, }, { - name: "PtrHeadInt64MultiFieldsOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrHeadInt64MultiFieldsOmitEmpty", data: &struct { A int64 `json:"a,omitempty"` B int64 `json:"b,omitempty"` }{A: 1, B: 2}, }, { - name: "PtrHeadInt64MultiFieldsString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "PtrHeadInt64MultiFieldsString", data: &struct { A int64 `json:"a,string"` B int64 `json:"b,string"` @@ -620,42 +364,21 @@ null // PtrHeadInt64PtrMultiFields { - name: "PtrHeadInt64PtrMultiFields", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrHeadInt64PtrMultiFields", data: &struct { A *int64 `json:"a"` B *int64 `json:"b"` }{A: int64ptr(1), B: int64ptr(2)}, }, { - name: "PtrHeadInt64PtrMultiFieldsOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrHeadInt64PtrMultiFieldsOmitEmpty", data: &struct { A *int64 `json:"a,omitempty"` B *int64 `json:"b,omitempty"` }{A: int64ptr(1), B: int64ptr(2)}, }, { - name: "PtrHeadInt64PtrMultiFieldsString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "PtrHeadInt64PtrMultiFieldsString", data: &struct { A *int64 `json:"a,string"` B *int64 `json:"b,string"` @@ -664,39 +387,21 @@ null // PtrHeadInt64PtrNilMultiFields { - name: "PtrHeadInt64PtrNilMultiFields", - expected: `{"a":null,"b":null}`, - indentExpected: ` -{ - "a": null, - "b": null -} -`, + name: "PtrHeadInt64PtrNilMultiFields", data: &struct { A *int64 `json:"a"` B *int64 `json:"b"` }{A: nil, B: nil}, }, { - name: "PtrHeadInt64PtrNilMultiFieldsOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadInt64PtrNilMultiFieldsOmitEmpty", data: &struct { A *int64 `json:"a,omitempty"` B *int64 `json:"b,omitempty"` }{A: nil, B: nil}, }, { - name: "PtrHeadInt64PtrNilMultiFieldsString", - expected: `{"a":null,"b":null}`, - indentExpected: ` -{ - "a": null, - "b": null -} -`, + name: "PtrHeadInt64PtrNilMultiFieldsString", data: &struct { A *int64 `json:"a,string"` B *int64 `json:"b,string"` @@ -705,33 +410,21 @@ null // PtrHeadInt64NilMultiFields { - name: "PtrHeadInt64NilMultiFields", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt64NilMultiFields", data: (*struct { A *int64 `json:"a"` B *int64 `json:"b"` })(nil), }, { - name: "PtrHeadInt64NilMultiFieldsOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt64NilMultiFieldsOmitEmpty", data: (*struct { A *int64 `json:"a,omitempty"` B *int64 `json:"b,omitempty"` })(nil), }, { - name: "PtrHeadInt64NilMultiFieldsString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt64NilMultiFieldsString", data: (*struct { A *int64 `json:"a,string"` B *int64 `json:"b,string"` @@ -740,15 +433,7 @@ null // HeadInt64ZeroNotRoot { - name: "HeadInt64ZeroNotRoot", - expected: `{"A":{"a":0}}`, - indentExpected: ` -{ - "A": { - "a": 0 - } -} -`, + name: "HeadInt64ZeroNotRoot", data: struct { A struct { A int64 `json:"a"` @@ -756,13 +441,7 @@ null }{}, }, { - name: "HeadInt64ZeroNotRootOmitEmpty", - expected: `{"A":{}}`, - indentExpected: ` -{ - "A": {} -} -`, + name: "HeadInt64ZeroNotRootOmitEmpty", data: struct { A struct { A int64 `json:"a,omitempty"` @@ -770,15 +449,7 @@ null }{}, }, { - name: "HeadInt64ZeroNotRootString", - expected: `{"A":{"a":"0"}}`, - indentExpected: ` -{ - "A": { - "a": "0" - } -} -`, + name: "HeadInt64ZeroNotRootString", data: struct { A struct { A int64 `json:"a,string"` @@ -788,15 +459,7 @@ null // HeadInt64NotRoot { - name: "HeadInt64NotRoot", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "HeadInt64NotRoot", data: struct { A struct { A int64 `json:"a"` @@ -806,15 +469,7 @@ null }{A: 1}}, }, { - name: "HeadInt64NotRootOmitEmpty", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "HeadInt64NotRootOmitEmpty", data: struct { A struct { A int64 `json:"a,omitempty"` @@ -824,15 +479,7 @@ null }{A: 1}}, }, { - name: "HeadInt64NotRootString", - expected: `{"A":{"a":"1"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - } -} -`, + name: "HeadInt64NotRootString", data: struct { A struct { A int64 `json:"a,string"` @@ -844,15 +491,7 @@ null // HeadInt64PtrNotRoot { - name: "HeadInt64PtrNotRoot", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "HeadInt64PtrNotRoot", data: struct { A struct { A *int64 `json:"a"` @@ -862,15 +501,7 @@ null }{int64ptr(1)}}, }, { - name: "HeadInt64PtrNotRootOmitEmpty", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "HeadInt64PtrNotRootOmitEmpty", data: struct { A struct { A *int64 `json:"a,omitempty"` @@ -880,15 +511,7 @@ null }{int64ptr(1)}}, }, { - name: "HeadInt64PtrNotRootString", - expected: `{"A":{"a":"1"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - } -} -`, + name: "HeadInt64PtrNotRootString", data: struct { A struct { A *int64 `json:"a,string"` @@ -900,15 +523,7 @@ null // HeadInt64PtrNilNotRoot { - name: "HeadInt64PtrNilNotRoot", - expected: `{"A":{"a":null}}`, - indentExpected: ` -{ - "A": { - "a": null - } -} -`, + name: "HeadInt64PtrNilNotRoot", data: struct { A struct { A *int64 `json:"a"` @@ -916,13 +531,7 @@ null }{}, }, { - name: "HeadInt64PtrNilNotRootOmitEmpty", - expected: `{"A":{}}`, - indentExpected: ` -{ - "A": {} -} -`, + name: "HeadInt64PtrNilNotRootOmitEmpty", data: struct { A struct { A *int64 `json:"a,omitempty"` @@ -930,15 +539,7 @@ null }{}, }, { - name: "HeadInt64PtrNilNotRootString", - expected: `{"A":{"a":null}}`, - indentExpected: ` -{ - "A": { - "a": null - } -} -`, + name: "HeadInt64PtrNilNotRootString", data: struct { A struct { A *int64 `json:"a,string"` @@ -948,15 +549,7 @@ null // PtrHeadInt64ZeroNotRoot { - name: "PtrHeadInt64ZeroNotRoot", - expected: `{"A":{"a":0}}`, - indentExpected: ` -{ - "A": { - "a": 0 - } -} -`, + name: "PtrHeadInt64ZeroNotRoot", data: struct { A *struct { A int64 `json:"a"` @@ -966,13 +559,7 @@ null })}, }, { - name: "PtrHeadInt64ZeroNotRootOmitEmpty", - expected: `{"A":{}}`, - indentExpected: ` -{ - "A": {} -} -`, + name: "PtrHeadInt64ZeroNotRootOmitEmpty", data: struct { A *struct { A int64 `json:"a,omitempty"` @@ -982,15 +569,7 @@ null })}, }, { - name: "PtrHeadInt64ZeroNotRootString", - expected: `{"A":{"a":"0"}}`, - indentExpected: ` -{ - "A": { - "a": "0" - } -} -`, + name: "PtrHeadInt64ZeroNotRootString", data: struct { A *struct { A int64 `json:"a,string"` @@ -1002,15 +581,7 @@ null // PtrHeadInt64NotRoot { - name: "PtrHeadInt64NotRoot", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "PtrHeadInt64NotRoot", data: struct { A *struct { A int64 `json:"a"` @@ -1020,15 +591,7 @@ null }{A: 1})}, }, { - name: "PtrHeadInt64NotRootOmitEmpty", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "PtrHeadInt64NotRootOmitEmpty", data: struct { A *struct { A int64 `json:"a,omitempty"` @@ -1038,15 +601,7 @@ null }{A: 1})}, }, { - name: "PtrHeadInt64NotRootString", - expected: `{"A":{"a":"1"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - } -} -`, + name: "PtrHeadInt64NotRootString", data: struct { A *struct { A int64 `json:"a,string"` @@ -1058,15 +613,7 @@ null // PtrHeadInt64PtrNotRoot { - name: "PtrHeadInt64PtrNotRoot", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "PtrHeadInt64PtrNotRoot", data: struct { A *struct { A *int64 `json:"a"` @@ -1076,15 +623,7 @@ null }{A: int64ptr(1)})}, }, { - name: "PtrHeadInt64PtrNotRootOmitEmpty", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "PtrHeadInt64PtrNotRootOmitEmpty", data: struct { A *struct { A *int64 `json:"a,omitempty"` @@ -1094,15 +633,7 @@ null }{A: int64ptr(1)})}, }, { - name: "PtrHeadInt64PtrNotRootString", - expected: `{"A":{"a":"1"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - } -} -`, + name: "PtrHeadInt64PtrNotRootString", data: struct { A *struct { A *int64 `json:"a,string"` @@ -1114,15 +645,7 @@ null // PtrHeadInt64PtrNilNotRoot { - name: "PtrHeadInt64PtrNilNotRoot", - expected: `{"A":{"a":null}}`, - indentExpected: ` -{ - "A": { - "a": null - } -} -`, + name: "PtrHeadInt64PtrNilNotRoot", data: struct { A *struct { A *int64 `json:"a"` @@ -1132,13 +655,7 @@ null }{A: nil})}, }, { - name: "PtrHeadInt64PtrNilNotRootOmitEmpty", - expected: `{"A":{}}`, - indentExpected: ` -{ - "A": {} -} -`, + name: "PtrHeadInt64PtrNilNotRootOmitEmpty", data: struct { A *struct { A *int64 `json:"a,omitempty"` @@ -1148,15 +665,7 @@ null }{A: nil})}, }, { - name: "PtrHeadInt64PtrNilNotRootString", - expected: `{"A":{"a":null}}`, - indentExpected: ` -{ - "A": { - "a": null - } -} -`, + name: "PtrHeadInt64PtrNilNotRootString", data: struct { A *struct { A *int64 `json:"a,string"` @@ -1168,13 +677,7 @@ null // PtrHeadInt64NilNotRoot { - name: "PtrHeadInt64NilNotRoot", - expected: `{"A":null}`, - indentExpected: ` -{ - "A": null -} -`, + name: "PtrHeadInt64NilNotRoot", data: struct { A *struct { A *int64 `json:"a"` @@ -1182,11 +685,7 @@ null }{A: nil}, }, { - name: "PtrHeadInt64NilNotRootOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadInt64NilNotRootOmitEmpty", data: struct { A *struct { A *int64 `json:"a,omitempty"` @@ -1194,13 +693,7 @@ null }{A: nil}, }, { - name: "PtrHeadInt64NilNotRootString", - expected: `{"A":null}`, - indentExpected: ` -{ - "A": null -} -`, + name: "PtrHeadInt64NilNotRootString", data: struct { A *struct { A *int64 `json:"a,string"` @@ -1210,18 +703,7 @@ null // HeadInt64ZeroMultiFieldsNotRoot { - name: "HeadInt64ZeroMultiFieldsNotRoot", - expected: `{"A":{"a":0},"B":{"b":0}}`, - indentExpected: ` -{ - "A": { - "a": 0 - }, - "B": { - "b": 0 - } -} -`, + name: "HeadInt64ZeroMultiFieldsNotRoot", data: struct { A struct { A int64 `json:"a"` @@ -1232,14 +714,7 @@ null }{}, }, { - name: "HeadInt64ZeroMultiFieldsNotRootOmitEmpty", - expected: `{"A":{},"B":{}}`, - indentExpected: ` -{ - "A": {}, - "B": {} -} -`, + name: "HeadInt64ZeroMultiFieldsNotRootOmitEmpty", data: struct { A struct { A int64 `json:"a,omitempty"` @@ -1250,18 +725,7 @@ null }{}, }, { - name: "HeadInt64ZeroMultiFieldsNotRootString", - expected: `{"A":{"a":"0"},"B":{"b":"0"}}`, - indentExpected: ` -{ - "A": { - "a": "0" - }, - "B": { - "b": "0" - } -} -`, + name: "HeadInt64ZeroMultiFieldsNotRootString", data: struct { A struct { A int64 `json:"a,string"` @@ -1274,18 +738,7 @@ null // HeadInt64MultiFieldsNotRoot { - name: "HeadInt64MultiFieldsNotRoot", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "HeadInt64MultiFieldsNotRoot", data: struct { A struct { A int64 `json:"a"` @@ -1300,18 +753,7 @@ null }{B: 2}}, }, { - name: "HeadInt64MultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "HeadInt64MultiFieldsNotRootOmitEmpty", data: struct { A struct { A int64 `json:"a,omitempty"` @@ -1326,18 +768,7 @@ null }{B: 2}}, }, { - name: "HeadInt64MultiFieldsNotRootString", - expected: `{"A":{"a":"1"},"B":{"b":"2"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - }, - "B": { - "b": "2" - } -} -`, + name: "HeadInt64MultiFieldsNotRootString", data: struct { A struct { A int64 `json:"a,string"` @@ -1354,18 +785,7 @@ null // HeadInt64PtrMultiFieldsNotRoot { - name: "HeadInt64PtrMultiFieldsNotRoot", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "HeadInt64PtrMultiFieldsNotRoot", data: struct { A struct { A *int64 `json:"a"` @@ -1380,18 +800,7 @@ null }{B: int64ptr(2)}}, }, { - name: "HeadInt64PtrMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "HeadInt64PtrMultiFieldsNotRootOmitEmpty", data: struct { A struct { A *int64 `json:"a,omitempty"` @@ -1406,18 +815,7 @@ null }{B: int64ptr(2)}}, }, { - name: "HeadInt64PtrMultiFieldsNotRootString", - expected: `{"A":{"a":"1"},"B":{"b":"2"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - }, - "B": { - "b": "2" - } -} -`, + name: "HeadInt64PtrMultiFieldsNotRootString", data: struct { A struct { A *int64 `json:"a,string"` @@ -1434,18 +832,7 @@ null // HeadInt64PtrNilMultiFieldsNotRoot { - name: "HeadInt64PtrNilMultiFieldsNotRoot", - expected: `{"A":{"a":null},"B":{"b":null}}`, - indentExpected: ` -{ - "A": { - "a": null - }, - "B": { - "b": null - } -} -`, + name: "HeadInt64PtrNilMultiFieldsNotRoot", data: struct { A struct { A *int64 `json:"a"` @@ -1460,14 +847,7 @@ null }{B: nil}}, }, { - name: "HeadInt64PtrNilMultiFieldsNotRootOmitEmpty", - expected: `{"A":{},"B":{}}`, - indentExpected: ` -{ - "A": {}, - "B": {} -} -`, + name: "HeadInt64PtrNilMultiFieldsNotRootOmitEmpty", data: struct { A struct { A *int64 `json:"a,omitempty"` @@ -1482,18 +862,7 @@ null }{B: nil}}, }, { - name: "HeadInt64PtrNilMultiFieldsNotRootString", - expected: `{"A":{"a":null},"B":{"b":null}}`, - indentExpected: ` -{ - "A": { - "a": null - }, - "B": { - "b": null - } -} -`, + name: "HeadInt64PtrNilMultiFieldsNotRootString", data: struct { A struct { A *int64 `json:"a,string"` @@ -1510,18 +879,7 @@ null // PtrHeadInt64ZeroMultiFieldsNotRoot { - name: "PtrHeadInt64ZeroMultiFieldsNotRoot", - expected: `{"A":{"a":0},"B":{"b":0}}`, - indentExpected: ` -{ - "A": { - "a": 0 - }, - "B": { - "b": 0 - } -} -`, + name: "PtrHeadInt64ZeroMultiFieldsNotRoot", data: &struct { A struct { A int64 `json:"a"` @@ -1532,14 +890,7 @@ null }{}, }, { - name: "PtrHeadInt64ZeroMultiFieldsNotRootOmitEmpty", - expected: `{"A":{},"B":{}}`, - indentExpected: ` -{ - "A": {}, - "B": {} -} -`, + name: "PtrHeadInt64ZeroMultiFieldsNotRootOmitEmpty", data: &struct { A struct { A int64 `json:"a,omitempty"` @@ -1550,18 +901,7 @@ null }{}, }, { - name: "PtrHeadInt64ZeroMultiFieldsNotRootString", - expected: `{"A":{"a":"0"},"B":{"b":"0"}}`, - indentExpected: ` -{ - "A": { - "a": "0" - }, - "B": { - "b": "0" - } -} -`, + name: "PtrHeadInt64ZeroMultiFieldsNotRootString", data: &struct { A struct { A int64 `json:"a,string"` @@ -1574,18 +914,7 @@ null // PtrHeadInt64MultiFieldsNotRoot { - name: "PtrHeadInt64MultiFieldsNotRoot", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "PtrHeadInt64MultiFieldsNotRoot", data: &struct { A struct { A int64 `json:"a"` @@ -1600,18 +929,7 @@ null }{B: 2}}, }, { - name: "PtrHeadInt64MultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "PtrHeadInt64MultiFieldsNotRootOmitEmpty", data: &struct { A struct { A int64 `json:"a,omitempty"` @@ -1626,18 +944,7 @@ null }{B: 2}}, }, { - name: "PtrHeadInt64MultiFieldsNotRootString", - expected: `{"A":{"a":"1"},"B":{"b":"2"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - }, - "B": { - "b": "2" - } -} -`, + name: "PtrHeadInt64MultiFieldsNotRootString", data: &struct { A struct { A int64 `json:"a,string"` @@ -1654,18 +961,7 @@ null // PtrHeadInt64PtrMultiFieldsNotRoot { - name: "PtrHeadInt64PtrMultiFieldsNotRoot", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "PtrHeadInt64PtrMultiFieldsNotRoot", data: &struct { A *struct { A *int64 `json:"a"` @@ -1680,18 +976,7 @@ null }{B: int64ptr(2)})}, }, { - name: "PtrHeadInt64PtrMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "PtrHeadInt64PtrMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A *int64 `json:"a,omitempty"` @@ -1706,18 +991,7 @@ null }{B: int64ptr(2)})}, }, { - name: "PtrHeadInt64PtrMultiFieldsNotRootString", - expected: `{"A":{"a":"1"},"B":{"b":"2"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - }, - "B": { - "b": "2" - } -} -`, + name: "PtrHeadInt64PtrMultiFieldsNotRootString", data: &struct { A *struct { A *int64 `json:"a,string"` @@ -1734,14 +1008,7 @@ null // PtrHeadInt64PtrNilMultiFieldsNotRoot { - name: "PtrHeadInt64PtrNilMultiFieldsNotRoot", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadInt64PtrNilMultiFieldsNotRoot", data: &struct { A *struct { A *int64 `json:"a"` @@ -1752,11 +1019,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadInt64PtrNilMultiFieldsNotRootOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadInt64PtrNilMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A *int64 `json:"a,omitempty"` @@ -1767,14 +1030,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadInt64PtrNilMultiFieldsNotRootString", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadInt64PtrNilMultiFieldsNotRootString", data: &struct { A *struct { A *int64 `json:"a,string"` @@ -1787,11 +1043,7 @@ null // PtrHeadInt64NilMultiFieldsNotRoot { - name: "PtrHeadInt64NilMultiFieldsNotRoot", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt64NilMultiFieldsNotRoot", data: (*struct { A *struct { A *int64 `json:"a"` @@ -1802,11 +1054,7 @@ null })(nil), }, { - name: "PtrHeadInt64NilMultiFieldsNotRootOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt64NilMultiFieldsNotRootOmitEmpty", data: (*struct { A *struct { A *int64 `json:"a,omitempty"` @@ -1817,11 +1065,7 @@ null })(nil), }, { - name: "PtrHeadInt64NilMultiFieldsNotRootString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt64NilMultiFieldsNotRootString", data: (*struct { A *struct { A *int64 `json:"a,string"` @@ -1834,20 +1078,7 @@ null // PtrHeadInt64DoubleMultiFieldsNotRoot { - name: "PtrHeadInt64DoubleMultiFieldsNotRoot", - expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`, - indentExpected: ` -{ - "A": { - "a": 1, - "b": 2 - }, - "B": { - "a": 3, - "b": 4 - } -} -`, + name: "PtrHeadInt64DoubleMultiFieldsNotRoot", data: &struct { A *struct { A int64 `json:"a"` @@ -1866,20 +1097,7 @@ null }{A: 3, B: 4})}, }, { - name: "PtrHeadInt64DoubleMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`, - indentExpected: ` -{ - "A": { - "a": 1, - "b": 2 - }, - "B": { - "a": 3, - "b": 4 - } -} -`, + name: "PtrHeadInt64DoubleMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A int64 `json:"a,omitempty"` @@ -1898,20 +1116,7 @@ null }{A: 3, B: 4})}, }, { - name: "PtrHeadInt64DoubleMultiFieldsNotRootString", - expected: `{"A":{"a":"1","b":"2"},"B":{"a":"3","b":"4"}}`, - indentExpected: ` -{ - "A": { - "a": "1", - "b": "2" - }, - "B": { - "a": "3", - "b": "4" - } -} -`, + name: "PtrHeadInt64DoubleMultiFieldsNotRootString", data: &struct { A *struct { A int64 `json:"a,string"` @@ -1932,14 +1137,7 @@ null // PtrHeadInt64NilDoubleMultiFieldsNotRoot { - name: "PtrHeadInt64NilDoubleMultiFieldsNotRoot", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadInt64NilDoubleMultiFieldsNotRoot", data: &struct { A *struct { A int64 `json:"a"` @@ -1952,11 +1150,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadInt64NilDoubleMultiFieldsNotRootOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadInt64NilDoubleMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A int64 `json:"a,omitempty"` @@ -1969,14 +1163,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadInt64NilDoubleMultiFieldsNotRootString", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadInt64NilDoubleMultiFieldsNotRootString", data: &struct { A *struct { A int64 `json:"a,string"` @@ -1991,11 +1178,7 @@ null // PtrHeadInt64NilDoubleMultiFieldsNotRoot { - name: "PtrHeadInt64NilDoubleMultiFieldsNotRoot", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt64NilDoubleMultiFieldsNotRoot", data: (*struct { A *struct { A int64 `json:"a"` @@ -2008,11 +1191,7 @@ null })(nil), }, { - name: "PtrHeadInt64NilDoubleMultiFieldsNotRootOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt64NilDoubleMultiFieldsNotRootOmitEmpty", data: (*struct { A *struct { A int64 `json:"a,omitempty"` @@ -2025,11 +1204,7 @@ null })(nil), }, { - name: "PtrHeadInt64NilDoubleMultiFieldsNotRootString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt64NilDoubleMultiFieldsNotRootString", data: (*struct { A *struct { A int64 `json:"a,string"` @@ -2044,20 +1219,7 @@ null // PtrHeadInt64PtrDoubleMultiFieldsNotRoot { - name: "PtrHeadInt64PtrDoubleMultiFieldsNotRoot", - expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`, - indentExpected: ` -{ - "A": { - "a": 1, - "b": 2 - }, - "B": { - "a": 3, - "b": 4 - } -} -`, + name: "PtrHeadInt64PtrDoubleMultiFieldsNotRoot", data: &struct { A *struct { A *int64 `json:"a"` @@ -2076,20 +1238,7 @@ null }{A: int64ptr(3), B: int64ptr(4)})}, }, { - name: "PtrHeadInt64PtrDoubleMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`, - indentExpected: ` -{ - "A": { - "a": 1, - "b": 2 - }, - "B": { - "a": 3, - "b": 4 - } -} -`, + name: "PtrHeadInt64PtrDoubleMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A *int64 `json:"a,omitempty"` @@ -2108,20 +1257,7 @@ null }{A: int64ptr(3), B: int64ptr(4)})}, }, { - name: "PtrHeadInt64PtrDoubleMultiFieldsNotRootString", - expected: `{"A":{"a":"1","b":"2"},"B":{"a":"3","b":"4"}}`, - indentExpected: ` -{ - "A": { - "a": "1", - "b": "2" - }, - "B": { - "a": "3", - "b": "4" - } -} -`, + name: "PtrHeadInt64PtrDoubleMultiFieldsNotRootString", data: &struct { A *struct { A *int64 `json:"a,string"` @@ -2142,14 +1278,7 @@ null // PtrHeadInt64PtrNilDoubleMultiFieldsNotRoot { - name: "PtrHeadInt64PtrNilDoubleMultiFieldsNotRoot", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadInt64PtrNilDoubleMultiFieldsNotRoot", data: &struct { A *struct { A *int64 `json:"a"` @@ -2162,11 +1291,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadInt64PtrNilDoubleMultiFieldsNotRootOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadInt64PtrNilDoubleMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A *int64 `json:"a,omitempty"` @@ -2179,14 +1304,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadInt64PtrNilDoubleMultiFieldsNotRootString", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadInt64PtrNilDoubleMultiFieldsNotRootString", data: &struct { A *struct { A *int64 `json:"a,string"` @@ -2201,11 +1319,7 @@ null // PtrHeadInt64PtrNilDoubleMultiFieldsNotRoot { - name: "PtrHeadInt64PtrNilDoubleMultiFieldsNotRoot", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt64PtrNilDoubleMultiFieldsNotRoot", data: (*struct { A *struct { A *int64 `json:"a"` @@ -2218,11 +1332,7 @@ null })(nil), }, { - name: "PtrHeadInt64PtrNilDoubleMultiFieldsNotRootOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt64PtrNilDoubleMultiFieldsNotRootOmitEmpty", data: (*struct { A *struct { A *int64 `json:"a,omitempty"` @@ -2235,11 +1345,7 @@ null })(nil), }, { - name: "PtrHeadInt64PtrNilDoubleMultiFieldsNotRootString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadInt64PtrNilDoubleMultiFieldsNotRootString", data: (*struct { A *struct { A *int64 `json:"a,string"` @@ -2254,14 +1360,7 @@ null // AnonymousHeadInt64 { - name: "AnonymousHeadInt64", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "AnonymousHeadInt64", data: struct { structInt64 B int64 `json:"b"` @@ -2271,14 +1370,7 @@ null }, }, { - name: "AnonymousHeadInt64OmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "AnonymousHeadInt64OmitEmpty", data: struct { structInt64OmitEmpty B int64 `json:"b,omitempty"` @@ -2288,14 +1380,7 @@ null }, }, { - name: "AnonymousHeadInt64String", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "AnonymousHeadInt64String", data: struct { structInt64String B int64 `json:"b,string"` @@ -2307,14 +1392,7 @@ null // PtrAnonymousHeadInt64 { - name: "PtrAnonymousHeadInt64", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrAnonymousHeadInt64", data: struct { *structInt64 B int64 `json:"b"` @@ -2324,14 +1402,7 @@ null }, }, { - name: "PtrAnonymousHeadInt64OmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrAnonymousHeadInt64OmitEmpty", data: struct { *structInt64OmitEmpty B int64 `json:"b,omitempty"` @@ -2341,14 +1412,7 @@ null }, }, { - name: "PtrAnonymousHeadInt64String", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "PtrAnonymousHeadInt64String", data: struct { *structInt64String B int64 `json:"b,string"` @@ -2360,13 +1424,7 @@ null // NilPtrAnonymousHeadInt64 { - name: "NilPtrAnonymousHeadInt64", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "NilPtrAnonymousHeadInt64", data: struct { *structInt64 B int64 `json:"b"` @@ -2376,13 +1434,7 @@ null }, }, { - name: "NilPtrAnonymousHeadInt64OmitEmpty", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "NilPtrAnonymousHeadInt64OmitEmpty", data: struct { *structInt64OmitEmpty B int64 `json:"b,omitempty"` @@ -2392,13 +1444,7 @@ null }, }, { - name: "NilPtrAnonymousHeadInt64String", - expected: `{"b":"2"}`, - indentExpected: ` -{ - "b": "2" -} -`, + name: "NilPtrAnonymousHeadInt64String", data: struct { *structInt64String B int64 `json:"b,string"` @@ -2410,14 +1456,7 @@ null // AnonymousHeadInt64Ptr { - name: "AnonymousHeadInt64Ptr", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "AnonymousHeadInt64Ptr", data: struct { structInt64Ptr B *int64 `json:"b"` @@ -2427,14 +1466,7 @@ null }, }, { - name: "AnonymousHeadInt64PtrOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "AnonymousHeadInt64PtrOmitEmpty", data: struct { structInt64PtrOmitEmpty B *int64 `json:"b,omitempty"` @@ -2444,14 +1476,7 @@ null }, }, { - name: "AnonymousHeadInt64PtrString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "AnonymousHeadInt64PtrString", data: struct { structInt64PtrString B *int64 `json:"b,string"` @@ -2463,14 +1488,7 @@ null // AnonymousHeadInt64PtrNil { - name: "AnonymousHeadInt64PtrNil", - expected: `{"a":null,"b":2}`, - indentExpected: ` -{ - "a": null, - "b": 2 -} -`, + name: "AnonymousHeadInt64PtrNil", data: struct { structInt64Ptr B *int64 `json:"b"` @@ -2480,13 +1498,7 @@ null }, }, { - name: "AnonymousHeadInt64PtrNilOmitEmpty", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "AnonymousHeadInt64PtrNilOmitEmpty", data: struct { structInt64PtrOmitEmpty B *int64 `json:"b,omitempty"` @@ -2496,14 +1508,7 @@ null }, }, { - name: "AnonymousHeadInt64PtrNilString", - expected: `{"a":null,"b":"2"}`, - indentExpected: ` -{ - "a": null, - "b": "2" -} -`, + name: "AnonymousHeadInt64PtrNilString", data: struct { structInt64PtrString B *int64 `json:"b,string"` @@ -2515,14 +1520,7 @@ null // PtrAnonymousHeadInt64Ptr { - name: "PtrAnonymousHeadInt64Ptr", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrAnonymousHeadInt64Ptr", data: struct { *structInt64Ptr B *int64 `json:"b"` @@ -2532,14 +1530,7 @@ null }, }, { - name: "PtrAnonymousHeadInt64PtrOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrAnonymousHeadInt64PtrOmitEmpty", data: struct { *structInt64PtrOmitEmpty B *int64 `json:"b,omitempty"` @@ -2549,14 +1540,7 @@ null }, }, { - name: "PtrAnonymousHeadInt64PtrString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "PtrAnonymousHeadInt64PtrString", data: struct { *structInt64PtrString B *int64 `json:"b,string"` @@ -2568,13 +1552,7 @@ null // NilPtrAnonymousHeadInt64Ptr { - name: "NilPtrAnonymousHeadInt64Ptr", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "NilPtrAnonymousHeadInt64Ptr", data: struct { *structInt64Ptr B *int64 `json:"b"` @@ -2584,13 +1562,7 @@ null }, }, { - name: "NilPtrAnonymousHeadInt64PtrOmitEmpty", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "NilPtrAnonymousHeadInt64PtrOmitEmpty", data: struct { *structInt64PtrOmitEmpty B *int64 `json:"b,omitempty"` @@ -2600,13 +1572,7 @@ null }, }, { - name: "NilPtrAnonymousHeadInt64PtrString", - expected: `{"b":"2"}`, - indentExpected: ` -{ - "b": "2" -} -`, + name: "NilPtrAnonymousHeadInt64PtrString", data: struct { *structInt64PtrString B *int64 `json:"b,string"` @@ -2618,13 +1584,7 @@ null // AnonymousHeadInt64Only { - name: "AnonymousHeadInt64Only", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "AnonymousHeadInt64Only", data: struct { structInt64 }{ @@ -2632,13 +1592,7 @@ null }, }, { - name: "AnonymousHeadInt64OnlyOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "AnonymousHeadInt64OnlyOmitEmpty", data: struct { structInt64OmitEmpty }{ @@ -2646,13 +1600,7 @@ null }, }, { - name: "AnonymousHeadInt64OnlyString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "AnonymousHeadInt64OnlyString", data: struct { structInt64String }{ @@ -2662,13 +1610,7 @@ null // PtrAnonymousHeadInt64Only { - name: "PtrAnonymousHeadInt64Only", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrAnonymousHeadInt64Only", data: struct { *structInt64 }{ @@ -2676,13 +1618,7 @@ null }, }, { - name: "PtrAnonymousHeadInt64OnlyOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrAnonymousHeadInt64OnlyOmitEmpty", data: struct { *structInt64OmitEmpty }{ @@ -2690,13 +1626,7 @@ null }, }, { - name: "PtrAnonymousHeadInt64OnlyString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "PtrAnonymousHeadInt64OnlyString", data: struct { *structInt64String }{ @@ -2706,11 +1636,7 @@ null // NilPtrAnonymousHeadInt64Only { - name: "NilPtrAnonymousHeadInt64Only", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadInt64Only", data: struct { *structInt64 }{ @@ -2718,11 +1644,7 @@ null }, }, { - name: "NilPtrAnonymousHeadInt64OnlyOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadInt64OnlyOmitEmpty", data: struct { *structInt64OmitEmpty }{ @@ -2730,11 +1652,7 @@ null }, }, { - name: "NilPtrAnonymousHeadInt64OnlyString", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadInt64OnlyString", data: struct { *structInt64String }{ @@ -2744,13 +1662,7 @@ null // AnonymousHeadInt64PtrOnly { - name: "AnonymousHeadInt64PtrOnly", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "AnonymousHeadInt64PtrOnly", data: struct { structInt64Ptr }{ @@ -2758,13 +1670,7 @@ null }, }, { - name: "AnonymousHeadInt64PtrOnlyOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "AnonymousHeadInt64PtrOnlyOmitEmpty", data: struct { structInt64PtrOmitEmpty }{ @@ -2772,13 +1678,7 @@ null }, }, { - name: "AnonymousHeadInt64PtrOnlyString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "AnonymousHeadInt64PtrOnlyString", data: struct { structInt64PtrString }{ @@ -2788,13 +1688,7 @@ null // AnonymousHeadInt64PtrNilOnly { - name: "AnonymousHeadInt64PtrNilOnly", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "AnonymousHeadInt64PtrNilOnly", data: struct { structInt64Ptr }{ @@ -2802,11 +1696,7 @@ null }, }, { - name: "AnonymousHeadInt64PtrNilOnlyOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "AnonymousHeadInt64PtrNilOnlyOmitEmpty", data: struct { structInt64PtrOmitEmpty }{ @@ -2814,13 +1704,7 @@ null }, }, { - name: "AnonymousHeadInt64PtrNilOnlyString", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "AnonymousHeadInt64PtrNilOnlyString", data: struct { structInt64PtrString }{ @@ -2830,13 +1714,7 @@ null // PtrAnonymousHeadInt64PtrOnly { - name: "PtrAnonymousHeadInt64PtrOnly", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrAnonymousHeadInt64PtrOnly", data: struct { *structInt64Ptr }{ @@ -2844,13 +1722,7 @@ null }, }, { - name: "PtrAnonymousHeadInt64PtrOnlyOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrAnonymousHeadInt64PtrOnlyOmitEmpty", data: struct { *structInt64PtrOmitEmpty }{ @@ -2858,13 +1730,7 @@ null }, }, { - name: "PtrAnonymousHeadInt64PtrOnlyString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "PtrAnonymousHeadInt64PtrOnlyString", data: struct { *structInt64PtrString }{ @@ -2874,11 +1740,7 @@ null // NilPtrAnonymousHeadInt64PtrOnly { - name: "NilPtrAnonymousHeadInt64PtrOnly", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadInt64PtrOnly", data: struct { *structInt64Ptr }{ @@ -2886,11 +1748,7 @@ null }, }, { - name: "NilPtrAnonymousHeadInt64PtrOnlyOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadInt64PtrOnlyOmitEmpty", data: struct { *structInt64PtrOmitEmpty }{ @@ -2898,11 +1756,7 @@ null }, }, { - name: "NilPtrAnonymousHeadInt64PtrOnlyString", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadInt64PtrOnlyString", data: struct { *structInt64PtrString }{ @@ -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()) - } - } } } } From 4edf1b1d09dc5ddf0dea939c33c360b663e5baaf Mon Sep 17 00:00:00 2001 From: Masaaki Goshima Date: Mon, 15 Feb 2021 11:24:35 +0900 Subject: [PATCH 06/15] Refactor cover_uint_test.go --- cover_uint_test.go | 1540 ++++++-------------------------------------- 1 file changed, 192 insertions(+), 1348 deletions(-) diff --git a/cover_uint_test.go b/cover_uint_test.go index 6abf39c..46d1e0c 100644 --- a/cover_uint_test.go +++ b/cover_uint_test.go @@ -2,7 +2,6 @@ package json_test import ( "bytes" - "strings" "testing" "github.com/goccy/go-json" @@ -30,42 +29,24 @@ func TestCoverUint(t *testing.T) { } tests := []struct { - name string - expected string - indentExpected string - data interface{} + name string + data interface{} }{ // HeadUintZero { - name: "HeadUintZero", - expected: `{"a":0}`, - indentExpected: ` -{ - "a": 0 -} -`, + name: "HeadUintZero", data: struct { A uint `json:"a"` }{}, }, { - name: "HeadUintZeroOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "HeadUintZeroOmitEmpty", data: struct { A uint `json:"a,omitempty"` }{}, }, { - name: "HeadUintZeroString", - expected: `{"a":"0"}`, - indentExpected: ` -{ - "a": "0" -} -`, + name: "HeadUintZeroString", data: struct { A uint `json:"a,string"` }{}, @@ -73,37 +54,19 @@ func TestCoverUint(t *testing.T) { // HeadUint { - name: "HeadUint", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "HeadUint", data: struct { A uint `json:"a"` }{A: 1}, }, { - name: "HeadUintOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "HeadUintOmitEmpty", data: struct { A uint `json:"a,omitempty"` }{A: 1}, }, { - name: "HeadUintString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "HeadUintString", data: struct { A uint `json:"a,string"` }{A: 1}, @@ -111,37 +74,19 @@ func TestCoverUint(t *testing.T) { // HeadUintPtr { - name: "HeadUintPtr", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "HeadUintPtr", data: struct { A *uint `json:"a"` }{A: uptr(1)}, }, { - name: "HeadUintPtrOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "HeadUintPtrOmitEmpty", data: struct { A *uint `json:"a,omitempty"` }{A: uptr(1)}, }, { - name: "HeadUintPtrString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "HeadUintPtrString", data: struct { A *uint `json:"a,string"` }{A: uptr(1)}, @@ -149,35 +94,19 @@ func TestCoverUint(t *testing.T) { // HeadUintPtrNil { - name: "HeadUintPtrNil", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "HeadUintPtrNil", data: struct { A *uint `json:"a"` }{A: nil}, }, { - name: "HeadUintPtrNilOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "HeadUintPtrNilOmitEmpty", data: struct { A *uint `json:"a,omitempty"` }{A: nil}, }, { - name: "HeadUintPtrNilString", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "HeadUintPtrNilString", data: struct { A *uint `json:"a,string"` }{A: nil}, @@ -185,35 +114,19 @@ func TestCoverUint(t *testing.T) { // PtrHeadUintZero { - name: "PtrHeadUintZero", - expected: `{"a":0}`, - indentExpected: ` -{ - "a": 0 -} -`, + name: "PtrHeadUintZero", data: &struct { A uint `json:"a"` }{}, }, { - name: "PtrHeadUintZeroOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadUintZeroOmitEmpty", data: &struct { A uint `json:"a,omitempty"` }{}, }, { - name: "PtrHeadUintZeroString", - expected: `{"a":"0"}`, - indentExpected: ` -{ - "a": "0" -} -`, + name: "PtrHeadUintZeroString", data: &struct { A uint `json:"a,string"` }{}, @@ -221,37 +134,19 @@ func TestCoverUint(t *testing.T) { // PtrHeadUint { - name: "PtrHeadUint", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrHeadUint", data: &struct { A uint `json:"a"` }{A: 1}, }, { - name: "PtrHeadUintOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrHeadUintOmitEmpty", data: &struct { A uint `json:"a,omitempty"` }{A: 1}, }, { - name: "PtrHeadUintString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "PtrHeadUintString", data: &struct { A uint `json:"a,string"` }{A: 1}, @@ -259,37 +154,19 @@ func TestCoverUint(t *testing.T) { // PtrHeadUintPtr { - name: "PtrHeadUintPtr", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrHeadUintPtr", data: &struct { A *uint `json:"a"` }{A: uptr(1)}, }, { - name: "PtrHeadUintPtrOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrHeadUintPtrOmitEmpty", data: &struct { A *uint `json:"a,omitempty"` }{A: uptr(1)}, }, { - name: "PtrHeadUintPtrString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "PtrHeadUintPtrString", data: &struct { A *uint `json:"a,string"` }{A: uptr(1)}, @@ -297,35 +174,19 @@ func TestCoverUint(t *testing.T) { // PtrHeadUintPtrNil { - name: "PtrHeadUintPtrNil", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "PtrHeadUintPtrNil", data: &struct { A *uint `json:"a"` }{A: nil}, }, { - name: "PtrHeadUintPtrNilOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadUintPtrNilOmitEmpty", data: &struct { A *uint `json:"a,omitempty"` }{A: nil}, }, { - name: "PtrHeadUintPtrNilString", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "PtrHeadUintPtrNilString", data: &struct { A *uint `json:"a,string"` }{A: nil}, @@ -333,31 +194,19 @@ func TestCoverUint(t *testing.T) { // PtrHeadUintNil { - name: "PtrHeadUintNil", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUintNil", data: (*struct { A *uint `json:"a"` })(nil), }, { - name: "PtrHeadUintNilOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUintNilOmitEmpty", data: (*struct { A *uint `json:"a,omitempty"` })(nil), }, { - name: "PtrHeadUintNilString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUintNilString", data: (*struct { A *uint `json:"a,string"` })(nil), @@ -365,209 +214,125 @@ null // HeadUintZeroMultiFields { - name: "HeadUintZeroMultiFields", - expected: `{"a":0,"b":0}`, - indentExpected: ` -{ - "a": 0, - "b": 0 -} -`, + name: "HeadUintZeroMultiFields", data: struct { A uint `json:"a"` B uint `json:"b"` + C uint `json:"c"` }{}, }, { - name: "HeadUintZeroMultiFieldsOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "HeadUintZeroMultiFieldsOmitEmpty", data: struct { A uint `json:"a,omitempty"` B uint `json:"b,omitempty"` + C uint `json:"c,omitempty"` }{}, }, { - name: "HeadUintZeroMultiFields", - expected: `{"a":"0","b":"0"}`, - indentExpected: ` -{ - "a": "0", - "b": "0" -} -`, + name: "HeadUintZeroMultiFields", data: struct { A uint `json:"a,string"` B uint `json:"b,string"` + C uint `json:"c,string"` }{}, }, // HeadUintMultiFields { - name: "HeadUintMultiFields", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "HeadUintMultiFields", data: struct { A uint `json:"a"` B uint `json:"b"` - }{A: 1, B: 2}, + C uint `json:"c"` + }{A: 1, B: 2, C: 3}, }, { - name: "HeadUintMultiFieldsOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "HeadUintMultiFieldsOmitEmpty", data: struct { A uint `json:"a,omitempty"` B uint `json:"b,omitempty"` - }{A: 1, B: 2}, + C uint `json:"c,omitempty"` + }{A: 1, B: 2, C: 3}, }, { - name: "HeadUintMultiFieldsString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "HeadUintMultiFieldsString", data: struct { A uint `json:"a,string"` B uint `json:"b,string"` - }{A: 1, B: 2}, + C uint `json:"c,string"` + }{A: 1, B: 2, C: 3}, }, // HeadUintPtrMultiFields { - name: "HeadUintPtrMultiFields", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "HeadUintPtrMultiFields", data: struct { A *uint `json:"a"` B *uint `json:"b"` - }{A: uptr(1), B: uptr(2)}, + C *uint `json:"c"` + }{A: uptr(1), B: uptr(2), C: uptr(3)}, }, { - name: "HeadUintPtrMultiFieldsOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "HeadUintPtrMultiFieldsOmitEmpty", data: struct { A *uint `json:"a,omitempty"` B *uint `json:"b,omitempty"` - }{A: uptr(1), B: uptr(2)}, + C *uint `json:"c,omitempty"` + }{A: uptr(1), B: uptr(2), C: uptr(3)}, }, { - name: "HeadUintPtrMultiFieldsString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "HeadUintPtrMultiFieldsString", data: struct { A *uint `json:"a,string"` B *uint `json:"b,string"` - }{A: uptr(1), B: uptr(2)}, + C *uint `json:"c,string"` + }{A: uptr(1), B: uptr(2), C: uptr(3)}, }, // HeadUintPtrNilMultiFields { - name: "HeadUintPtrNilMultiFields", - expected: `{"a":null,"b":null}`, - indentExpected: ` -{ - "a": null, - "b": null -} -`, + name: "HeadUintPtrNilMultiFields", data: struct { A *uint `json:"a"` B *uint `json:"b"` - }{A: nil, B: nil}, + C *uint `json:"c"` + }{A: nil, B: nil, C: nil}, }, { - name: "HeadUintPtrNilMultiFieldsOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "HeadUintPtrNilMultiFieldsOmitEmpty", data: struct { A *uint `json:"a,omitempty"` B *uint `json:"b,omitempty"` - }{A: nil, B: nil}, + C *uint `json:"c,omitempty"` + }{A: nil, B: nil, C: nil}, }, { - name: "HeadUintPtrNilMultiFieldsString", - expected: `{"a":null,"b":null}`, - indentExpected: ` -{ - "a": null, - "b": null -} -`, + name: "HeadUintPtrNilMultiFieldsString", data: struct { A *uint `json:"a,string"` B *uint `json:"b,string"` - }{A: nil, B: nil}, + C *uint `json:"c,string"` + }{A: nil, B: nil, C: nil}, }, // PtrHeadUintZeroMultiFields { - name: "PtrHeadUintZeroMultiFields", - expected: `{"a":0,"b":0}`, - indentExpected: ` -{ - "a": 0, - "b": 0 -} -`, + name: "PtrHeadUintZeroMultiFields", data: &struct { A uint `json:"a"` B uint `json:"b"` }{}, }, { - name: "PtrHeadUintZeroMultiFieldsOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadUintZeroMultiFieldsOmitEmpty", data: &struct { A uint `json:"a,omitempty"` B uint `json:"b,omitempty"` }{}, }, { - name: "PtrHeadUintZeroMultiFieldsString", - expected: `{"a":"0","b":"0"}`, - indentExpected: ` -{ - "a": "0", - "b": "0" -} -`, + name: "PtrHeadUintZeroMultiFieldsString", data: &struct { A uint `json:"a,string"` B uint `json:"b,string"` @@ -576,42 +341,21 @@ null // PtrHeadUintMultiFields { - name: "PtrHeadUintMultiFields", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrHeadUintMultiFields", data: &struct { A uint `json:"a"` B uint `json:"b"` }{A: 1, B: 2}, }, { - name: "PtrHeadUintMultiFieldsOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrHeadUintMultiFieldsOmitEmpty", data: &struct { A uint `json:"a,omitempty"` B uint `json:"b,omitempty"` }{A: 1, B: 2}, }, { - name: "PtrHeadUintMultiFieldsString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "PtrHeadUintMultiFieldsString", data: &struct { A uint `json:"a,string"` B uint `json:"b,string"` @@ -620,42 +364,21 @@ null // PtrHeadUintPtrMultiFields { - name: "PtrHeadUintPtrMultiFields", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrHeadUintPtrMultiFields", data: &struct { A *uint `json:"a"` B *uint `json:"b"` }{A: uptr(1), B: uptr(2)}, }, { - name: "PtrHeadUintPtrMultiFieldsOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrHeadUintPtrMultiFieldsOmitEmpty", data: &struct { A *uint `json:"a,omitempty"` B *uint `json:"b,omitempty"` }{A: uptr(1), B: uptr(2)}, }, { - name: "PtrHeadUintPtrMultiFieldsString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "PtrHeadUintPtrMultiFieldsString", data: &struct { A *uint `json:"a,string"` B *uint `json:"b,string"` @@ -664,39 +387,21 @@ null // PtrHeadUintPtrNilMultiFields { - name: "PtrHeadUintPtrNilMultiFields", - expected: `{"a":null,"b":null}`, - indentExpected: ` -{ - "a": null, - "b": null -} -`, + name: "PtrHeadUintPtrNilMultiFields", data: &struct { A *uint `json:"a"` B *uint `json:"b"` }{A: nil, B: nil}, }, { - name: "PtrHeadUintPtrNilMultiFieldsOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadUintPtrNilMultiFieldsOmitEmpty", data: &struct { A *uint `json:"a,omitempty"` B *uint `json:"b,omitempty"` }{A: nil, B: nil}, }, { - name: "PtrHeadUintPtrNilMultiFieldsString", - expected: `{"a":null,"b":null}`, - indentExpected: ` -{ - "a": null, - "b": null -} -`, + name: "PtrHeadUintPtrNilMultiFieldsString", data: &struct { A *uint `json:"a,string"` B *uint `json:"b,string"` @@ -705,33 +410,21 @@ null // PtrHeadUintNilMultiFields { - name: "PtrHeadUintNilMultiFields", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUintNilMultiFields", data: (*struct { A *uint `json:"a"` B *uint `json:"b"` })(nil), }, { - name: "PtrHeadUintNilMultiFieldsOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUintNilMultiFieldsOmitEmpty", data: (*struct { A *uint `json:"a,omitempty"` B *uint `json:"b,omitempty"` })(nil), }, { - name: "PtrHeadUintNilMultiFieldsString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUintNilMultiFieldsString", data: (*struct { A *uint `json:"a,string"` B *uint `json:"b,string"` @@ -740,15 +433,7 @@ null // HeadUintZeroNotRoot { - name: "HeadUintZeroNotRoot", - expected: `{"A":{"a":0}}`, - indentExpected: ` -{ - "A": { - "a": 0 - } -} -`, + name: "HeadUintZeroNotRoot", data: struct { A struct { A uint `json:"a"` @@ -756,13 +441,7 @@ null }{}, }, { - name: "HeadUintZeroNotRootOmitEmpty", - expected: `{"A":{}}`, - indentExpected: ` -{ - "A": {} -} -`, + name: "HeadUintZeroNotRootOmitEmpty", data: struct { A struct { A uint `json:"a,omitempty"` @@ -770,15 +449,7 @@ null }{}, }, { - name: "HeadUintZeroNotRootString", - expected: `{"A":{"a":"0"}}`, - indentExpected: ` -{ - "A": { - "a": "0" - } -} -`, + name: "HeadUintZeroNotRootString", data: struct { A struct { A uint `json:"a,string"` @@ -788,15 +459,7 @@ null // HeadUintNotRoot { - name: "HeadUintNotRoot", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "HeadUintNotRoot", data: struct { A struct { A uint `json:"a"` @@ -806,15 +469,7 @@ null }{A: 1}}, }, { - name: "HeadUintNotRootOmitEmpty", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "HeadUintNotRootOmitEmpty", data: struct { A struct { A uint `json:"a,omitempty"` @@ -824,15 +479,7 @@ null }{A: 1}}, }, { - name: "HeadUintNotRootString", - expected: `{"A":{"a":"1"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - } -} -`, + name: "HeadUintNotRootString", data: struct { A struct { A uint `json:"a,string"` @@ -844,15 +491,7 @@ null // HeadUintPtrNotRoot { - name: "HeadUintPtrNotRoot", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "HeadUintPtrNotRoot", data: struct { A struct { A *uint `json:"a"` @@ -862,15 +501,7 @@ null }{uptr(1)}}, }, { - name: "HeadUintPtrNotRootOmitEmpty", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "HeadUintPtrNotRootOmitEmpty", data: struct { A struct { A *uint `json:"a,omitempty"` @@ -880,15 +511,7 @@ null }{uptr(1)}}, }, { - name: "HeadUintPtrNotRootString", - expected: `{"A":{"a":"1"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - } -} -`, + name: "HeadUintPtrNotRootString", data: struct { A struct { A *uint `json:"a,string"` @@ -900,15 +523,7 @@ null // HeadUintPtrNilNotRoot { - name: "HeadUintPtrNilNotRoot", - expected: `{"A":{"a":null}}`, - indentExpected: ` -{ - "A": { - "a": null - } -} -`, + name: "HeadUintPtrNilNotRoot", data: struct { A struct { A *uint `json:"a"` @@ -916,13 +531,7 @@ null }{}, }, { - name: "HeadUintPtrNilNotRootOmitEmpty", - expected: `{"A":{}}`, - indentExpected: ` -{ - "A": {} -} -`, + name: "HeadUintPtrNilNotRootOmitEmpty", data: struct { A struct { A *uint `json:"a,omitempty"` @@ -930,15 +539,7 @@ null }{}, }, { - name: "HeadUintPtrNilNotRootString", - expected: `{"A":{"a":null}}`, - indentExpected: ` -{ - "A": { - "a": null - } -} -`, + name: "HeadUintPtrNilNotRootString", data: struct { A struct { A *uint `json:"a,string"` @@ -948,15 +549,7 @@ null // PtrHeadUintZeroNotRoot { - name: "PtrHeadUintZeroNotRoot", - expected: `{"A":{"a":0}}`, - indentExpected: ` -{ - "A": { - "a": 0 - } -} -`, + name: "PtrHeadUintZeroNotRoot", data: struct { A *struct { A uint `json:"a"` @@ -966,13 +559,7 @@ null })}, }, { - name: "PtrHeadUintZeroNotRootOmitEmpty", - expected: `{"A":{}}`, - indentExpected: ` -{ - "A": {} -} -`, + name: "PtrHeadUintZeroNotRootOmitEmpty", data: struct { A *struct { A uint `json:"a,omitempty"` @@ -982,15 +569,7 @@ null })}, }, { - name: "PtrHeadUintZeroNotRootString", - expected: `{"A":{"a":"0"}}`, - indentExpected: ` -{ - "A": { - "a": "0" - } -} -`, + name: "PtrHeadUintZeroNotRootString", data: struct { A *struct { A uint `json:"a,string"` @@ -1002,15 +581,7 @@ null // PtrHeadUintNotRoot { - name: "PtrHeadUintNotRoot", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "PtrHeadUintNotRoot", data: struct { A *struct { A uint `json:"a"` @@ -1020,15 +591,7 @@ null }{A: 1})}, }, { - name: "PtrHeadUintNotRootOmitEmpty", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "PtrHeadUintNotRootOmitEmpty", data: struct { A *struct { A uint `json:"a,omitempty"` @@ -1038,15 +601,7 @@ null }{A: 1})}, }, { - name: "PtrHeadUintNotRootString", - expected: `{"A":{"a":"1"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - } -} -`, + name: "PtrHeadUintNotRootString", data: struct { A *struct { A uint `json:"a,string"` @@ -1058,15 +613,7 @@ null // PtrHeadUintPtrNotRoot { - name: "PtrHeadUintPtrNotRoot", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "PtrHeadUintPtrNotRoot", data: struct { A *struct { A *uint `json:"a"` @@ -1076,15 +623,7 @@ null }{A: uptr(1)})}, }, { - name: "PtrHeadUintPtrNotRootOmitEmpty", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "PtrHeadUintPtrNotRootOmitEmpty", data: struct { A *struct { A *uint `json:"a,omitempty"` @@ -1094,15 +633,7 @@ null }{A: uptr(1)})}, }, { - name: "PtrHeadUintPtrNotRootString", - expected: `{"A":{"a":"1"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - } -} -`, + name: "PtrHeadUintPtrNotRootString", data: struct { A *struct { A *uint `json:"a,string"` @@ -1114,15 +645,7 @@ null // PtrHeadUintPtrNilNotRoot { - name: "PtrHeadUintPtrNilNotRoot", - expected: `{"A":{"a":null}}`, - indentExpected: ` -{ - "A": { - "a": null - } -} -`, + name: "PtrHeadUintPtrNilNotRoot", data: struct { A *struct { A *uint `json:"a"` @@ -1132,13 +655,7 @@ null }{A: nil})}, }, { - name: "PtrHeadUintPtrNilNotRootOmitEmpty", - expected: `{"A":{}}`, - indentExpected: ` -{ - "A": {} -} -`, + name: "PtrHeadUintPtrNilNotRootOmitEmpty", data: struct { A *struct { A *uint `json:"a,omitempty"` @@ -1148,15 +665,7 @@ null }{A: nil})}, }, { - name: "PtrHeadUintPtrNilNotRootString", - expected: `{"A":{"a":null}}`, - indentExpected: ` -{ - "A": { - "a": null - } -} -`, + name: "PtrHeadUintPtrNilNotRootString", data: struct { A *struct { A *uint `json:"a,string"` @@ -1168,13 +677,7 @@ null // PtrHeadUintNilNotRoot { - name: "PtrHeadUintNilNotRoot", - expected: `{"A":null}`, - indentExpected: ` -{ - "A": null -} -`, + name: "PtrHeadUintNilNotRoot", data: struct { A *struct { A *uint `json:"a"` @@ -1182,11 +685,7 @@ null }{A: nil}, }, { - name: "PtrHeadUintNilNotRootOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadUintNilNotRootOmitEmpty", data: struct { A *struct { A *uint `json:"a,omitempty"` @@ -1194,13 +693,7 @@ null }{A: nil}, }, { - name: "PtrHeadUintNilNotRootString", - expected: `{"A":null}`, - indentExpected: ` -{ - "A": null -} -`, + name: "PtrHeadUintNilNotRootString", data: struct { A *struct { A *uint `json:"a,string"` @@ -1210,18 +703,7 @@ null // HeadUintZeroMultiFieldsNotRoot { - name: "HeadUintZeroMultiFieldsNotRoot", - expected: `{"A":{"a":0},"B":{"b":0}}`, - indentExpected: ` -{ - "A": { - "a": 0 - }, - "B": { - "b": 0 - } -} -`, + name: "HeadUintZeroMultiFieldsNotRoot", data: struct { A struct { A uint `json:"a"` @@ -1232,14 +714,7 @@ null }{}, }, { - name: "HeadUintZeroMultiFieldsNotRootOmitEmpty", - expected: `{"A":{},"B":{}}`, - indentExpected: ` -{ - "A": {}, - "B": {} -} -`, + name: "HeadUintZeroMultiFieldsNotRootOmitEmpty", data: struct { A struct { A uint `json:"a,omitempty"` @@ -1250,18 +725,7 @@ null }{}, }, { - name: "HeadUintZeroMultiFieldsNotRootString", - expected: `{"A":{"a":"0"},"B":{"b":"0"}}`, - indentExpected: ` -{ - "A": { - "a": "0" - }, - "B": { - "b": "0" - } -} -`, + name: "HeadUintZeroMultiFieldsNotRootString", data: struct { A struct { A uint `json:"a,string"` @@ -1274,18 +738,7 @@ null // HeadUintMultiFieldsNotRoot { - name: "HeadUintMultiFieldsNotRoot", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "HeadUintMultiFieldsNotRoot", data: struct { A struct { A uint `json:"a"` @@ -1300,18 +753,7 @@ null }{B: 2}}, }, { - name: "HeadUintMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "HeadUintMultiFieldsNotRootOmitEmpty", data: struct { A struct { A uint `json:"a,omitempty"` @@ -1326,18 +768,7 @@ null }{B: 2}}, }, { - name: "HeadUintMultiFieldsNotRootString", - expected: `{"A":{"a":"1"},"B":{"b":"2"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - }, - "B": { - "b": "2" - } -} -`, + name: "HeadUintMultiFieldsNotRootString", data: struct { A struct { A uint `json:"a,string"` @@ -1354,18 +785,7 @@ null // HeadUintPtrMultiFieldsNotRoot { - name: "HeadUintPtrMultiFieldsNotRoot", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "HeadUintPtrMultiFieldsNotRoot", data: struct { A struct { A *uint `json:"a"` @@ -1380,18 +800,7 @@ null }{B: uptr(2)}}, }, { - name: "HeadUintPtrMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "HeadUintPtrMultiFieldsNotRootOmitEmpty", data: struct { A struct { A *uint `json:"a,omitempty"` @@ -1406,18 +815,7 @@ null }{B: uptr(2)}}, }, { - name: "HeadUintPtrMultiFieldsNotRootString", - expected: `{"A":{"a":"1"},"B":{"b":"2"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - }, - "B": { - "b": "2" - } -} -`, + name: "HeadUintPtrMultiFieldsNotRootString", data: struct { A struct { A *uint `json:"a,string"` @@ -1434,18 +832,7 @@ null // HeadUintPtrNilMultiFieldsNotRoot { - name: "HeadUintPtrNilMultiFieldsNotRoot", - expected: `{"A":{"a":null},"B":{"b":null}}`, - indentExpected: ` -{ - "A": { - "a": null - }, - "B": { - "b": null - } -} -`, + name: "HeadUintPtrNilMultiFieldsNotRoot", data: struct { A struct { A *uint `json:"a"` @@ -1460,14 +847,7 @@ null }{B: nil}}, }, { - name: "HeadUintPtrNilMultiFieldsNotRootOmitEmpty", - expected: `{"A":{},"B":{}}`, - indentExpected: ` -{ - "A": {}, - "B": {} -} -`, + name: "HeadUintPtrNilMultiFieldsNotRootOmitEmpty", data: struct { A struct { A *uint `json:"a,omitempty"` @@ -1482,18 +862,7 @@ null }{B: nil}}, }, { - name: "HeadUintPtrNilMultiFieldsNotRootString", - expected: `{"A":{"a":null},"B":{"b":null}}`, - indentExpected: ` -{ - "A": { - "a": null - }, - "B": { - "b": null - } -} -`, + name: "HeadUintPtrNilMultiFieldsNotRootString", data: struct { A struct { A *uint `json:"a,string"` @@ -1510,18 +879,7 @@ null // PtrHeadUintZeroMultiFieldsNotRoot { - name: "PtrHeadUintZeroMultiFieldsNotRoot", - expected: `{"A":{"a":0},"B":{"b":0}}`, - indentExpected: ` -{ - "A": { - "a": 0 - }, - "B": { - "b": 0 - } -} -`, + name: "PtrHeadUintZeroMultiFieldsNotRoot", data: &struct { A struct { A uint `json:"a"` @@ -1532,14 +890,7 @@ null }{}, }, { - name: "PtrHeadUintZeroMultiFieldsNotRootOmitEmpty", - expected: `{"A":{},"B":{}}`, - indentExpected: ` -{ - "A": {}, - "B": {} -} -`, + name: "PtrHeadUintZeroMultiFieldsNotRootOmitEmpty", data: &struct { A struct { A uint `json:"a,omitempty"` @@ -1550,18 +901,7 @@ null }{}, }, { - name: "PtrHeadUintZeroMultiFieldsNotRootString", - expected: `{"A":{"a":"0"},"B":{"b":"0"}}`, - indentExpected: ` -{ - "A": { - "a": "0" - }, - "B": { - "b": "0" - } -} -`, + name: "PtrHeadUintZeroMultiFieldsNotRootString", data: &struct { A struct { A uint `json:"a,string"` @@ -1574,18 +914,7 @@ null // PtrHeadUintMultiFieldsNotRoot { - name: "PtrHeadUintMultiFieldsNotRoot", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "PtrHeadUintMultiFieldsNotRoot", data: &struct { A struct { A uint `json:"a"` @@ -1600,18 +929,7 @@ null }{B: 2}}, }, { - name: "PtrHeadUintMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "PtrHeadUintMultiFieldsNotRootOmitEmpty", data: &struct { A struct { A uint `json:"a,omitempty"` @@ -1626,18 +944,7 @@ null }{B: 2}}, }, { - name: "PtrHeadUintMultiFieldsNotRootString", - expected: `{"A":{"a":"1"},"B":{"b":"2"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - }, - "B": { - "b": "2" - } -} -`, + name: "PtrHeadUintMultiFieldsNotRootString", data: &struct { A struct { A uint `json:"a,string"` @@ -1654,18 +961,7 @@ null // PtrHeadUintPtrMultiFieldsNotRoot { - name: "PtrHeadUintPtrMultiFieldsNotRoot", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "PtrHeadUintPtrMultiFieldsNotRoot", data: &struct { A *struct { A *uint `json:"a"` @@ -1680,18 +976,7 @@ null }{B: uptr(2)})}, }, { - name: "PtrHeadUintPtrMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "PtrHeadUintPtrMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A *uint `json:"a,omitempty"` @@ -1706,18 +991,7 @@ null }{B: uptr(2)})}, }, { - name: "PtrHeadUintPtrMultiFieldsNotRootString", - expected: `{"A":{"a":"1"},"B":{"b":"2"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - }, - "B": { - "b": "2" - } -} -`, + name: "PtrHeadUintPtrMultiFieldsNotRootString", data: &struct { A *struct { A *uint `json:"a,string"` @@ -1734,14 +1008,7 @@ null // PtrHeadUintPtrNilMultiFieldsNotRoot { - name: "PtrHeadUintPtrNilMultiFieldsNotRoot", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadUintPtrNilMultiFieldsNotRoot", data: &struct { A *struct { A *uint `json:"a"` @@ -1752,11 +1019,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadUintPtrNilMultiFieldsNotRootOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadUintPtrNilMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A *uint `json:"a,omitempty"` @@ -1767,14 +1030,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadUintPtrNilMultiFieldsNotRootString", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadUintPtrNilMultiFieldsNotRootString", data: &struct { A *struct { A *uint `json:"a,string"` @@ -1787,11 +1043,7 @@ null // PtrHeadUintNilMultiFieldsNotRoot { - name: "PtrHeadUintNilMultiFieldsNotRoot", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUintNilMultiFieldsNotRoot", data: (*struct { A *struct { A *uint `json:"a"` @@ -1802,11 +1054,7 @@ null })(nil), }, { - name: "PtrHeadUintNilMultiFieldsNotRootOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUintNilMultiFieldsNotRootOmitEmpty", data: (*struct { A *struct { A *uint `json:"a,omitempty"` @@ -1817,11 +1065,7 @@ null })(nil), }, { - name: "PtrHeadUintNilMultiFieldsNotRootString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUintNilMultiFieldsNotRootString", data: (*struct { A *struct { A *uint `json:"a,string"` @@ -1834,20 +1078,7 @@ null // PtrHeadUintDoubleMultiFieldsNotRoot { - name: "PtrHeadUintDoubleMultiFieldsNotRoot", - expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`, - indentExpected: ` -{ - "A": { - "a": 1, - "b": 2 - }, - "B": { - "a": 3, - "b": 4 - } -} -`, + name: "PtrHeadUintDoubleMultiFieldsNotRoot", data: &struct { A *struct { A uint `json:"a"` @@ -1866,20 +1097,7 @@ null }{A: 3, B: 4})}, }, { - name: "PtrHeadUintDoubleMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`, - indentExpected: ` -{ - "A": { - "a": 1, - "b": 2 - }, - "B": { - "a": 3, - "b": 4 - } -} -`, + name: "PtrHeadUintDoubleMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A uint `json:"a,omitempty"` @@ -1898,20 +1116,7 @@ null }{A: 3, B: 4})}, }, { - name: "PtrHeadUintDoubleMultiFieldsNotRootString", - expected: `{"A":{"a":"1","b":"2"},"B":{"a":"3","b":"4"}}`, - indentExpected: ` -{ - "A": { - "a": "1", - "b": "2" - }, - "B": { - "a": "3", - "b": "4" - } -} -`, + name: "PtrHeadUintDoubleMultiFieldsNotRootString", data: &struct { A *struct { A uint `json:"a,string"` @@ -1932,14 +1137,7 @@ null // PtrHeadUintNilDoubleMultiFieldsNotRoot { - name: "PtrHeadUintNilDoubleMultiFieldsNotRoot", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadUintNilDoubleMultiFieldsNotRoot", data: &struct { A *struct { A uint `json:"a"` @@ -1952,11 +1150,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadUintNilDoubleMultiFieldsNotRootOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadUintNilDoubleMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A uint `json:"a,omitempty"` @@ -1969,14 +1163,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadUintNilDoubleMultiFieldsNotRootString", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadUintNilDoubleMultiFieldsNotRootString", data: &struct { A *struct { A uint `json:"a,string"` @@ -1991,11 +1178,7 @@ null // PtrHeadUintNilDoubleMultiFieldsNotRoot { - name: "PtrHeadUintNilDoubleMultiFieldsNotRoot", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUintNilDoubleMultiFieldsNotRoot", data: (*struct { A *struct { A uint `json:"a"` @@ -2008,11 +1191,7 @@ null })(nil), }, { - name: "PtrHeadUintNilDoubleMultiFieldsNotRootOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUintNilDoubleMultiFieldsNotRootOmitEmpty", data: (*struct { A *struct { A uint `json:"a,omitempty"` @@ -2025,11 +1204,7 @@ null })(nil), }, { - name: "PtrHeadUintNilDoubleMultiFieldsNotRootString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUintNilDoubleMultiFieldsNotRootString", data: (*struct { A *struct { A uint `json:"a,string"` @@ -2044,20 +1219,7 @@ null // PtrHeadUintPtrDoubleMultiFieldsNotRoot { - name: "PtrHeadUintPtrDoubleMultiFieldsNotRoot", - expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`, - indentExpected: ` -{ - "A": { - "a": 1, - "b": 2 - }, - "B": { - "a": 3, - "b": 4 - } -} -`, + name: "PtrHeadUintPtrDoubleMultiFieldsNotRoot", data: &struct { A *struct { A *uint `json:"a"` @@ -2076,20 +1238,7 @@ null }{A: uptr(3), B: uptr(4)})}, }, { - name: "PtrHeadUintPtrDoubleMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`, - indentExpected: ` -{ - "A": { - "a": 1, - "b": 2 - }, - "B": { - "a": 3, - "b": 4 - } -} -`, + name: "PtrHeadUintPtrDoubleMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A *uint `json:"a,omitempty"` @@ -2108,20 +1257,7 @@ null }{A: uptr(3), B: uptr(4)})}, }, { - name: "PtrHeadUintPtrDoubleMultiFieldsNotRootString", - expected: `{"A":{"a":"1","b":"2"},"B":{"a":"3","b":"4"}}`, - indentExpected: ` -{ - "A": { - "a": "1", - "b": "2" - }, - "B": { - "a": "3", - "b": "4" - } -} -`, + name: "PtrHeadUintPtrDoubleMultiFieldsNotRootString", data: &struct { A *struct { A *uint `json:"a,string"` @@ -2142,14 +1278,7 @@ null // PtrHeadUintPtrNilDoubleMultiFieldsNotRoot { - name: "PtrHeadUintPtrNilDoubleMultiFieldsNotRoot", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadUintPtrNilDoubleMultiFieldsNotRoot", data: &struct { A *struct { A *uint `json:"a"` @@ -2162,11 +1291,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadUintPtrNilDoubleMultiFieldsNotRootOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadUintPtrNilDoubleMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A *uint `json:"a,omitempty"` @@ -2179,14 +1304,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadUintPtrNilDoubleMultiFieldsNotRootString", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadUintPtrNilDoubleMultiFieldsNotRootString", data: &struct { A *struct { A *uint `json:"a,string"` @@ -2201,11 +1319,7 @@ null // PtrHeadUintPtrNilDoubleMultiFieldsNotRoot { - name: "PtrHeadUintPtrNilDoubleMultiFieldsNotRoot", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUintPtrNilDoubleMultiFieldsNotRoot", data: (*struct { A *struct { A *uint `json:"a"` @@ -2218,11 +1332,7 @@ null })(nil), }, { - name: "PtrHeadUintPtrNilDoubleMultiFieldsNotRootOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUintPtrNilDoubleMultiFieldsNotRootOmitEmpty", data: (*struct { A *struct { A *uint `json:"a,omitempty"` @@ -2235,11 +1345,7 @@ null })(nil), }, { - name: "PtrHeadUintPtrNilDoubleMultiFieldsNotRootString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUintPtrNilDoubleMultiFieldsNotRootString", data: (*struct { A *struct { A *uint `json:"a,string"` @@ -2254,14 +1360,7 @@ null // AnonymousHeadUint { - name: "AnonymousHeadUint", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "AnonymousHeadUint", data: struct { structUint B uint `json:"b"` @@ -2271,14 +1370,7 @@ null }, }, { - name: "AnonymousHeadUintOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "AnonymousHeadUintOmitEmpty", data: struct { structUintOmitEmpty B uint `json:"b,omitempty"` @@ -2288,14 +1380,7 @@ null }, }, { - name: "AnonymousHeadUintString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "AnonymousHeadUintString", data: struct { structUintString B uint `json:"b,string"` @@ -2307,14 +1392,7 @@ null // PtrAnonymousHeadUint { - name: "PtrAnonymousHeadUint", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrAnonymousHeadUint", data: struct { *structUint B uint `json:"b"` @@ -2324,14 +1402,7 @@ null }, }, { - name: "PtrAnonymousHeadUintOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrAnonymousHeadUintOmitEmpty", data: struct { *structUintOmitEmpty B uint `json:"b,omitempty"` @@ -2341,14 +1412,7 @@ null }, }, { - name: "PtrAnonymousHeadUintString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "PtrAnonymousHeadUintString", data: struct { *structUintString B uint `json:"b,string"` @@ -2360,13 +1424,7 @@ null // NilPtrAnonymousHeadUint { - name: "NilPtrAnonymousHeadUint", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "NilPtrAnonymousHeadUint", data: struct { *structUint B uint `json:"b"` @@ -2376,13 +1434,7 @@ null }, }, { - name: "NilPtrAnonymousHeadUintOmitEmpty", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "NilPtrAnonymousHeadUintOmitEmpty", data: struct { *structUintOmitEmpty B uint `json:"b,omitempty"` @@ -2392,13 +1444,7 @@ null }, }, { - name: "NilPtrAnonymousHeadUintString", - expected: `{"b":"2"}`, - indentExpected: ` -{ - "b": "2" -} -`, + name: "NilPtrAnonymousHeadUintString", data: struct { *structUintString B uint `json:"b,string"` @@ -2410,14 +1456,7 @@ null // AnonymousHeadUintPtr { - name: "AnonymousHeadUintPtr", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "AnonymousHeadUintPtr", data: struct { structUintPtr B *uint `json:"b"` @@ -2427,14 +1466,7 @@ null }, }, { - name: "AnonymousHeadUintPtrOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "AnonymousHeadUintPtrOmitEmpty", data: struct { structUintPtrOmitEmpty B *uint `json:"b,omitempty"` @@ -2444,14 +1476,7 @@ null }, }, { - name: "AnonymousHeadUintPtrString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "AnonymousHeadUintPtrString", data: struct { structUintPtrString B *uint `json:"b,string"` @@ -2463,14 +1488,7 @@ null // AnonymousHeadUintPtrNil { - name: "AnonymousHeadUintPtrNil", - expected: `{"a":null,"b":2}`, - indentExpected: ` -{ - "a": null, - "b": 2 -} -`, + name: "AnonymousHeadUintPtrNil", data: struct { structUintPtr B *uint `json:"b"` @@ -2480,13 +1498,7 @@ null }, }, { - name: "AnonymousHeadUintPtrNilOmitEmpty", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "AnonymousHeadUintPtrNilOmitEmpty", data: struct { structUintPtrOmitEmpty B *uint `json:"b,omitempty"` @@ -2496,14 +1508,7 @@ null }, }, { - name: "AnonymousHeadUintPtrNilString", - expected: `{"a":null,"b":"2"}`, - indentExpected: ` -{ - "a": null, - "b": "2" -} -`, + name: "AnonymousHeadUintPtrNilString", data: struct { structUintPtrString B *uint `json:"b,string"` @@ -2515,14 +1520,7 @@ null // PtrAnonymousHeadUintPtr { - name: "PtrAnonymousHeadUintPtr", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrAnonymousHeadUintPtr", data: struct { *structUintPtr B *uint `json:"b"` @@ -2532,14 +1530,7 @@ null }, }, { - name: "PtrAnonymousHeadUintPtrOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrAnonymousHeadUintPtrOmitEmpty", data: struct { *structUintPtrOmitEmpty B *uint `json:"b,omitempty"` @@ -2549,14 +1540,7 @@ null }, }, { - name: "PtrAnonymousHeadUintPtrString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "PtrAnonymousHeadUintPtrString", data: struct { *structUintPtrString B *uint `json:"b,string"` @@ -2568,13 +1552,7 @@ null // NilPtrAnonymousHeadUintPtr { - name: "NilPtrAnonymousHeadUintPtr", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "NilPtrAnonymousHeadUintPtr", data: struct { *structUintPtr B *uint `json:"b"` @@ -2584,13 +1562,7 @@ null }, }, { - name: "NilPtrAnonymousHeadUintPtrOmitEmpty", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "NilPtrAnonymousHeadUintPtrOmitEmpty", data: struct { *structUintPtrOmitEmpty B *uint `json:"b,omitempty"` @@ -2600,13 +1572,7 @@ null }, }, { - name: "NilPtrAnonymousHeadUintPtrString", - expected: `{"b":"2"}`, - indentExpected: ` -{ - "b": "2" -} -`, + name: "NilPtrAnonymousHeadUintPtrString", data: struct { *structUintPtrString B *uint `json:"b,string"` @@ -2618,13 +1584,7 @@ null // AnonymousHeadUintOnly { - name: "AnonymousHeadUintOnly", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "AnonymousHeadUintOnly", data: struct { structUint }{ @@ -2632,13 +1592,7 @@ null }, }, { - name: "AnonymousHeadUintOnlyOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "AnonymousHeadUintOnlyOmitEmpty", data: struct { structUintOmitEmpty }{ @@ -2646,13 +1600,7 @@ null }, }, { - name: "AnonymousHeadUintOnlyString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "AnonymousHeadUintOnlyString", data: struct { structUintString }{ @@ -2662,13 +1610,7 @@ null // PtrAnonymousHeadUintOnly { - name: "PtrAnonymousHeadUintOnly", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrAnonymousHeadUintOnly", data: struct { *structUint }{ @@ -2676,13 +1618,7 @@ null }, }, { - name: "PtrAnonymousHeadUintOnlyOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrAnonymousHeadUintOnlyOmitEmpty", data: struct { *structUintOmitEmpty }{ @@ -2690,13 +1626,7 @@ null }, }, { - name: "PtrAnonymousHeadUintOnlyString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "PtrAnonymousHeadUintOnlyString", data: struct { *structUintString }{ @@ -2706,11 +1636,7 @@ null // NilPtrAnonymousHeadUintOnly { - name: "NilPtrAnonymousHeadUintOnly", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadUintOnly", data: struct { *structUint }{ @@ -2718,11 +1644,7 @@ null }, }, { - name: "NilPtrAnonymousHeadUintOnlyOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadUintOnlyOmitEmpty", data: struct { *structUintOmitEmpty }{ @@ -2730,11 +1652,7 @@ null }, }, { - name: "NilPtrAnonymousHeadUintOnlyString", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadUintOnlyString", data: struct { *structUintString }{ @@ -2744,13 +1662,7 @@ null // AnonymousHeadUintPtrOnly { - name: "AnonymousHeadUintPtrOnly", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "AnonymousHeadUintPtrOnly", data: struct { structUintPtr }{ @@ -2758,13 +1670,7 @@ null }, }, { - name: "AnonymousHeadUintPtrOnlyOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "AnonymousHeadUintPtrOnlyOmitEmpty", data: struct { structUintPtrOmitEmpty }{ @@ -2772,13 +1678,7 @@ null }, }, { - name: "AnonymousHeadUintPtrOnlyString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "AnonymousHeadUintPtrOnlyString", data: struct { structUintPtrString }{ @@ -2788,13 +1688,7 @@ null // AnonymousHeadUintPtrNilOnly { - name: "AnonymousHeadUintPtrNilOnly", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "AnonymousHeadUintPtrNilOnly", data: struct { structUintPtr }{ @@ -2802,11 +1696,7 @@ null }, }, { - name: "AnonymousHeadUintPtrNilOnlyOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "AnonymousHeadUintPtrNilOnlyOmitEmpty", data: struct { structUintPtrOmitEmpty }{ @@ -2814,13 +1704,7 @@ null }, }, { - name: "AnonymousHeadUintPtrNilOnlyString", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "AnonymousHeadUintPtrNilOnlyString", data: struct { structUintPtrString }{ @@ -2830,13 +1714,7 @@ null // PtrAnonymousHeadUintPtrOnly { - name: "PtrAnonymousHeadUintPtrOnly", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrAnonymousHeadUintPtrOnly", data: struct { *structUintPtr }{ @@ -2844,13 +1722,7 @@ null }, }, { - name: "PtrAnonymousHeadUintPtrOnlyOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrAnonymousHeadUintPtrOnlyOmitEmpty", data: struct { *structUintPtrOmitEmpty }{ @@ -2858,13 +1730,7 @@ null }, }, { - name: "PtrAnonymousHeadUintPtrOnlyString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "PtrAnonymousHeadUintPtrOnlyString", data: struct { *structUintPtrString }{ @@ -2874,11 +1740,7 @@ null // NilPtrAnonymousHeadUintPtrOnly { - name: "NilPtrAnonymousHeadUintPtrOnly", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadUintPtrOnly", data: struct { *structUintPtr }{ @@ -2886,11 +1748,7 @@ null }, }, { - name: "NilPtrAnonymousHeadUintPtrOnlyOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadUintPtrOnlyOmitEmpty", data: struct { *structUintPtrOmitEmpty }{ @@ -2898,11 +1756,7 @@ null }, }, { - name: "NilPtrAnonymousHeadUintPtrOnlyString", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadUintPtrOnlyString", data: struct { *structUintPtrString }{ @@ -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()) - } - } } } } From 631ee85a9edd5474214314360c0b58d1b5f9cbd2 Mon Sep 17 00:00:00 2001 From: Masaaki Goshima Date: Mon, 15 Feb 2021 11:27:37 +0900 Subject: [PATCH 07/15] Refactor cover_uint8_test.go --- cover_uint8_test.go | 1540 ++++++------------------------------------- 1 file changed, 192 insertions(+), 1348 deletions(-) diff --git a/cover_uint8_test.go b/cover_uint8_test.go index f463452..96c2a5f 100644 --- a/cover_uint8_test.go +++ b/cover_uint8_test.go @@ -2,7 +2,6 @@ package json_test import ( "bytes" - "strings" "testing" "github.com/goccy/go-json" @@ -30,42 +29,24 @@ func TestCoverUint8(t *testing.T) { } tests := []struct { - name string - expected string - indentExpected string - data interface{} + name string + data interface{} }{ // HeadUint8Zero { - name: "HeadUint8Zero", - expected: `{"a":0}`, - indentExpected: ` -{ - "a": 0 -} -`, + name: "HeadUint8Zero", data: struct { A uint8 `json:"a"` }{}, }, { - name: "HeadUint8ZeroOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "HeadUint8ZeroOmitEmpty", data: struct { A uint8 `json:"a,omitempty"` }{}, }, { - name: "HeadUint8ZeroString", - expected: `{"a":"0"}`, - indentExpected: ` -{ - "a": "0" -} -`, + name: "HeadUint8ZeroString", data: struct { A uint8 `json:"a,string"` }{}, @@ -73,37 +54,19 @@ func TestCoverUint8(t *testing.T) { // HeadUint8 { - name: "HeadUint8", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "HeadUint8", data: struct { A uint8 `json:"a"` }{A: 1}, }, { - name: "HeadUint8OmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "HeadUint8OmitEmpty", data: struct { A uint8 `json:"a,omitempty"` }{A: 1}, }, { - name: "HeadUint8String", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "HeadUint8String", data: struct { A uint8 `json:"a,string"` }{A: 1}, @@ -111,37 +74,19 @@ func TestCoverUint8(t *testing.T) { // HeadUint8Ptr { - name: "HeadUint8Ptr", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "HeadUint8Ptr", data: struct { A *uint8 `json:"a"` }{A: uint8ptr(1)}, }, { - name: "HeadUint8PtrOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "HeadUint8PtrOmitEmpty", data: struct { A *uint8 `json:"a,omitempty"` }{A: uint8ptr(1)}, }, { - name: "HeadUint8PtrString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "HeadUint8PtrString", data: struct { A *uint8 `json:"a,string"` }{A: uint8ptr(1)}, @@ -149,35 +94,19 @@ func TestCoverUint8(t *testing.T) { // HeadUint8PtrNil { - name: "HeadUint8PtrNil", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "HeadUint8PtrNil", data: struct { A *uint8 `json:"a"` }{A: nil}, }, { - name: "HeadUint8PtrNilOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "HeadUint8PtrNilOmitEmpty", data: struct { A *uint8 `json:"a,omitempty"` }{A: nil}, }, { - name: "HeadUint8PtrNilString", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "HeadUint8PtrNilString", data: struct { A *uint8 `json:"a,string"` }{A: nil}, @@ -185,35 +114,19 @@ func TestCoverUint8(t *testing.T) { // PtrHeadUint8Zero { - name: "PtrHeadUint8Zero", - expected: `{"a":0}`, - indentExpected: ` -{ - "a": 0 -} -`, + name: "PtrHeadUint8Zero", data: &struct { A uint8 `json:"a"` }{}, }, { - name: "PtrHeadUint8ZeroOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadUint8ZeroOmitEmpty", data: &struct { A uint8 `json:"a,omitempty"` }{}, }, { - name: "PtrHeadUint8ZeroString", - expected: `{"a":"0"}`, - indentExpected: ` -{ - "a": "0" -} -`, + name: "PtrHeadUint8ZeroString", data: &struct { A uint8 `json:"a,string"` }{}, @@ -221,37 +134,19 @@ func TestCoverUint8(t *testing.T) { // PtrHeadUint8 { - name: "PtrHeadUint8", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrHeadUint8", data: &struct { A uint8 `json:"a"` }{A: 1}, }, { - name: "PtrHeadUint8OmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrHeadUint8OmitEmpty", data: &struct { A uint8 `json:"a,omitempty"` }{A: 1}, }, { - name: "PtrHeadUint8String", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "PtrHeadUint8String", data: &struct { A uint8 `json:"a,string"` }{A: 1}, @@ -259,37 +154,19 @@ func TestCoverUint8(t *testing.T) { // PtrHeadUint8Ptr { - name: "PtrHeadUint8Ptr", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrHeadUint8Ptr", data: &struct { A *uint8 `json:"a"` }{A: uint8ptr(1)}, }, { - name: "PtrHeadUint8PtrOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrHeadUint8PtrOmitEmpty", data: &struct { A *uint8 `json:"a,omitempty"` }{A: uint8ptr(1)}, }, { - name: "PtrHeadUint8PtrString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "PtrHeadUint8PtrString", data: &struct { A *uint8 `json:"a,string"` }{A: uint8ptr(1)}, @@ -297,35 +174,19 @@ func TestCoverUint8(t *testing.T) { // PtrHeadUint8PtrNil { - name: "PtrHeadUint8PtrNil", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "PtrHeadUint8PtrNil", data: &struct { A *uint8 `json:"a"` }{A: nil}, }, { - name: "PtrHeadUint8PtrNilOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadUint8PtrNilOmitEmpty", data: &struct { A *uint8 `json:"a,omitempty"` }{A: nil}, }, { - name: "PtrHeadUint8PtrNilString", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "PtrHeadUint8PtrNilString", data: &struct { A *uint8 `json:"a,string"` }{A: nil}, @@ -333,31 +194,19 @@ func TestCoverUint8(t *testing.T) { // PtrHeadUint8Nil { - name: "PtrHeadUint8Nil", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint8Nil", data: (*struct { A *uint8 `json:"a"` })(nil), }, { - name: "PtrHeadUint8NilOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint8NilOmitEmpty", data: (*struct { A *uint8 `json:"a,omitempty"` })(nil), }, { - name: "PtrHeadUint8NilString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint8NilString", data: (*struct { A *uint8 `json:"a,string"` })(nil), @@ -365,209 +214,125 @@ null // HeadUint8ZeroMultiFields { - name: "HeadUint8ZeroMultiFields", - expected: `{"a":0,"b":0}`, - indentExpected: ` -{ - "a": 0, - "b": 0 -} -`, + name: "HeadUint8ZeroMultiFields", data: struct { A uint8 `json:"a"` B uint8 `json:"b"` + C uint8 `json:"c"` }{}, }, { - name: "HeadUint8ZeroMultiFieldsOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "HeadUint8ZeroMultiFieldsOmitEmpty", data: struct { A uint8 `json:"a,omitempty"` B uint8 `json:"b,omitempty"` + C uint8 `json:"c,omitempty"` }{}, }, { - name: "HeadUint8ZeroMultiFields", - expected: `{"a":"0","b":"0"}`, - indentExpected: ` -{ - "a": "0", - "b": "0" -} -`, + name: "HeadUint8ZeroMultiFields", data: struct { A uint8 `json:"a,string"` B uint8 `json:"b,string"` + C uint8 `json:"c,string"` }{}, }, // HeadUint8MultiFields { - name: "HeadUint8MultiFields", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "HeadUint8MultiFields", data: struct { A uint8 `json:"a"` B uint8 `json:"b"` - }{A: 1, B: 2}, + C uint8 `json:"c"` + }{A: 1, B: 2, C: 3}, }, { - name: "HeadUint8MultiFieldsOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "HeadUint8MultiFieldsOmitEmpty", data: struct { A uint8 `json:"a,omitempty"` B uint8 `json:"b,omitempty"` - }{A: 1, B: 2}, + C uint8 `json:"c,omitempty"` + }{A: 1, B: 2, C: 3}, }, { - name: "HeadUint8MultiFieldsString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "HeadUint8MultiFieldsString", data: struct { A uint8 `json:"a,string"` B uint8 `json:"b,string"` - }{A: 1, B: 2}, + C uint8 `json:"c,string"` + }{A: 1, B: 2, C: 3}, }, // HeadUint8PtrMultiFields { - name: "HeadUint8PtrMultiFields", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "HeadUint8PtrMultiFields", data: struct { A *uint8 `json:"a"` B *uint8 `json:"b"` - }{A: uint8ptr(1), B: uint8ptr(2)}, + C *uint8 `json:"c"` + }{A: uint8ptr(1), B: uint8ptr(2), C: uint8ptr(3)}, }, { - name: "HeadUint8PtrMultiFieldsOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "HeadUint8PtrMultiFieldsOmitEmpty", data: struct { A *uint8 `json:"a,omitempty"` B *uint8 `json:"b,omitempty"` - }{A: uint8ptr(1), B: uint8ptr(2)}, + C *uint8 `json:"c,omitempty"` + }{A: uint8ptr(1), B: uint8ptr(2), C: uint8ptr(3)}, }, { - name: "HeadUint8PtrMultiFieldsString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "HeadUint8PtrMultiFieldsString", data: struct { A *uint8 `json:"a,string"` B *uint8 `json:"b,string"` - }{A: uint8ptr(1), B: uint8ptr(2)}, + C *uint8 `json:"c,string"` + }{A: uint8ptr(1), B: uint8ptr(2), C: uint8ptr(3)}, }, // HeadUint8PtrNilMultiFields { - name: "HeadUint8PtrNilMultiFields", - expected: `{"a":null,"b":null}`, - indentExpected: ` -{ - "a": null, - "b": null -} -`, + name: "HeadUint8PtrNilMultiFields", data: struct { A *uint8 `json:"a"` B *uint8 `json:"b"` - }{A: nil, B: nil}, + C *uint8 `json:"c"` + }{A: nil, B: nil, C: nil}, }, { - name: "HeadUint8PtrNilMultiFieldsOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "HeadUint8PtrNilMultiFieldsOmitEmpty", data: struct { A *uint8 `json:"a,omitempty"` B *uint8 `json:"b,omitempty"` - }{A: nil, B: nil}, + C *uint8 `json:"c,omitempty"` + }{A: nil, B: nil, C: nil}, }, { - name: "HeadUint8PtrNilMultiFieldsString", - expected: `{"a":null,"b":null}`, - indentExpected: ` -{ - "a": null, - "b": null -} -`, + name: "HeadUint8PtrNilMultiFieldsString", data: struct { A *uint8 `json:"a,string"` B *uint8 `json:"b,string"` - }{A: nil, B: nil}, + C *uint8 `json:"c,string"` + }{A: nil, B: nil, C: nil}, }, // PtrHeadUint8ZeroMultiFields { - name: "PtrHeadUint8ZeroMultiFields", - expected: `{"a":0,"b":0}`, - indentExpected: ` -{ - "a": 0, - "b": 0 -} -`, + name: "PtrHeadUint8ZeroMultiFields", data: &struct { A uint8 `json:"a"` B uint8 `json:"b"` }{}, }, { - name: "PtrHeadUint8ZeroMultiFieldsOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadUint8ZeroMultiFieldsOmitEmpty", data: &struct { A uint8 `json:"a,omitempty"` B uint8 `json:"b,omitempty"` }{}, }, { - name: "PtrHeadUint8ZeroMultiFieldsString", - expected: `{"a":"0","b":"0"}`, - indentExpected: ` -{ - "a": "0", - "b": "0" -} -`, + name: "PtrHeadUint8ZeroMultiFieldsString", data: &struct { A uint8 `json:"a,string"` B uint8 `json:"b,string"` @@ -576,42 +341,21 @@ null // PtrHeadUint8MultiFields { - name: "PtrHeadUint8MultiFields", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrHeadUint8MultiFields", data: &struct { A uint8 `json:"a"` B uint8 `json:"b"` }{A: 1, B: 2}, }, { - name: "PtrHeadUint8MultiFieldsOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrHeadUint8MultiFieldsOmitEmpty", data: &struct { A uint8 `json:"a,omitempty"` B uint8 `json:"b,omitempty"` }{A: 1, B: 2}, }, { - name: "PtrHeadUint8MultiFieldsString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "PtrHeadUint8MultiFieldsString", data: &struct { A uint8 `json:"a,string"` B uint8 `json:"b,string"` @@ -620,42 +364,21 @@ null // PtrHeadUint8PtrMultiFields { - name: "PtrHeadUint8PtrMultiFields", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrHeadUint8PtrMultiFields", data: &struct { A *uint8 `json:"a"` B *uint8 `json:"b"` }{A: uint8ptr(1), B: uint8ptr(2)}, }, { - name: "PtrHeadUint8PtrMultiFieldsOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrHeadUint8PtrMultiFieldsOmitEmpty", data: &struct { A *uint8 `json:"a,omitempty"` B *uint8 `json:"b,omitempty"` }{A: uint8ptr(1), B: uint8ptr(2)}, }, { - name: "PtrHeadUint8PtrMultiFieldsString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "PtrHeadUint8PtrMultiFieldsString", data: &struct { A *uint8 `json:"a,string"` B *uint8 `json:"b,string"` @@ -664,39 +387,21 @@ null // PtrHeadUint8PtrNilMultiFields { - name: "PtrHeadUint8PtrNilMultiFields", - expected: `{"a":null,"b":null}`, - indentExpected: ` -{ - "a": null, - "b": null -} -`, + name: "PtrHeadUint8PtrNilMultiFields", data: &struct { A *uint8 `json:"a"` B *uint8 `json:"b"` }{A: nil, B: nil}, }, { - name: "PtrHeadUint8PtrNilMultiFieldsOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadUint8PtrNilMultiFieldsOmitEmpty", data: &struct { A *uint8 `json:"a,omitempty"` B *uint8 `json:"b,omitempty"` }{A: nil, B: nil}, }, { - name: "PtrHeadUint8PtrNilMultiFieldsString", - expected: `{"a":null,"b":null}`, - indentExpected: ` -{ - "a": null, - "b": null -} -`, + name: "PtrHeadUint8PtrNilMultiFieldsString", data: &struct { A *uint8 `json:"a,string"` B *uint8 `json:"b,string"` @@ -705,33 +410,21 @@ null // PtrHeadUint8NilMultiFields { - name: "PtrHeadUint8NilMultiFields", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint8NilMultiFields", data: (*struct { A *uint8 `json:"a"` B *uint8 `json:"b"` })(nil), }, { - name: "PtrHeadUint8NilMultiFieldsOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint8NilMultiFieldsOmitEmpty", data: (*struct { A *uint8 `json:"a,omitempty"` B *uint8 `json:"b,omitempty"` })(nil), }, { - name: "PtrHeadUint8NilMultiFieldsString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint8NilMultiFieldsString", data: (*struct { A *uint8 `json:"a,string"` B *uint8 `json:"b,string"` @@ -740,15 +433,7 @@ null // HeadUint8ZeroNotRoot { - name: "HeadUint8ZeroNotRoot", - expected: `{"A":{"a":0}}`, - indentExpected: ` -{ - "A": { - "a": 0 - } -} -`, + name: "HeadUint8ZeroNotRoot", data: struct { A struct { A uint8 `json:"a"` @@ -756,13 +441,7 @@ null }{}, }, { - name: "HeadUint8ZeroNotRootOmitEmpty", - expected: `{"A":{}}`, - indentExpected: ` -{ - "A": {} -} -`, + name: "HeadUint8ZeroNotRootOmitEmpty", data: struct { A struct { A uint8 `json:"a,omitempty"` @@ -770,15 +449,7 @@ null }{}, }, { - name: "HeadUint8ZeroNotRootString", - expected: `{"A":{"a":"0"}}`, - indentExpected: ` -{ - "A": { - "a": "0" - } -} -`, + name: "HeadUint8ZeroNotRootString", data: struct { A struct { A uint8 `json:"a,string"` @@ -788,15 +459,7 @@ null // HeadUint8NotRoot { - name: "HeadUint8NotRoot", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "HeadUint8NotRoot", data: struct { A struct { A uint8 `json:"a"` @@ -806,15 +469,7 @@ null }{A: 1}}, }, { - name: "HeadUint8NotRootOmitEmpty", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "HeadUint8NotRootOmitEmpty", data: struct { A struct { A uint8 `json:"a,omitempty"` @@ -824,15 +479,7 @@ null }{A: 1}}, }, { - name: "HeadUint8NotRootString", - expected: `{"A":{"a":"1"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - } -} -`, + name: "HeadUint8NotRootString", data: struct { A struct { A uint8 `json:"a,string"` @@ -844,15 +491,7 @@ null // HeadUint8PtrNotRoot { - name: "HeadUint8PtrNotRoot", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "HeadUint8PtrNotRoot", data: struct { A struct { A *uint8 `json:"a"` @@ -862,15 +501,7 @@ null }{uint8ptr(1)}}, }, { - name: "HeadUint8PtrNotRootOmitEmpty", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "HeadUint8PtrNotRootOmitEmpty", data: struct { A struct { A *uint8 `json:"a,omitempty"` @@ -880,15 +511,7 @@ null }{uint8ptr(1)}}, }, { - name: "HeadUint8PtrNotRootString", - expected: `{"A":{"a":"1"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - } -} -`, + name: "HeadUint8PtrNotRootString", data: struct { A struct { A *uint8 `json:"a,string"` @@ -900,15 +523,7 @@ null // HeadUint8PtrNilNotRoot { - name: "HeadUint8PtrNilNotRoot", - expected: `{"A":{"a":null}}`, - indentExpected: ` -{ - "A": { - "a": null - } -} -`, + name: "HeadUint8PtrNilNotRoot", data: struct { A struct { A *uint8 `json:"a"` @@ -916,13 +531,7 @@ null }{}, }, { - name: "HeadUint8PtrNilNotRootOmitEmpty", - expected: `{"A":{}}`, - indentExpected: ` -{ - "A": {} -} -`, + name: "HeadUint8PtrNilNotRootOmitEmpty", data: struct { A struct { A *uint8 `json:"a,omitempty"` @@ -930,15 +539,7 @@ null }{}, }, { - name: "HeadUint8PtrNilNotRootString", - expected: `{"A":{"a":null}}`, - indentExpected: ` -{ - "A": { - "a": null - } -} -`, + name: "HeadUint8PtrNilNotRootString", data: struct { A struct { A *uint8 `json:"a,string"` @@ -948,15 +549,7 @@ null // PtrHeadUint8ZeroNotRoot { - name: "PtrHeadUint8ZeroNotRoot", - expected: `{"A":{"a":0}}`, - indentExpected: ` -{ - "A": { - "a": 0 - } -} -`, + name: "PtrHeadUint8ZeroNotRoot", data: struct { A *struct { A uint8 `json:"a"` @@ -966,13 +559,7 @@ null })}, }, { - name: "PtrHeadUint8ZeroNotRootOmitEmpty", - expected: `{"A":{}}`, - indentExpected: ` -{ - "A": {} -} -`, + name: "PtrHeadUint8ZeroNotRootOmitEmpty", data: struct { A *struct { A uint8 `json:"a,omitempty"` @@ -982,15 +569,7 @@ null })}, }, { - name: "PtrHeadUint8ZeroNotRootString", - expected: `{"A":{"a":"0"}}`, - indentExpected: ` -{ - "A": { - "a": "0" - } -} -`, + name: "PtrHeadUint8ZeroNotRootString", data: struct { A *struct { A uint8 `json:"a,string"` @@ -1002,15 +581,7 @@ null // PtrHeadUint8NotRoot { - name: "PtrHeadUint8NotRoot", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "PtrHeadUint8NotRoot", data: struct { A *struct { A uint8 `json:"a"` @@ -1020,15 +591,7 @@ null }{A: 1})}, }, { - name: "PtrHeadUint8NotRootOmitEmpty", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "PtrHeadUint8NotRootOmitEmpty", data: struct { A *struct { A uint8 `json:"a,omitempty"` @@ -1038,15 +601,7 @@ null }{A: 1})}, }, { - name: "PtrHeadUint8NotRootString", - expected: `{"A":{"a":"1"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - } -} -`, + name: "PtrHeadUint8NotRootString", data: struct { A *struct { A uint8 `json:"a,string"` @@ -1058,15 +613,7 @@ null // PtrHeadUint8PtrNotRoot { - name: "PtrHeadUint8PtrNotRoot", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "PtrHeadUint8PtrNotRoot", data: struct { A *struct { A *uint8 `json:"a"` @@ -1076,15 +623,7 @@ null }{A: uint8ptr(1)})}, }, { - name: "PtrHeadUint8PtrNotRootOmitEmpty", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "PtrHeadUint8PtrNotRootOmitEmpty", data: struct { A *struct { A *uint8 `json:"a,omitempty"` @@ -1094,15 +633,7 @@ null }{A: uint8ptr(1)})}, }, { - name: "PtrHeadUint8PtrNotRootString", - expected: `{"A":{"a":"1"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - } -} -`, + name: "PtrHeadUint8PtrNotRootString", data: struct { A *struct { A *uint8 `json:"a,string"` @@ -1114,15 +645,7 @@ null // PtrHeadUint8PtrNilNotRoot { - name: "PtrHeadUint8PtrNilNotRoot", - expected: `{"A":{"a":null}}`, - indentExpected: ` -{ - "A": { - "a": null - } -} -`, + name: "PtrHeadUint8PtrNilNotRoot", data: struct { A *struct { A *uint8 `json:"a"` @@ -1132,13 +655,7 @@ null }{A: nil})}, }, { - name: "PtrHeadUint8PtrNilNotRootOmitEmpty", - expected: `{"A":{}}`, - indentExpected: ` -{ - "A": {} -} -`, + name: "PtrHeadUint8PtrNilNotRootOmitEmpty", data: struct { A *struct { A *uint8 `json:"a,omitempty"` @@ -1148,15 +665,7 @@ null }{A: nil})}, }, { - name: "PtrHeadUint8PtrNilNotRootString", - expected: `{"A":{"a":null}}`, - indentExpected: ` -{ - "A": { - "a": null - } -} -`, + name: "PtrHeadUint8PtrNilNotRootString", data: struct { A *struct { A *uint8 `json:"a,string"` @@ -1168,13 +677,7 @@ null // PtrHeadUint8NilNotRoot { - name: "PtrHeadUint8NilNotRoot", - expected: `{"A":null}`, - indentExpected: ` -{ - "A": null -} -`, + name: "PtrHeadUint8NilNotRoot", data: struct { A *struct { A *uint8 `json:"a"` @@ -1182,11 +685,7 @@ null }{A: nil}, }, { - name: "PtrHeadUint8NilNotRootOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadUint8NilNotRootOmitEmpty", data: struct { A *struct { A *uint8 `json:"a,omitempty"` @@ -1194,13 +693,7 @@ null }{A: nil}, }, { - name: "PtrHeadUint8NilNotRootString", - expected: `{"A":null}`, - indentExpected: ` -{ - "A": null -} -`, + name: "PtrHeadUint8NilNotRootString", data: struct { A *struct { A *uint8 `json:"a,string"` @@ -1210,18 +703,7 @@ null // HeadUint8ZeroMultiFieldsNotRoot { - name: "HeadUint8ZeroMultiFieldsNotRoot", - expected: `{"A":{"a":0},"B":{"b":0}}`, - indentExpected: ` -{ - "A": { - "a": 0 - }, - "B": { - "b": 0 - } -} -`, + name: "HeadUint8ZeroMultiFieldsNotRoot", data: struct { A struct { A uint8 `json:"a"` @@ -1232,14 +714,7 @@ null }{}, }, { - name: "HeadUint8ZeroMultiFieldsNotRootOmitEmpty", - expected: `{"A":{},"B":{}}`, - indentExpected: ` -{ - "A": {}, - "B": {} -} -`, + name: "HeadUint8ZeroMultiFieldsNotRootOmitEmpty", data: struct { A struct { A uint8 `json:"a,omitempty"` @@ -1250,18 +725,7 @@ null }{}, }, { - name: "HeadUint8ZeroMultiFieldsNotRootString", - expected: `{"A":{"a":"0"},"B":{"b":"0"}}`, - indentExpected: ` -{ - "A": { - "a": "0" - }, - "B": { - "b": "0" - } -} -`, + name: "HeadUint8ZeroMultiFieldsNotRootString", data: struct { A struct { A uint8 `json:"a,string"` @@ -1274,18 +738,7 @@ null // HeadUint8MultiFieldsNotRoot { - name: "HeadUint8MultiFieldsNotRoot", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "HeadUint8MultiFieldsNotRoot", data: struct { A struct { A uint8 `json:"a"` @@ -1300,18 +753,7 @@ null }{B: 2}}, }, { - name: "HeadUint8MultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "HeadUint8MultiFieldsNotRootOmitEmpty", data: struct { A struct { A uint8 `json:"a,omitempty"` @@ -1326,18 +768,7 @@ null }{B: 2}}, }, { - name: "HeadUint8MultiFieldsNotRootString", - expected: `{"A":{"a":"1"},"B":{"b":"2"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - }, - "B": { - "b": "2" - } -} -`, + name: "HeadUint8MultiFieldsNotRootString", data: struct { A struct { A uint8 `json:"a,string"` @@ -1354,18 +785,7 @@ null // HeadUint8PtrMultiFieldsNotRoot { - name: "HeadUint8PtrMultiFieldsNotRoot", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "HeadUint8PtrMultiFieldsNotRoot", data: struct { A struct { A *uint8 `json:"a"` @@ -1380,18 +800,7 @@ null }{B: uint8ptr(2)}}, }, { - name: "HeadUint8PtrMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "HeadUint8PtrMultiFieldsNotRootOmitEmpty", data: struct { A struct { A *uint8 `json:"a,omitempty"` @@ -1406,18 +815,7 @@ null }{B: uint8ptr(2)}}, }, { - name: "HeadUint8PtrMultiFieldsNotRootString", - expected: `{"A":{"a":"1"},"B":{"b":"2"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - }, - "B": { - "b": "2" - } -} -`, + name: "HeadUint8PtrMultiFieldsNotRootString", data: struct { A struct { A *uint8 `json:"a,string"` @@ -1434,18 +832,7 @@ null // HeadUint8PtrNilMultiFieldsNotRoot { - name: "HeadUint8PtrNilMultiFieldsNotRoot", - expected: `{"A":{"a":null},"B":{"b":null}}`, - indentExpected: ` -{ - "A": { - "a": null - }, - "B": { - "b": null - } -} -`, + name: "HeadUint8PtrNilMultiFieldsNotRoot", data: struct { A struct { A *uint8 `json:"a"` @@ -1460,14 +847,7 @@ null }{B: nil}}, }, { - name: "HeadUint8PtrNilMultiFieldsNotRootOmitEmpty", - expected: `{"A":{},"B":{}}`, - indentExpected: ` -{ - "A": {}, - "B": {} -} -`, + name: "HeadUint8PtrNilMultiFieldsNotRootOmitEmpty", data: struct { A struct { A *uint8 `json:"a,omitempty"` @@ -1482,18 +862,7 @@ null }{B: nil}}, }, { - name: "HeadUint8PtrNilMultiFieldsNotRootString", - expected: `{"A":{"a":null},"B":{"b":null}}`, - indentExpected: ` -{ - "A": { - "a": null - }, - "B": { - "b": null - } -} -`, + name: "HeadUint8PtrNilMultiFieldsNotRootString", data: struct { A struct { A *uint8 `json:"a,string"` @@ -1510,18 +879,7 @@ null // PtrHeadUint8ZeroMultiFieldsNotRoot { - name: "PtrHeadUint8ZeroMultiFieldsNotRoot", - expected: `{"A":{"a":0},"B":{"b":0}}`, - indentExpected: ` -{ - "A": { - "a": 0 - }, - "B": { - "b": 0 - } -} -`, + name: "PtrHeadUint8ZeroMultiFieldsNotRoot", data: &struct { A struct { A uint8 `json:"a"` @@ -1532,14 +890,7 @@ null }{}, }, { - name: "PtrHeadUint8ZeroMultiFieldsNotRootOmitEmpty", - expected: `{"A":{},"B":{}}`, - indentExpected: ` -{ - "A": {}, - "B": {} -} -`, + name: "PtrHeadUint8ZeroMultiFieldsNotRootOmitEmpty", data: &struct { A struct { A uint8 `json:"a,omitempty"` @@ -1550,18 +901,7 @@ null }{}, }, { - name: "PtrHeadUint8ZeroMultiFieldsNotRootString", - expected: `{"A":{"a":"0"},"B":{"b":"0"}}`, - indentExpected: ` -{ - "A": { - "a": "0" - }, - "B": { - "b": "0" - } -} -`, + name: "PtrHeadUint8ZeroMultiFieldsNotRootString", data: &struct { A struct { A uint8 `json:"a,string"` @@ -1574,18 +914,7 @@ null // PtrHeadUint8MultiFieldsNotRoot { - name: "PtrHeadUint8MultiFieldsNotRoot", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "PtrHeadUint8MultiFieldsNotRoot", data: &struct { A struct { A uint8 `json:"a"` @@ -1600,18 +929,7 @@ null }{B: 2}}, }, { - name: "PtrHeadUint8MultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "PtrHeadUint8MultiFieldsNotRootOmitEmpty", data: &struct { A struct { A uint8 `json:"a,omitempty"` @@ -1626,18 +944,7 @@ null }{B: 2}}, }, { - name: "PtrHeadUint8MultiFieldsNotRootString", - expected: `{"A":{"a":"1"},"B":{"b":"2"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - }, - "B": { - "b": "2" - } -} -`, + name: "PtrHeadUint8MultiFieldsNotRootString", data: &struct { A struct { A uint8 `json:"a,string"` @@ -1654,18 +961,7 @@ null // PtrHeadUint8PtrMultiFieldsNotRoot { - name: "PtrHeadUint8PtrMultiFieldsNotRoot", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "PtrHeadUint8PtrMultiFieldsNotRoot", data: &struct { A *struct { A *uint8 `json:"a"` @@ -1680,18 +976,7 @@ null }{B: uint8ptr(2)})}, }, { - name: "PtrHeadUint8PtrMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "PtrHeadUint8PtrMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A *uint8 `json:"a,omitempty"` @@ -1706,18 +991,7 @@ null }{B: uint8ptr(2)})}, }, { - name: "PtrHeadUint8PtrMultiFieldsNotRootString", - expected: `{"A":{"a":"1"},"B":{"b":"2"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - }, - "B": { - "b": "2" - } -} -`, + name: "PtrHeadUint8PtrMultiFieldsNotRootString", data: &struct { A *struct { A *uint8 `json:"a,string"` @@ -1734,14 +1008,7 @@ null // PtrHeadUint8PtrNilMultiFieldsNotRoot { - name: "PtrHeadUint8PtrNilMultiFieldsNotRoot", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadUint8PtrNilMultiFieldsNotRoot", data: &struct { A *struct { A *uint8 `json:"a"` @@ -1752,11 +1019,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadUint8PtrNilMultiFieldsNotRootOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadUint8PtrNilMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A *uint8 `json:"a,omitempty"` @@ -1767,14 +1030,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadUint8PtrNilMultiFieldsNotRootString", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadUint8PtrNilMultiFieldsNotRootString", data: &struct { A *struct { A *uint8 `json:"a,string"` @@ -1787,11 +1043,7 @@ null // PtrHeadUint8NilMultiFieldsNotRoot { - name: "PtrHeadUint8NilMultiFieldsNotRoot", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint8NilMultiFieldsNotRoot", data: (*struct { A *struct { A *uint8 `json:"a"` @@ -1802,11 +1054,7 @@ null })(nil), }, { - name: "PtrHeadUint8NilMultiFieldsNotRootOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint8NilMultiFieldsNotRootOmitEmpty", data: (*struct { A *struct { A *uint8 `json:"a,omitempty"` @@ -1817,11 +1065,7 @@ null })(nil), }, { - name: "PtrHeadUint8NilMultiFieldsNotRootString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint8NilMultiFieldsNotRootString", data: (*struct { A *struct { A *uint8 `json:"a,string"` @@ -1834,20 +1078,7 @@ null // PtrHeadUint8DoubleMultiFieldsNotRoot { - name: "PtrHeadUint8DoubleMultiFieldsNotRoot", - expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`, - indentExpected: ` -{ - "A": { - "a": 1, - "b": 2 - }, - "B": { - "a": 3, - "b": 4 - } -} -`, + name: "PtrHeadUint8DoubleMultiFieldsNotRoot", data: &struct { A *struct { A uint8 `json:"a"` @@ -1866,20 +1097,7 @@ null }{A: 3, B: 4})}, }, { - name: "PtrHeadUint8DoubleMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`, - indentExpected: ` -{ - "A": { - "a": 1, - "b": 2 - }, - "B": { - "a": 3, - "b": 4 - } -} -`, + name: "PtrHeadUint8DoubleMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A uint8 `json:"a,omitempty"` @@ -1898,20 +1116,7 @@ null }{A: 3, B: 4})}, }, { - name: "PtrHeadUint8DoubleMultiFieldsNotRootString", - expected: `{"A":{"a":"1","b":"2"},"B":{"a":"3","b":"4"}}`, - indentExpected: ` -{ - "A": { - "a": "1", - "b": "2" - }, - "B": { - "a": "3", - "b": "4" - } -} -`, + name: "PtrHeadUint8DoubleMultiFieldsNotRootString", data: &struct { A *struct { A uint8 `json:"a,string"` @@ -1932,14 +1137,7 @@ null // PtrHeadUint8NilDoubleMultiFieldsNotRoot { - name: "PtrHeadUint8NilDoubleMultiFieldsNotRoot", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadUint8NilDoubleMultiFieldsNotRoot", data: &struct { A *struct { A uint8 `json:"a"` @@ -1952,11 +1150,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadUint8NilDoubleMultiFieldsNotRootOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadUint8NilDoubleMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A uint8 `json:"a,omitempty"` @@ -1969,14 +1163,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadUint8NilDoubleMultiFieldsNotRootString", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadUint8NilDoubleMultiFieldsNotRootString", data: &struct { A *struct { A uint8 `json:"a,string"` @@ -1991,11 +1178,7 @@ null // PtrHeadUint8NilDoubleMultiFieldsNotRoot { - name: "PtrHeadUint8NilDoubleMultiFieldsNotRoot", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint8NilDoubleMultiFieldsNotRoot", data: (*struct { A *struct { A uint8 `json:"a"` @@ -2008,11 +1191,7 @@ null })(nil), }, { - name: "PtrHeadUint8NilDoubleMultiFieldsNotRootOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint8NilDoubleMultiFieldsNotRootOmitEmpty", data: (*struct { A *struct { A uint8 `json:"a,omitempty"` @@ -2025,11 +1204,7 @@ null })(nil), }, { - name: "PtrHeadUint8NilDoubleMultiFieldsNotRootString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint8NilDoubleMultiFieldsNotRootString", data: (*struct { A *struct { A uint8 `json:"a,string"` @@ -2044,20 +1219,7 @@ null // PtrHeadUint8PtrDoubleMultiFieldsNotRoot { - name: "PtrHeadUint8PtrDoubleMultiFieldsNotRoot", - expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`, - indentExpected: ` -{ - "A": { - "a": 1, - "b": 2 - }, - "B": { - "a": 3, - "b": 4 - } -} -`, + name: "PtrHeadUint8PtrDoubleMultiFieldsNotRoot", data: &struct { A *struct { A *uint8 `json:"a"` @@ -2076,20 +1238,7 @@ null }{A: uint8ptr(3), B: uint8ptr(4)})}, }, { - name: "PtrHeadUint8PtrDoubleMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`, - indentExpected: ` -{ - "A": { - "a": 1, - "b": 2 - }, - "B": { - "a": 3, - "b": 4 - } -} -`, + name: "PtrHeadUint8PtrDoubleMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A *uint8 `json:"a,omitempty"` @@ -2108,20 +1257,7 @@ null }{A: uint8ptr(3), B: uint8ptr(4)})}, }, { - name: "PtrHeadUint8PtrDoubleMultiFieldsNotRootString", - expected: `{"A":{"a":"1","b":"2"},"B":{"a":"3","b":"4"}}`, - indentExpected: ` -{ - "A": { - "a": "1", - "b": "2" - }, - "B": { - "a": "3", - "b": "4" - } -} -`, + name: "PtrHeadUint8PtrDoubleMultiFieldsNotRootString", data: &struct { A *struct { A *uint8 `json:"a,string"` @@ -2142,14 +1278,7 @@ null // PtrHeadUint8PtrNilDoubleMultiFieldsNotRoot { - name: "PtrHeadUint8PtrNilDoubleMultiFieldsNotRoot", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadUint8PtrNilDoubleMultiFieldsNotRoot", data: &struct { A *struct { A *uint8 `json:"a"` @@ -2162,11 +1291,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadUint8PtrNilDoubleMultiFieldsNotRootOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadUint8PtrNilDoubleMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A *uint8 `json:"a,omitempty"` @@ -2179,14 +1304,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadUint8PtrNilDoubleMultiFieldsNotRootString", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadUint8PtrNilDoubleMultiFieldsNotRootString", data: &struct { A *struct { A *uint8 `json:"a,string"` @@ -2201,11 +1319,7 @@ null // PtrHeadUint8PtrNilDoubleMultiFieldsNotRoot { - name: "PtrHeadUint8PtrNilDoubleMultiFieldsNotRoot", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint8PtrNilDoubleMultiFieldsNotRoot", data: (*struct { A *struct { A *uint8 `json:"a"` @@ -2218,11 +1332,7 @@ null })(nil), }, { - name: "PtrHeadUint8PtrNilDoubleMultiFieldsNotRootOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint8PtrNilDoubleMultiFieldsNotRootOmitEmpty", data: (*struct { A *struct { A *uint8 `json:"a,omitempty"` @@ -2235,11 +1345,7 @@ null })(nil), }, { - name: "PtrHeadUint8PtrNilDoubleMultiFieldsNotRootString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint8PtrNilDoubleMultiFieldsNotRootString", data: (*struct { A *struct { A *uint8 `json:"a,string"` @@ -2254,14 +1360,7 @@ null // AnonymousHeadUint8 { - name: "AnonymousHeadUint8", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "AnonymousHeadUint8", data: struct { structUint8 B uint8 `json:"b"` @@ -2271,14 +1370,7 @@ null }, }, { - name: "AnonymousHeadUint8OmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "AnonymousHeadUint8OmitEmpty", data: struct { structUint8OmitEmpty B uint8 `json:"b,omitempty"` @@ -2288,14 +1380,7 @@ null }, }, { - name: "AnonymousHeadUint8String", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "AnonymousHeadUint8String", data: struct { structUint8String B uint8 `json:"b,string"` @@ -2307,14 +1392,7 @@ null // PtrAnonymousHeadUint8 { - name: "PtrAnonymousHeadUint8", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrAnonymousHeadUint8", data: struct { *structUint8 B uint8 `json:"b"` @@ -2324,14 +1402,7 @@ null }, }, { - name: "PtrAnonymousHeadUint8OmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrAnonymousHeadUint8OmitEmpty", data: struct { *structUint8OmitEmpty B uint8 `json:"b,omitempty"` @@ -2341,14 +1412,7 @@ null }, }, { - name: "PtrAnonymousHeadUint8String", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "PtrAnonymousHeadUint8String", data: struct { *structUint8String B uint8 `json:"b,string"` @@ -2360,13 +1424,7 @@ null // NilPtrAnonymousHeadUint8 { - name: "NilPtrAnonymousHeadUint8", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "NilPtrAnonymousHeadUint8", data: struct { *structUint8 B uint8 `json:"b"` @@ -2376,13 +1434,7 @@ null }, }, { - name: "NilPtrAnonymousHeadUint8OmitEmpty", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "NilPtrAnonymousHeadUint8OmitEmpty", data: struct { *structUint8OmitEmpty B uint8 `json:"b,omitempty"` @@ -2392,13 +1444,7 @@ null }, }, { - name: "NilPtrAnonymousHeadUint8String", - expected: `{"b":"2"}`, - indentExpected: ` -{ - "b": "2" -} -`, + name: "NilPtrAnonymousHeadUint8String", data: struct { *structUint8String B uint8 `json:"b,string"` @@ -2410,14 +1456,7 @@ null // AnonymousHeadUint8Ptr { - name: "AnonymousHeadUint8Ptr", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "AnonymousHeadUint8Ptr", data: struct { structUint8Ptr B *uint8 `json:"b"` @@ -2427,14 +1466,7 @@ null }, }, { - name: "AnonymousHeadUint8PtrOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "AnonymousHeadUint8PtrOmitEmpty", data: struct { structUint8PtrOmitEmpty B *uint8 `json:"b,omitempty"` @@ -2444,14 +1476,7 @@ null }, }, { - name: "AnonymousHeadUint8PtrString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "AnonymousHeadUint8PtrString", data: struct { structUint8PtrString B *uint8 `json:"b,string"` @@ -2463,14 +1488,7 @@ null // AnonymousHeadUint8PtrNil { - name: "AnonymousHeadUint8PtrNil", - expected: `{"a":null,"b":2}`, - indentExpected: ` -{ - "a": null, - "b": 2 -} -`, + name: "AnonymousHeadUint8PtrNil", data: struct { structUint8Ptr B *uint8 `json:"b"` @@ -2480,13 +1498,7 @@ null }, }, { - name: "AnonymousHeadUint8PtrNilOmitEmpty", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "AnonymousHeadUint8PtrNilOmitEmpty", data: struct { structUint8PtrOmitEmpty B *uint8 `json:"b,omitempty"` @@ -2496,14 +1508,7 @@ null }, }, { - name: "AnonymousHeadUint8PtrNilString", - expected: `{"a":null,"b":"2"}`, - indentExpected: ` -{ - "a": null, - "b": "2" -} -`, + name: "AnonymousHeadUint8PtrNilString", data: struct { structUint8PtrString B *uint8 `json:"b,string"` @@ -2515,14 +1520,7 @@ null // PtrAnonymousHeadUint8Ptr { - name: "PtrAnonymousHeadUint8Ptr", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrAnonymousHeadUint8Ptr", data: struct { *structUint8Ptr B *uint8 `json:"b"` @@ -2532,14 +1530,7 @@ null }, }, { - name: "PtrAnonymousHeadUint8PtrOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrAnonymousHeadUint8PtrOmitEmpty", data: struct { *structUint8PtrOmitEmpty B *uint8 `json:"b,omitempty"` @@ -2549,14 +1540,7 @@ null }, }, { - name: "PtrAnonymousHeadUint8PtrString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "PtrAnonymousHeadUint8PtrString", data: struct { *structUint8PtrString B *uint8 `json:"b,string"` @@ -2568,13 +1552,7 @@ null // NilPtrAnonymousHeadUint8Ptr { - name: "NilPtrAnonymousHeadUint8Ptr", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "NilPtrAnonymousHeadUint8Ptr", data: struct { *structUint8Ptr B *uint8 `json:"b"` @@ -2584,13 +1562,7 @@ null }, }, { - name: "NilPtrAnonymousHeadUint8PtrOmitEmpty", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "NilPtrAnonymousHeadUint8PtrOmitEmpty", data: struct { *structUint8PtrOmitEmpty B *uint8 `json:"b,omitempty"` @@ -2600,13 +1572,7 @@ null }, }, { - name: "NilPtrAnonymousHeadUint8PtrString", - expected: `{"b":"2"}`, - indentExpected: ` -{ - "b": "2" -} -`, + name: "NilPtrAnonymousHeadUint8PtrString", data: struct { *structUint8PtrString B *uint8 `json:"b,string"` @@ -2618,13 +1584,7 @@ null // AnonymousHeadUint8Only { - name: "AnonymousHeadUint8Only", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "AnonymousHeadUint8Only", data: struct { structUint8 }{ @@ -2632,13 +1592,7 @@ null }, }, { - name: "AnonymousHeadUint8OnlyOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "AnonymousHeadUint8OnlyOmitEmpty", data: struct { structUint8OmitEmpty }{ @@ -2646,13 +1600,7 @@ null }, }, { - name: "AnonymousHeadUint8OnlyString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "AnonymousHeadUint8OnlyString", data: struct { structUint8String }{ @@ -2662,13 +1610,7 @@ null // PtrAnonymousHeadUint8Only { - name: "PtrAnonymousHeadUint8Only", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrAnonymousHeadUint8Only", data: struct { *structUint8 }{ @@ -2676,13 +1618,7 @@ null }, }, { - name: "PtrAnonymousHeadUint8OnlyOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrAnonymousHeadUint8OnlyOmitEmpty", data: struct { *structUint8OmitEmpty }{ @@ -2690,13 +1626,7 @@ null }, }, { - name: "PtrAnonymousHeadUint8OnlyString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "PtrAnonymousHeadUint8OnlyString", data: struct { *structUint8String }{ @@ -2706,11 +1636,7 @@ null // NilPtrAnonymousHeadUint8Only { - name: "NilPtrAnonymousHeadUint8Only", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadUint8Only", data: struct { *structUint8 }{ @@ -2718,11 +1644,7 @@ null }, }, { - name: "NilPtrAnonymousHeadUint8OnlyOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadUint8OnlyOmitEmpty", data: struct { *structUint8OmitEmpty }{ @@ -2730,11 +1652,7 @@ null }, }, { - name: "NilPtrAnonymousHeadUint8OnlyString", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadUint8OnlyString", data: struct { *structUint8String }{ @@ -2744,13 +1662,7 @@ null // AnonymousHeadUint8PtrOnly { - name: "AnonymousHeadUint8PtrOnly", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "AnonymousHeadUint8PtrOnly", data: struct { structUint8Ptr }{ @@ -2758,13 +1670,7 @@ null }, }, { - name: "AnonymousHeadUint8PtrOnlyOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "AnonymousHeadUint8PtrOnlyOmitEmpty", data: struct { structUint8PtrOmitEmpty }{ @@ -2772,13 +1678,7 @@ null }, }, { - name: "AnonymousHeadUint8PtrOnlyString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "AnonymousHeadUint8PtrOnlyString", data: struct { structUint8PtrString }{ @@ -2788,13 +1688,7 @@ null // AnonymousHeadUint8PtrNilOnly { - name: "AnonymousHeadUint8PtrNilOnly", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "AnonymousHeadUint8PtrNilOnly", data: struct { structUint8Ptr }{ @@ -2802,11 +1696,7 @@ null }, }, { - name: "AnonymousHeadUint8PtrNilOnlyOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "AnonymousHeadUint8PtrNilOnlyOmitEmpty", data: struct { structUint8PtrOmitEmpty }{ @@ -2814,13 +1704,7 @@ null }, }, { - name: "AnonymousHeadUint8PtrNilOnlyString", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "AnonymousHeadUint8PtrNilOnlyString", data: struct { structUint8PtrString }{ @@ -2830,13 +1714,7 @@ null // PtrAnonymousHeadUint8PtrOnly { - name: "PtrAnonymousHeadUint8PtrOnly", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrAnonymousHeadUint8PtrOnly", data: struct { *structUint8Ptr }{ @@ -2844,13 +1722,7 @@ null }, }, { - name: "PtrAnonymousHeadUint8PtrOnlyOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrAnonymousHeadUint8PtrOnlyOmitEmpty", data: struct { *structUint8PtrOmitEmpty }{ @@ -2858,13 +1730,7 @@ null }, }, { - name: "PtrAnonymousHeadUint8PtrOnlyString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "PtrAnonymousHeadUint8PtrOnlyString", data: struct { *structUint8PtrString }{ @@ -2874,11 +1740,7 @@ null // NilPtrAnonymousHeadUint8PtrOnly { - name: "NilPtrAnonymousHeadUint8PtrOnly", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadUint8PtrOnly", data: struct { *structUint8Ptr }{ @@ -2886,11 +1748,7 @@ null }, }, { - name: "NilPtrAnonymousHeadUint8PtrOnlyOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadUint8PtrOnlyOmitEmpty", data: struct { *structUint8PtrOmitEmpty }{ @@ -2898,11 +1756,7 @@ null }, }, { - name: "NilPtrAnonymousHeadUint8PtrOnlyString", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadUint8PtrOnlyString", data: struct { *structUint8PtrString }{ @@ -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()) - } - } } } } From 5e52d90f0df59cfd81a8c2d815d722d5b0ab94e0 Mon Sep 17 00:00:00 2001 From: Masaaki Goshima Date: Mon, 15 Feb 2021 11:27:47 +0900 Subject: [PATCH 08/15] Refactor cover_uint16_test.go --- cover_uint16_test.go | 1540 ++++++------------------------------------ 1 file changed, 192 insertions(+), 1348 deletions(-) diff --git a/cover_uint16_test.go b/cover_uint16_test.go index c9834ba..4b450c2 100644 --- a/cover_uint16_test.go +++ b/cover_uint16_test.go @@ -2,7 +2,6 @@ package json_test import ( "bytes" - "strings" "testing" "github.com/goccy/go-json" @@ -30,42 +29,24 @@ func TestCoverUint16(t *testing.T) { } tests := []struct { - name string - expected string - indentExpected string - data interface{} + name string + data interface{} }{ // HeadUint16Zero { - name: "HeadUint16Zero", - expected: `{"a":0}`, - indentExpected: ` -{ - "a": 0 -} -`, + name: "HeadUint16Zero", data: struct { A uint16 `json:"a"` }{}, }, { - name: "HeadUint16ZeroOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "HeadUint16ZeroOmitEmpty", data: struct { A uint16 `json:"a,omitempty"` }{}, }, { - name: "HeadUint16ZeroString", - expected: `{"a":"0"}`, - indentExpected: ` -{ - "a": "0" -} -`, + name: "HeadUint16ZeroString", data: struct { A uint16 `json:"a,string"` }{}, @@ -73,37 +54,19 @@ func TestCoverUint16(t *testing.T) { // HeadUint16 { - name: "HeadUint16", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "HeadUint16", data: struct { A uint16 `json:"a"` }{A: 1}, }, { - name: "HeadUint16OmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "HeadUint16OmitEmpty", data: struct { A uint16 `json:"a,omitempty"` }{A: 1}, }, { - name: "HeadUint16String", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "HeadUint16String", data: struct { A uint16 `json:"a,string"` }{A: 1}, @@ -111,37 +74,19 @@ func TestCoverUint16(t *testing.T) { // HeadUint16Ptr { - name: "HeadUint16Ptr", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "HeadUint16Ptr", data: struct { A *uint16 `json:"a"` }{A: uint16ptr(1)}, }, { - name: "HeadUint16PtrOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "HeadUint16PtrOmitEmpty", data: struct { A *uint16 `json:"a,omitempty"` }{A: uint16ptr(1)}, }, { - name: "HeadUint16PtrString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "HeadUint16PtrString", data: struct { A *uint16 `json:"a,string"` }{A: uint16ptr(1)}, @@ -149,35 +94,19 @@ func TestCoverUint16(t *testing.T) { // HeadUint16PtrNil { - name: "HeadUint16PtrNil", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "HeadUint16PtrNil", data: struct { A *uint16 `json:"a"` }{A: nil}, }, { - name: "HeadUint16PtrNilOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "HeadUint16PtrNilOmitEmpty", data: struct { A *uint16 `json:"a,omitempty"` }{A: nil}, }, { - name: "HeadUint16PtrNilString", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "HeadUint16PtrNilString", data: struct { A *uint16 `json:"a,string"` }{A: nil}, @@ -185,35 +114,19 @@ func TestCoverUint16(t *testing.T) { // PtrHeadUint16Zero { - name: "PtrHeadUint16Zero", - expected: `{"a":0}`, - indentExpected: ` -{ - "a": 0 -} -`, + name: "PtrHeadUint16Zero", data: &struct { A uint16 `json:"a"` }{}, }, { - name: "PtrHeadUint16ZeroOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadUint16ZeroOmitEmpty", data: &struct { A uint16 `json:"a,omitempty"` }{}, }, { - name: "PtrHeadUint16ZeroString", - expected: `{"a":"0"}`, - indentExpected: ` -{ - "a": "0" -} -`, + name: "PtrHeadUint16ZeroString", data: &struct { A uint16 `json:"a,string"` }{}, @@ -221,37 +134,19 @@ func TestCoverUint16(t *testing.T) { // PtrHeadUint16 { - name: "PtrHeadUint16", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrHeadUint16", data: &struct { A uint16 `json:"a"` }{A: 1}, }, { - name: "PtrHeadUint16OmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrHeadUint16OmitEmpty", data: &struct { A uint16 `json:"a,omitempty"` }{A: 1}, }, { - name: "PtrHeadUint16String", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "PtrHeadUint16String", data: &struct { A uint16 `json:"a,string"` }{A: 1}, @@ -259,37 +154,19 @@ func TestCoverUint16(t *testing.T) { // PtrHeadUint16Ptr { - name: "PtrHeadUint16Ptr", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrHeadUint16Ptr", data: &struct { A *uint16 `json:"a"` }{A: uint16ptr(1)}, }, { - name: "PtrHeadUint16PtrOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrHeadUint16PtrOmitEmpty", data: &struct { A *uint16 `json:"a,omitempty"` }{A: uint16ptr(1)}, }, { - name: "PtrHeadUint16PtrString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "PtrHeadUint16PtrString", data: &struct { A *uint16 `json:"a,string"` }{A: uint16ptr(1)}, @@ -297,35 +174,19 @@ func TestCoverUint16(t *testing.T) { // PtrHeadUint16PtrNil { - name: "PtrHeadUint16PtrNil", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "PtrHeadUint16PtrNil", data: &struct { A *uint16 `json:"a"` }{A: nil}, }, { - name: "PtrHeadUint16PtrNilOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadUint16PtrNilOmitEmpty", data: &struct { A *uint16 `json:"a,omitempty"` }{A: nil}, }, { - name: "PtrHeadUint16PtrNilString", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "PtrHeadUint16PtrNilString", data: &struct { A *uint16 `json:"a,string"` }{A: nil}, @@ -333,31 +194,19 @@ func TestCoverUint16(t *testing.T) { // PtrHeadUint16Nil { - name: "PtrHeadUint16Nil", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint16Nil", data: (*struct { A *uint16 `json:"a"` })(nil), }, { - name: "PtrHeadUint16NilOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint16NilOmitEmpty", data: (*struct { A *uint16 `json:"a,omitempty"` })(nil), }, { - name: "PtrHeadUint16NilString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint16NilString", data: (*struct { A *uint16 `json:"a,string"` })(nil), @@ -365,209 +214,125 @@ null // HeadUint16ZeroMultiFields { - name: "HeadUint16ZeroMultiFields", - expected: `{"a":0,"b":0}`, - indentExpected: ` -{ - "a": 0, - "b": 0 -} -`, + name: "HeadUint16ZeroMultiFields", data: struct { A uint16 `json:"a"` B uint16 `json:"b"` + C uint16 `json:"c"` }{}, }, { - name: "HeadUint16ZeroMultiFieldsOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "HeadUint16ZeroMultiFieldsOmitEmpty", data: struct { A uint16 `json:"a,omitempty"` B uint16 `json:"b,omitempty"` + C uint16 `json:"c,omitempty"` }{}, }, { - name: "HeadUint16ZeroMultiFields", - expected: `{"a":"0","b":"0"}`, - indentExpected: ` -{ - "a": "0", - "b": "0" -} -`, + name: "HeadUint16ZeroMultiFields", data: struct { A uint16 `json:"a,string"` B uint16 `json:"b,string"` + C uint16 `json:"c,string"` }{}, }, // HeadUint16MultiFields { - name: "HeadUint16MultiFields", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "HeadUint16MultiFields", data: struct { A uint16 `json:"a"` B uint16 `json:"b"` - }{A: 1, B: 2}, + C uint16 `json:"c"` + }{A: 1, B: 2, C: 3}, }, { - name: "HeadUint16MultiFieldsOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "HeadUint16MultiFieldsOmitEmpty", data: struct { A uint16 `json:"a,omitempty"` B uint16 `json:"b,omitempty"` - }{A: 1, B: 2}, + C uint16 `json:"c,omitempty"` + }{A: 1, B: 2, C: 3}, }, { - name: "HeadUint16MultiFieldsString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "HeadUint16MultiFieldsString", data: struct { A uint16 `json:"a,string"` B uint16 `json:"b,string"` - }{A: 1, B: 2}, + C uint16 `json:"c,string"` + }{A: 1, B: 2, C: 3}, }, // HeadUint16PtrMultiFields { - name: "HeadUint16PtrMultiFields", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "HeadUint16PtrMultiFields", data: struct { A *uint16 `json:"a"` B *uint16 `json:"b"` - }{A: uint16ptr(1), B: uint16ptr(2)}, + C *uint16 `json:"c"` + }{A: uint16ptr(1), B: uint16ptr(2), C: uint16ptr(3)}, }, { - name: "HeadUint16PtrMultiFieldsOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "HeadUint16PtrMultiFieldsOmitEmpty", data: struct { A *uint16 `json:"a,omitempty"` B *uint16 `json:"b,omitempty"` - }{A: uint16ptr(1), B: uint16ptr(2)}, + C *uint16 `json:"c,omitempty"` + }{A: uint16ptr(1), B: uint16ptr(2), C: uint16ptr(3)}, }, { - name: "HeadUint16PtrMultiFieldsString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "HeadUint16PtrMultiFieldsString", data: struct { A *uint16 `json:"a,string"` B *uint16 `json:"b,string"` - }{A: uint16ptr(1), B: uint16ptr(2)}, + C *uint16 `json:"c,string"` + }{A: uint16ptr(1), B: uint16ptr(2), C: uint16ptr(3)}, }, // HeadUint16PtrNilMultiFields { - name: "HeadUint16PtrNilMultiFields", - expected: `{"a":null,"b":null}`, - indentExpected: ` -{ - "a": null, - "b": null -} -`, + name: "HeadUint16PtrNilMultiFields", data: struct { A *uint16 `json:"a"` B *uint16 `json:"b"` - }{A: nil, B: nil}, + C *uint16 `json:"c"` + }{A: nil, B: nil, C: nil}, }, { - name: "HeadUint16PtrNilMultiFieldsOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "HeadUint16PtrNilMultiFieldsOmitEmpty", data: struct { A *uint16 `json:"a,omitempty"` B *uint16 `json:"b,omitempty"` - }{A: nil, B: nil}, + C *uint16 `json:"c,omitempty"` + }{A: nil, B: nil, C: nil}, }, { - name: "HeadUint16PtrNilMultiFieldsString", - expected: `{"a":null,"b":null}`, - indentExpected: ` -{ - "a": null, - "b": null -} -`, + name: "HeadUint16PtrNilMultiFieldsString", data: struct { A *uint16 `json:"a,string"` B *uint16 `json:"b,string"` - }{A: nil, B: nil}, + C *uint16 `json:"c,string"` + }{A: nil, B: nil, C: nil}, }, // PtrHeadUint16ZeroMultiFields { - name: "PtrHeadUint16ZeroMultiFields", - expected: `{"a":0,"b":0}`, - indentExpected: ` -{ - "a": 0, - "b": 0 -} -`, + name: "PtrHeadUint16ZeroMultiFields", data: &struct { A uint16 `json:"a"` B uint16 `json:"b"` }{}, }, { - name: "PtrHeadUint16ZeroMultiFieldsOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadUint16ZeroMultiFieldsOmitEmpty", data: &struct { A uint16 `json:"a,omitempty"` B uint16 `json:"b,omitempty"` }{}, }, { - name: "PtrHeadUint16ZeroMultiFieldsString", - expected: `{"a":"0","b":"0"}`, - indentExpected: ` -{ - "a": "0", - "b": "0" -} -`, + name: "PtrHeadUint16ZeroMultiFieldsString", data: &struct { A uint16 `json:"a,string"` B uint16 `json:"b,string"` @@ -576,42 +341,21 @@ null // PtrHeadUint16MultiFields { - name: "PtrHeadUint16MultiFields", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrHeadUint16MultiFields", data: &struct { A uint16 `json:"a"` B uint16 `json:"b"` }{A: 1, B: 2}, }, { - name: "PtrHeadUint16MultiFieldsOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrHeadUint16MultiFieldsOmitEmpty", data: &struct { A uint16 `json:"a,omitempty"` B uint16 `json:"b,omitempty"` }{A: 1, B: 2}, }, { - name: "PtrHeadUint16MultiFieldsString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "PtrHeadUint16MultiFieldsString", data: &struct { A uint16 `json:"a,string"` B uint16 `json:"b,string"` @@ -620,42 +364,21 @@ null // PtrHeadUint16PtrMultiFields { - name: "PtrHeadUint16PtrMultiFields", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrHeadUint16PtrMultiFields", data: &struct { A *uint16 `json:"a"` B *uint16 `json:"b"` }{A: uint16ptr(1), B: uint16ptr(2)}, }, { - name: "PtrHeadUint16PtrMultiFieldsOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrHeadUint16PtrMultiFieldsOmitEmpty", data: &struct { A *uint16 `json:"a,omitempty"` B *uint16 `json:"b,omitempty"` }{A: uint16ptr(1), B: uint16ptr(2)}, }, { - name: "PtrHeadUint16PtrMultiFieldsString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "PtrHeadUint16PtrMultiFieldsString", data: &struct { A *uint16 `json:"a,string"` B *uint16 `json:"b,string"` @@ -664,39 +387,21 @@ null // PtrHeadUint16PtrNilMultiFields { - name: "PtrHeadUint16PtrNilMultiFields", - expected: `{"a":null,"b":null}`, - indentExpected: ` -{ - "a": null, - "b": null -} -`, + name: "PtrHeadUint16PtrNilMultiFields", data: &struct { A *uint16 `json:"a"` B *uint16 `json:"b"` }{A: nil, B: nil}, }, { - name: "PtrHeadUint16PtrNilMultiFieldsOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadUint16PtrNilMultiFieldsOmitEmpty", data: &struct { A *uint16 `json:"a,omitempty"` B *uint16 `json:"b,omitempty"` }{A: nil, B: nil}, }, { - name: "PtrHeadUint16PtrNilMultiFieldsString", - expected: `{"a":null,"b":null}`, - indentExpected: ` -{ - "a": null, - "b": null -} -`, + name: "PtrHeadUint16PtrNilMultiFieldsString", data: &struct { A *uint16 `json:"a,string"` B *uint16 `json:"b,string"` @@ -705,33 +410,21 @@ null // PtrHeadUint16NilMultiFields { - name: "PtrHeadUint16NilMultiFields", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint16NilMultiFields", data: (*struct { A *uint16 `json:"a"` B *uint16 `json:"b"` })(nil), }, { - name: "PtrHeadUint16NilMultiFieldsOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint16NilMultiFieldsOmitEmpty", data: (*struct { A *uint16 `json:"a,omitempty"` B *uint16 `json:"b,omitempty"` })(nil), }, { - name: "PtrHeadUint16NilMultiFieldsString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint16NilMultiFieldsString", data: (*struct { A *uint16 `json:"a,string"` B *uint16 `json:"b,string"` @@ -740,15 +433,7 @@ null // HeadUint16ZeroNotRoot { - name: "HeadUint16ZeroNotRoot", - expected: `{"A":{"a":0}}`, - indentExpected: ` -{ - "A": { - "a": 0 - } -} -`, + name: "HeadUint16ZeroNotRoot", data: struct { A struct { A uint16 `json:"a"` @@ -756,13 +441,7 @@ null }{}, }, { - name: "HeadUint16ZeroNotRootOmitEmpty", - expected: `{"A":{}}`, - indentExpected: ` -{ - "A": {} -} -`, + name: "HeadUint16ZeroNotRootOmitEmpty", data: struct { A struct { A uint16 `json:"a,omitempty"` @@ -770,15 +449,7 @@ null }{}, }, { - name: "HeadUint16ZeroNotRootString", - expected: `{"A":{"a":"0"}}`, - indentExpected: ` -{ - "A": { - "a": "0" - } -} -`, + name: "HeadUint16ZeroNotRootString", data: struct { A struct { A uint16 `json:"a,string"` @@ -788,15 +459,7 @@ null // HeadUint16NotRoot { - name: "HeadUint16NotRoot", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "HeadUint16NotRoot", data: struct { A struct { A uint16 `json:"a"` @@ -806,15 +469,7 @@ null }{A: 1}}, }, { - name: "HeadUint16NotRootOmitEmpty", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "HeadUint16NotRootOmitEmpty", data: struct { A struct { A uint16 `json:"a,omitempty"` @@ -824,15 +479,7 @@ null }{A: 1}}, }, { - name: "HeadUint16NotRootString", - expected: `{"A":{"a":"1"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - } -} -`, + name: "HeadUint16NotRootString", data: struct { A struct { A uint16 `json:"a,string"` @@ -844,15 +491,7 @@ null // HeadUint16PtrNotRoot { - name: "HeadUint16PtrNotRoot", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "HeadUint16PtrNotRoot", data: struct { A struct { A *uint16 `json:"a"` @@ -862,15 +501,7 @@ null }{uint16ptr(1)}}, }, { - name: "HeadUint16PtrNotRootOmitEmpty", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "HeadUint16PtrNotRootOmitEmpty", data: struct { A struct { A *uint16 `json:"a,omitempty"` @@ -880,15 +511,7 @@ null }{uint16ptr(1)}}, }, { - name: "HeadUint16PtrNotRootString", - expected: `{"A":{"a":"1"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - } -} -`, + name: "HeadUint16PtrNotRootString", data: struct { A struct { A *uint16 `json:"a,string"` @@ -900,15 +523,7 @@ null // HeadUint16PtrNilNotRoot { - name: "HeadUint16PtrNilNotRoot", - expected: `{"A":{"a":null}}`, - indentExpected: ` -{ - "A": { - "a": null - } -} -`, + name: "HeadUint16PtrNilNotRoot", data: struct { A struct { A *uint16 `json:"a"` @@ -916,13 +531,7 @@ null }{}, }, { - name: "HeadUint16PtrNilNotRootOmitEmpty", - expected: `{"A":{}}`, - indentExpected: ` -{ - "A": {} -} -`, + name: "HeadUint16PtrNilNotRootOmitEmpty", data: struct { A struct { A *uint16 `json:"a,omitempty"` @@ -930,15 +539,7 @@ null }{}, }, { - name: "HeadUint16PtrNilNotRootString", - expected: `{"A":{"a":null}}`, - indentExpected: ` -{ - "A": { - "a": null - } -} -`, + name: "HeadUint16PtrNilNotRootString", data: struct { A struct { A *uint16 `json:"a,string"` @@ -948,15 +549,7 @@ null // PtrHeadUint16ZeroNotRoot { - name: "PtrHeadUint16ZeroNotRoot", - expected: `{"A":{"a":0}}`, - indentExpected: ` -{ - "A": { - "a": 0 - } -} -`, + name: "PtrHeadUint16ZeroNotRoot", data: struct { A *struct { A uint16 `json:"a"` @@ -966,13 +559,7 @@ null })}, }, { - name: "PtrHeadUint16ZeroNotRootOmitEmpty", - expected: `{"A":{}}`, - indentExpected: ` -{ - "A": {} -} -`, + name: "PtrHeadUint16ZeroNotRootOmitEmpty", data: struct { A *struct { A uint16 `json:"a,omitempty"` @@ -982,15 +569,7 @@ null })}, }, { - name: "PtrHeadUint16ZeroNotRootString", - expected: `{"A":{"a":"0"}}`, - indentExpected: ` -{ - "A": { - "a": "0" - } -} -`, + name: "PtrHeadUint16ZeroNotRootString", data: struct { A *struct { A uint16 `json:"a,string"` @@ -1002,15 +581,7 @@ null // PtrHeadUint16NotRoot { - name: "PtrHeadUint16NotRoot", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "PtrHeadUint16NotRoot", data: struct { A *struct { A uint16 `json:"a"` @@ -1020,15 +591,7 @@ null }{A: 1})}, }, { - name: "PtrHeadUint16NotRootOmitEmpty", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "PtrHeadUint16NotRootOmitEmpty", data: struct { A *struct { A uint16 `json:"a,omitempty"` @@ -1038,15 +601,7 @@ null }{A: 1})}, }, { - name: "PtrHeadUint16NotRootString", - expected: `{"A":{"a":"1"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - } -} -`, + name: "PtrHeadUint16NotRootString", data: struct { A *struct { A uint16 `json:"a,string"` @@ -1058,15 +613,7 @@ null // PtrHeadUint16PtrNotRoot { - name: "PtrHeadUint16PtrNotRoot", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "PtrHeadUint16PtrNotRoot", data: struct { A *struct { A *uint16 `json:"a"` @@ -1076,15 +623,7 @@ null }{A: uint16ptr(1)})}, }, { - name: "PtrHeadUint16PtrNotRootOmitEmpty", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "PtrHeadUint16PtrNotRootOmitEmpty", data: struct { A *struct { A *uint16 `json:"a,omitempty"` @@ -1094,15 +633,7 @@ null }{A: uint16ptr(1)})}, }, { - name: "PtrHeadUint16PtrNotRootString", - expected: `{"A":{"a":"1"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - } -} -`, + name: "PtrHeadUint16PtrNotRootString", data: struct { A *struct { A *uint16 `json:"a,string"` @@ -1114,15 +645,7 @@ null // PtrHeadUint16PtrNilNotRoot { - name: "PtrHeadUint16PtrNilNotRoot", - expected: `{"A":{"a":null}}`, - indentExpected: ` -{ - "A": { - "a": null - } -} -`, + name: "PtrHeadUint16PtrNilNotRoot", data: struct { A *struct { A *uint16 `json:"a"` @@ -1132,13 +655,7 @@ null }{A: nil})}, }, { - name: "PtrHeadUint16PtrNilNotRootOmitEmpty", - expected: `{"A":{}}`, - indentExpected: ` -{ - "A": {} -} -`, + name: "PtrHeadUint16PtrNilNotRootOmitEmpty", data: struct { A *struct { A *uint16 `json:"a,omitempty"` @@ -1148,15 +665,7 @@ null }{A: nil})}, }, { - name: "PtrHeadUint16PtrNilNotRootString", - expected: `{"A":{"a":null}}`, - indentExpected: ` -{ - "A": { - "a": null - } -} -`, + name: "PtrHeadUint16PtrNilNotRootString", data: struct { A *struct { A *uint16 `json:"a,string"` @@ -1168,13 +677,7 @@ null // PtrHeadUint16NilNotRoot { - name: "PtrHeadUint16NilNotRoot", - expected: `{"A":null}`, - indentExpected: ` -{ - "A": null -} -`, + name: "PtrHeadUint16NilNotRoot", data: struct { A *struct { A *uint16 `json:"a"` @@ -1182,11 +685,7 @@ null }{A: nil}, }, { - name: "PtrHeadUint16NilNotRootOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadUint16NilNotRootOmitEmpty", data: struct { A *struct { A *uint16 `json:"a,omitempty"` @@ -1194,13 +693,7 @@ null }{A: nil}, }, { - name: "PtrHeadUint16NilNotRootString", - expected: `{"A":null}`, - indentExpected: ` -{ - "A": null -} -`, + name: "PtrHeadUint16NilNotRootString", data: struct { A *struct { A *uint16 `json:"a,string"` @@ -1210,18 +703,7 @@ null // HeadUint16ZeroMultiFieldsNotRoot { - name: "HeadUint16ZeroMultiFieldsNotRoot", - expected: `{"A":{"a":0},"B":{"b":0}}`, - indentExpected: ` -{ - "A": { - "a": 0 - }, - "B": { - "b": 0 - } -} -`, + name: "HeadUint16ZeroMultiFieldsNotRoot", data: struct { A struct { A uint16 `json:"a"` @@ -1232,14 +714,7 @@ null }{}, }, { - name: "HeadUint16ZeroMultiFieldsNotRootOmitEmpty", - expected: `{"A":{},"B":{}}`, - indentExpected: ` -{ - "A": {}, - "B": {} -} -`, + name: "HeadUint16ZeroMultiFieldsNotRootOmitEmpty", data: struct { A struct { A uint16 `json:"a,omitempty"` @@ -1250,18 +725,7 @@ null }{}, }, { - name: "HeadUint16ZeroMultiFieldsNotRootString", - expected: `{"A":{"a":"0"},"B":{"b":"0"}}`, - indentExpected: ` -{ - "A": { - "a": "0" - }, - "B": { - "b": "0" - } -} -`, + name: "HeadUint16ZeroMultiFieldsNotRootString", data: struct { A struct { A uint16 `json:"a,string"` @@ -1274,18 +738,7 @@ null // HeadUint16MultiFieldsNotRoot { - name: "HeadUint16MultiFieldsNotRoot", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "HeadUint16MultiFieldsNotRoot", data: struct { A struct { A uint16 `json:"a"` @@ -1300,18 +753,7 @@ null }{B: 2}}, }, { - name: "HeadUint16MultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "HeadUint16MultiFieldsNotRootOmitEmpty", data: struct { A struct { A uint16 `json:"a,omitempty"` @@ -1326,18 +768,7 @@ null }{B: 2}}, }, { - name: "HeadUint16MultiFieldsNotRootString", - expected: `{"A":{"a":"1"},"B":{"b":"2"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - }, - "B": { - "b": "2" - } -} -`, + name: "HeadUint16MultiFieldsNotRootString", data: struct { A struct { A uint16 `json:"a,string"` @@ -1354,18 +785,7 @@ null // HeadUint16PtrMultiFieldsNotRoot { - name: "HeadUint16PtrMultiFieldsNotRoot", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "HeadUint16PtrMultiFieldsNotRoot", data: struct { A struct { A *uint16 `json:"a"` @@ -1380,18 +800,7 @@ null }{B: uint16ptr(2)}}, }, { - name: "HeadUint16PtrMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "HeadUint16PtrMultiFieldsNotRootOmitEmpty", data: struct { A struct { A *uint16 `json:"a,omitempty"` @@ -1406,18 +815,7 @@ null }{B: uint16ptr(2)}}, }, { - name: "HeadUint16PtrMultiFieldsNotRootString", - expected: `{"A":{"a":"1"},"B":{"b":"2"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - }, - "B": { - "b": "2" - } -} -`, + name: "HeadUint16PtrMultiFieldsNotRootString", data: struct { A struct { A *uint16 `json:"a,string"` @@ -1434,18 +832,7 @@ null // HeadUint16PtrNilMultiFieldsNotRoot { - name: "HeadUint16PtrNilMultiFieldsNotRoot", - expected: `{"A":{"a":null},"B":{"b":null}}`, - indentExpected: ` -{ - "A": { - "a": null - }, - "B": { - "b": null - } -} -`, + name: "HeadUint16PtrNilMultiFieldsNotRoot", data: struct { A struct { A *uint16 `json:"a"` @@ -1460,14 +847,7 @@ null }{B: nil}}, }, { - name: "HeadUint16PtrNilMultiFieldsNotRootOmitEmpty", - expected: `{"A":{},"B":{}}`, - indentExpected: ` -{ - "A": {}, - "B": {} -} -`, + name: "HeadUint16PtrNilMultiFieldsNotRootOmitEmpty", data: struct { A struct { A *uint16 `json:"a,omitempty"` @@ -1482,18 +862,7 @@ null }{B: nil}}, }, { - name: "HeadUint16PtrNilMultiFieldsNotRootString", - expected: `{"A":{"a":null},"B":{"b":null}}`, - indentExpected: ` -{ - "A": { - "a": null - }, - "B": { - "b": null - } -} -`, + name: "HeadUint16PtrNilMultiFieldsNotRootString", data: struct { A struct { A *uint16 `json:"a,string"` @@ -1510,18 +879,7 @@ null // PtrHeadUint16ZeroMultiFieldsNotRoot { - name: "PtrHeadUint16ZeroMultiFieldsNotRoot", - expected: `{"A":{"a":0},"B":{"b":0}}`, - indentExpected: ` -{ - "A": { - "a": 0 - }, - "B": { - "b": 0 - } -} -`, + name: "PtrHeadUint16ZeroMultiFieldsNotRoot", data: &struct { A struct { A uint16 `json:"a"` @@ -1532,14 +890,7 @@ null }{}, }, { - name: "PtrHeadUint16ZeroMultiFieldsNotRootOmitEmpty", - expected: `{"A":{},"B":{}}`, - indentExpected: ` -{ - "A": {}, - "B": {} -} -`, + name: "PtrHeadUint16ZeroMultiFieldsNotRootOmitEmpty", data: &struct { A struct { A uint16 `json:"a,omitempty"` @@ -1550,18 +901,7 @@ null }{}, }, { - name: "PtrHeadUint16ZeroMultiFieldsNotRootString", - expected: `{"A":{"a":"0"},"B":{"b":"0"}}`, - indentExpected: ` -{ - "A": { - "a": "0" - }, - "B": { - "b": "0" - } -} -`, + name: "PtrHeadUint16ZeroMultiFieldsNotRootString", data: &struct { A struct { A uint16 `json:"a,string"` @@ -1574,18 +914,7 @@ null // PtrHeadUint16MultiFieldsNotRoot { - name: "PtrHeadUint16MultiFieldsNotRoot", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "PtrHeadUint16MultiFieldsNotRoot", data: &struct { A struct { A uint16 `json:"a"` @@ -1600,18 +929,7 @@ null }{B: 2}}, }, { - name: "PtrHeadUint16MultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "PtrHeadUint16MultiFieldsNotRootOmitEmpty", data: &struct { A struct { A uint16 `json:"a,omitempty"` @@ -1626,18 +944,7 @@ null }{B: 2}}, }, { - name: "PtrHeadUint16MultiFieldsNotRootString", - expected: `{"A":{"a":"1"},"B":{"b":"2"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - }, - "B": { - "b": "2" - } -} -`, + name: "PtrHeadUint16MultiFieldsNotRootString", data: &struct { A struct { A uint16 `json:"a,string"` @@ -1654,18 +961,7 @@ null // PtrHeadUint16PtrMultiFieldsNotRoot { - name: "PtrHeadUint16PtrMultiFieldsNotRoot", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "PtrHeadUint16PtrMultiFieldsNotRoot", data: &struct { A *struct { A *uint16 `json:"a"` @@ -1680,18 +976,7 @@ null }{B: uint16ptr(2)})}, }, { - name: "PtrHeadUint16PtrMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "PtrHeadUint16PtrMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A *uint16 `json:"a,omitempty"` @@ -1706,18 +991,7 @@ null }{B: uint16ptr(2)})}, }, { - name: "PtrHeadUint16PtrMultiFieldsNotRootString", - expected: `{"A":{"a":"1"},"B":{"b":"2"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - }, - "B": { - "b": "2" - } -} -`, + name: "PtrHeadUint16PtrMultiFieldsNotRootString", data: &struct { A *struct { A *uint16 `json:"a,string"` @@ -1734,14 +1008,7 @@ null // PtrHeadUint16PtrNilMultiFieldsNotRoot { - name: "PtrHeadUint16PtrNilMultiFieldsNotRoot", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadUint16PtrNilMultiFieldsNotRoot", data: &struct { A *struct { A *uint16 `json:"a"` @@ -1752,11 +1019,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadUint16PtrNilMultiFieldsNotRootOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadUint16PtrNilMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A *uint16 `json:"a,omitempty"` @@ -1767,14 +1030,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadUint16PtrNilMultiFieldsNotRootString", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadUint16PtrNilMultiFieldsNotRootString", data: &struct { A *struct { A *uint16 `json:"a,string"` @@ -1787,11 +1043,7 @@ null // PtrHeadUint16NilMultiFieldsNotRoot { - name: "PtrHeadUint16NilMultiFieldsNotRoot", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint16NilMultiFieldsNotRoot", data: (*struct { A *struct { A *uint16 `json:"a"` @@ -1802,11 +1054,7 @@ null })(nil), }, { - name: "PtrHeadUint16NilMultiFieldsNotRootOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint16NilMultiFieldsNotRootOmitEmpty", data: (*struct { A *struct { A *uint16 `json:"a,omitempty"` @@ -1817,11 +1065,7 @@ null })(nil), }, { - name: "PtrHeadUint16NilMultiFieldsNotRootString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint16NilMultiFieldsNotRootString", data: (*struct { A *struct { A *uint16 `json:"a,string"` @@ -1834,20 +1078,7 @@ null // PtrHeadUint16DoubleMultiFieldsNotRoot { - name: "PtrHeadUint16DoubleMultiFieldsNotRoot", - expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`, - indentExpected: ` -{ - "A": { - "a": 1, - "b": 2 - }, - "B": { - "a": 3, - "b": 4 - } -} -`, + name: "PtrHeadUint16DoubleMultiFieldsNotRoot", data: &struct { A *struct { A uint16 `json:"a"` @@ -1866,20 +1097,7 @@ null }{A: 3, B: 4})}, }, { - name: "PtrHeadUint16DoubleMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`, - indentExpected: ` -{ - "A": { - "a": 1, - "b": 2 - }, - "B": { - "a": 3, - "b": 4 - } -} -`, + name: "PtrHeadUint16DoubleMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A uint16 `json:"a,omitempty"` @@ -1898,20 +1116,7 @@ null }{A: 3, B: 4})}, }, { - name: "PtrHeadUint16DoubleMultiFieldsNotRootString", - expected: `{"A":{"a":"1","b":"2"},"B":{"a":"3","b":"4"}}`, - indentExpected: ` -{ - "A": { - "a": "1", - "b": "2" - }, - "B": { - "a": "3", - "b": "4" - } -} -`, + name: "PtrHeadUint16DoubleMultiFieldsNotRootString", data: &struct { A *struct { A uint16 `json:"a,string"` @@ -1932,14 +1137,7 @@ null // PtrHeadUint16NilDoubleMultiFieldsNotRoot { - name: "PtrHeadUint16NilDoubleMultiFieldsNotRoot", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadUint16NilDoubleMultiFieldsNotRoot", data: &struct { A *struct { A uint16 `json:"a"` @@ -1952,11 +1150,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadUint16NilDoubleMultiFieldsNotRootOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadUint16NilDoubleMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A uint16 `json:"a,omitempty"` @@ -1969,14 +1163,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadUint16NilDoubleMultiFieldsNotRootString", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadUint16NilDoubleMultiFieldsNotRootString", data: &struct { A *struct { A uint16 `json:"a,string"` @@ -1991,11 +1178,7 @@ null // PtrHeadUint16NilDoubleMultiFieldsNotRoot { - name: "PtrHeadUint16NilDoubleMultiFieldsNotRoot", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint16NilDoubleMultiFieldsNotRoot", data: (*struct { A *struct { A uint16 `json:"a"` @@ -2008,11 +1191,7 @@ null })(nil), }, { - name: "PtrHeadUint16NilDoubleMultiFieldsNotRootOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint16NilDoubleMultiFieldsNotRootOmitEmpty", data: (*struct { A *struct { A uint16 `json:"a,omitempty"` @@ -2025,11 +1204,7 @@ null })(nil), }, { - name: "PtrHeadUint16NilDoubleMultiFieldsNotRootString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint16NilDoubleMultiFieldsNotRootString", data: (*struct { A *struct { A uint16 `json:"a,string"` @@ -2044,20 +1219,7 @@ null // PtrHeadUint16PtrDoubleMultiFieldsNotRoot { - name: "PtrHeadUint16PtrDoubleMultiFieldsNotRoot", - expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`, - indentExpected: ` -{ - "A": { - "a": 1, - "b": 2 - }, - "B": { - "a": 3, - "b": 4 - } -} -`, + name: "PtrHeadUint16PtrDoubleMultiFieldsNotRoot", data: &struct { A *struct { A *uint16 `json:"a"` @@ -2076,20 +1238,7 @@ null }{A: uint16ptr(3), B: uint16ptr(4)})}, }, { - name: "PtrHeadUint16PtrDoubleMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`, - indentExpected: ` -{ - "A": { - "a": 1, - "b": 2 - }, - "B": { - "a": 3, - "b": 4 - } -} -`, + name: "PtrHeadUint16PtrDoubleMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A *uint16 `json:"a,omitempty"` @@ -2108,20 +1257,7 @@ null }{A: uint16ptr(3), B: uint16ptr(4)})}, }, { - name: "PtrHeadUint16PtrDoubleMultiFieldsNotRootString", - expected: `{"A":{"a":"1","b":"2"},"B":{"a":"3","b":"4"}}`, - indentExpected: ` -{ - "A": { - "a": "1", - "b": "2" - }, - "B": { - "a": "3", - "b": "4" - } -} -`, + name: "PtrHeadUint16PtrDoubleMultiFieldsNotRootString", data: &struct { A *struct { A *uint16 `json:"a,string"` @@ -2142,14 +1278,7 @@ null // PtrHeadUint16PtrNilDoubleMultiFieldsNotRoot { - name: "PtrHeadUint16PtrNilDoubleMultiFieldsNotRoot", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadUint16PtrNilDoubleMultiFieldsNotRoot", data: &struct { A *struct { A *uint16 `json:"a"` @@ -2162,11 +1291,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadUint16PtrNilDoubleMultiFieldsNotRootOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadUint16PtrNilDoubleMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A *uint16 `json:"a,omitempty"` @@ -2179,14 +1304,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadUint16PtrNilDoubleMultiFieldsNotRootString", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadUint16PtrNilDoubleMultiFieldsNotRootString", data: &struct { A *struct { A *uint16 `json:"a,string"` @@ -2201,11 +1319,7 @@ null // PtrHeadUint16PtrNilDoubleMultiFieldsNotRoot { - name: "PtrHeadUint16PtrNilDoubleMultiFieldsNotRoot", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint16PtrNilDoubleMultiFieldsNotRoot", data: (*struct { A *struct { A *uint16 `json:"a"` @@ -2218,11 +1332,7 @@ null })(nil), }, { - name: "PtrHeadUint16PtrNilDoubleMultiFieldsNotRootOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint16PtrNilDoubleMultiFieldsNotRootOmitEmpty", data: (*struct { A *struct { A *uint16 `json:"a,omitempty"` @@ -2235,11 +1345,7 @@ null })(nil), }, { - name: "PtrHeadUint16PtrNilDoubleMultiFieldsNotRootString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint16PtrNilDoubleMultiFieldsNotRootString", data: (*struct { A *struct { A *uint16 `json:"a,string"` @@ -2254,14 +1360,7 @@ null // AnonymousHeadUint16 { - name: "AnonymousHeadUint16", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "AnonymousHeadUint16", data: struct { structUint16 B uint16 `json:"b"` @@ -2271,14 +1370,7 @@ null }, }, { - name: "AnonymousHeadUint16OmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "AnonymousHeadUint16OmitEmpty", data: struct { structUint16OmitEmpty B uint16 `json:"b,omitempty"` @@ -2288,14 +1380,7 @@ null }, }, { - name: "AnonymousHeadUint16String", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "AnonymousHeadUint16String", data: struct { structUint16String B uint16 `json:"b,string"` @@ -2307,14 +1392,7 @@ null // PtrAnonymousHeadUint16 { - name: "PtrAnonymousHeadUint16", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrAnonymousHeadUint16", data: struct { *structUint16 B uint16 `json:"b"` @@ -2324,14 +1402,7 @@ null }, }, { - name: "PtrAnonymousHeadUint16OmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrAnonymousHeadUint16OmitEmpty", data: struct { *structUint16OmitEmpty B uint16 `json:"b,omitempty"` @@ -2341,14 +1412,7 @@ null }, }, { - name: "PtrAnonymousHeadUint16String", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "PtrAnonymousHeadUint16String", data: struct { *structUint16String B uint16 `json:"b,string"` @@ -2360,13 +1424,7 @@ null // NilPtrAnonymousHeadUint16 { - name: "NilPtrAnonymousHeadUint16", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "NilPtrAnonymousHeadUint16", data: struct { *structUint16 B uint16 `json:"b"` @@ -2376,13 +1434,7 @@ null }, }, { - name: "NilPtrAnonymousHeadUint16OmitEmpty", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "NilPtrAnonymousHeadUint16OmitEmpty", data: struct { *structUint16OmitEmpty B uint16 `json:"b,omitempty"` @@ -2392,13 +1444,7 @@ null }, }, { - name: "NilPtrAnonymousHeadUint16String", - expected: `{"b":"2"}`, - indentExpected: ` -{ - "b": "2" -} -`, + name: "NilPtrAnonymousHeadUint16String", data: struct { *structUint16String B uint16 `json:"b,string"` @@ -2410,14 +1456,7 @@ null // AnonymousHeadUint16Ptr { - name: "AnonymousHeadUint16Ptr", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "AnonymousHeadUint16Ptr", data: struct { structUint16Ptr B *uint16 `json:"b"` @@ -2427,14 +1466,7 @@ null }, }, { - name: "AnonymousHeadUint16PtrOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "AnonymousHeadUint16PtrOmitEmpty", data: struct { structUint16PtrOmitEmpty B *uint16 `json:"b,omitempty"` @@ -2444,14 +1476,7 @@ null }, }, { - name: "AnonymousHeadUint16PtrString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "AnonymousHeadUint16PtrString", data: struct { structUint16PtrString B *uint16 `json:"b,string"` @@ -2463,14 +1488,7 @@ null // AnonymousHeadUint16PtrNil { - name: "AnonymousHeadUint16PtrNil", - expected: `{"a":null,"b":2}`, - indentExpected: ` -{ - "a": null, - "b": 2 -} -`, + name: "AnonymousHeadUint16PtrNil", data: struct { structUint16Ptr B *uint16 `json:"b"` @@ -2480,13 +1498,7 @@ null }, }, { - name: "AnonymousHeadUint16PtrNilOmitEmpty", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "AnonymousHeadUint16PtrNilOmitEmpty", data: struct { structUint16PtrOmitEmpty B *uint16 `json:"b,omitempty"` @@ -2496,14 +1508,7 @@ null }, }, { - name: "AnonymousHeadUint16PtrNilString", - expected: `{"a":null,"b":"2"}`, - indentExpected: ` -{ - "a": null, - "b": "2" -} -`, + name: "AnonymousHeadUint16PtrNilString", data: struct { structUint16PtrString B *uint16 `json:"b,string"` @@ -2515,14 +1520,7 @@ null // PtrAnonymousHeadUint16Ptr { - name: "PtrAnonymousHeadUint16Ptr", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrAnonymousHeadUint16Ptr", data: struct { *structUint16Ptr B *uint16 `json:"b"` @@ -2532,14 +1530,7 @@ null }, }, { - name: "PtrAnonymousHeadUint16PtrOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrAnonymousHeadUint16PtrOmitEmpty", data: struct { *structUint16PtrOmitEmpty B *uint16 `json:"b,omitempty"` @@ -2549,14 +1540,7 @@ null }, }, { - name: "PtrAnonymousHeadUint16PtrString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "PtrAnonymousHeadUint16PtrString", data: struct { *structUint16PtrString B *uint16 `json:"b,string"` @@ -2568,13 +1552,7 @@ null // NilPtrAnonymousHeadUint16Ptr { - name: "NilPtrAnonymousHeadUint16Ptr", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "NilPtrAnonymousHeadUint16Ptr", data: struct { *structUint16Ptr B *uint16 `json:"b"` @@ -2584,13 +1562,7 @@ null }, }, { - name: "NilPtrAnonymousHeadUint16PtrOmitEmpty", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "NilPtrAnonymousHeadUint16PtrOmitEmpty", data: struct { *structUint16PtrOmitEmpty B *uint16 `json:"b,omitempty"` @@ -2600,13 +1572,7 @@ null }, }, { - name: "NilPtrAnonymousHeadUint16PtrString", - expected: `{"b":"2"}`, - indentExpected: ` -{ - "b": "2" -} -`, + name: "NilPtrAnonymousHeadUint16PtrString", data: struct { *structUint16PtrString B *uint16 `json:"b,string"` @@ -2618,13 +1584,7 @@ null // AnonymousHeadUint16Only { - name: "AnonymousHeadUint16Only", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "AnonymousHeadUint16Only", data: struct { structUint16 }{ @@ -2632,13 +1592,7 @@ null }, }, { - name: "AnonymousHeadUint16OnlyOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "AnonymousHeadUint16OnlyOmitEmpty", data: struct { structUint16OmitEmpty }{ @@ -2646,13 +1600,7 @@ null }, }, { - name: "AnonymousHeadUint16OnlyString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "AnonymousHeadUint16OnlyString", data: struct { structUint16String }{ @@ -2662,13 +1610,7 @@ null // PtrAnonymousHeadUint16Only { - name: "PtrAnonymousHeadUint16Only", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrAnonymousHeadUint16Only", data: struct { *structUint16 }{ @@ -2676,13 +1618,7 @@ null }, }, { - name: "PtrAnonymousHeadUint16OnlyOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrAnonymousHeadUint16OnlyOmitEmpty", data: struct { *structUint16OmitEmpty }{ @@ -2690,13 +1626,7 @@ null }, }, { - name: "PtrAnonymousHeadUint16OnlyString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "PtrAnonymousHeadUint16OnlyString", data: struct { *structUint16String }{ @@ -2706,11 +1636,7 @@ null // NilPtrAnonymousHeadUint16Only { - name: "NilPtrAnonymousHeadUint16Only", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadUint16Only", data: struct { *structUint16 }{ @@ -2718,11 +1644,7 @@ null }, }, { - name: "NilPtrAnonymousHeadUint16OnlyOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadUint16OnlyOmitEmpty", data: struct { *structUint16OmitEmpty }{ @@ -2730,11 +1652,7 @@ null }, }, { - name: "NilPtrAnonymousHeadUint16OnlyString", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadUint16OnlyString", data: struct { *structUint16String }{ @@ -2744,13 +1662,7 @@ null // AnonymousHeadUint16PtrOnly { - name: "AnonymousHeadUint16PtrOnly", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "AnonymousHeadUint16PtrOnly", data: struct { structUint16Ptr }{ @@ -2758,13 +1670,7 @@ null }, }, { - name: "AnonymousHeadUint16PtrOnlyOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "AnonymousHeadUint16PtrOnlyOmitEmpty", data: struct { structUint16PtrOmitEmpty }{ @@ -2772,13 +1678,7 @@ null }, }, { - name: "AnonymousHeadUint16PtrOnlyString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "AnonymousHeadUint16PtrOnlyString", data: struct { structUint16PtrString }{ @@ -2788,13 +1688,7 @@ null // AnonymousHeadUint16PtrNilOnly { - name: "AnonymousHeadUint16PtrNilOnly", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "AnonymousHeadUint16PtrNilOnly", data: struct { structUint16Ptr }{ @@ -2802,11 +1696,7 @@ null }, }, { - name: "AnonymousHeadUint16PtrNilOnlyOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "AnonymousHeadUint16PtrNilOnlyOmitEmpty", data: struct { structUint16PtrOmitEmpty }{ @@ -2814,13 +1704,7 @@ null }, }, { - name: "AnonymousHeadUint16PtrNilOnlyString", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "AnonymousHeadUint16PtrNilOnlyString", data: struct { structUint16PtrString }{ @@ -2830,13 +1714,7 @@ null // PtrAnonymousHeadUint16PtrOnly { - name: "PtrAnonymousHeadUint16PtrOnly", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrAnonymousHeadUint16PtrOnly", data: struct { *structUint16Ptr }{ @@ -2844,13 +1722,7 @@ null }, }, { - name: "PtrAnonymousHeadUint16PtrOnlyOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrAnonymousHeadUint16PtrOnlyOmitEmpty", data: struct { *structUint16PtrOmitEmpty }{ @@ -2858,13 +1730,7 @@ null }, }, { - name: "PtrAnonymousHeadUint16PtrOnlyString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "PtrAnonymousHeadUint16PtrOnlyString", data: struct { *structUint16PtrString }{ @@ -2874,11 +1740,7 @@ null // NilPtrAnonymousHeadUint16PtrOnly { - name: "NilPtrAnonymousHeadUint16PtrOnly", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadUint16PtrOnly", data: struct { *structUint16Ptr }{ @@ -2886,11 +1748,7 @@ null }, }, { - name: "NilPtrAnonymousHeadUint16PtrOnlyOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadUint16PtrOnlyOmitEmpty", data: struct { *structUint16PtrOmitEmpty }{ @@ -2898,11 +1756,7 @@ null }, }, { - name: "NilPtrAnonymousHeadUint16PtrOnlyString", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadUint16PtrOnlyString", data: struct { *structUint16PtrString }{ @@ -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()) - } - } } } } From 159f30d9f99fedc781e9c344bc38d49434dc905e Mon Sep 17 00:00:00 2001 From: Masaaki Goshima Date: Mon, 15 Feb 2021 11:27:57 +0900 Subject: [PATCH 09/15] Refactor cover_uint32_test.go --- cover_uint32_test.go | 1540 ++++++------------------------------------ 1 file changed, 192 insertions(+), 1348 deletions(-) diff --git a/cover_uint32_test.go b/cover_uint32_test.go index 811b1a0..6e58ce5 100644 --- a/cover_uint32_test.go +++ b/cover_uint32_test.go @@ -2,7 +2,6 @@ package json_test import ( "bytes" - "strings" "testing" "github.com/goccy/go-json" @@ -30,42 +29,24 @@ func TestCoverUint32(t *testing.T) { } tests := []struct { - name string - expected string - indentExpected string - data interface{} + name string + data interface{} }{ // HeadUint32Zero { - name: "HeadUint32Zero", - expected: `{"a":0}`, - indentExpected: ` -{ - "a": 0 -} -`, + name: "HeadUint32Zero", data: struct { A uint32 `json:"a"` }{}, }, { - name: "HeadUint32ZeroOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "HeadUint32ZeroOmitEmpty", data: struct { A uint32 `json:"a,omitempty"` }{}, }, { - name: "HeadUint32ZeroString", - expected: `{"a":"0"}`, - indentExpected: ` -{ - "a": "0" -} -`, + name: "HeadUint32ZeroString", data: struct { A uint32 `json:"a,string"` }{}, @@ -73,37 +54,19 @@ func TestCoverUint32(t *testing.T) { // HeadUint32 { - name: "HeadUint32", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "HeadUint32", data: struct { A uint32 `json:"a"` }{A: 1}, }, { - name: "HeadUint32OmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "HeadUint32OmitEmpty", data: struct { A uint32 `json:"a,omitempty"` }{A: 1}, }, { - name: "HeadUint32String", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "HeadUint32String", data: struct { A uint32 `json:"a,string"` }{A: 1}, @@ -111,37 +74,19 @@ func TestCoverUint32(t *testing.T) { // HeadUint32Ptr { - name: "HeadUint32Ptr", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "HeadUint32Ptr", data: struct { A *uint32 `json:"a"` }{A: uint32ptr(1)}, }, { - name: "HeadUint32PtrOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "HeadUint32PtrOmitEmpty", data: struct { A *uint32 `json:"a,omitempty"` }{A: uint32ptr(1)}, }, { - name: "HeadUint32PtrString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "HeadUint32PtrString", data: struct { A *uint32 `json:"a,string"` }{A: uint32ptr(1)}, @@ -149,35 +94,19 @@ func TestCoverUint32(t *testing.T) { // HeadUint32PtrNil { - name: "HeadUint32PtrNil", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "HeadUint32PtrNil", data: struct { A *uint32 `json:"a"` }{A: nil}, }, { - name: "HeadUint32PtrNilOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "HeadUint32PtrNilOmitEmpty", data: struct { A *uint32 `json:"a,omitempty"` }{A: nil}, }, { - name: "HeadUint32PtrNilString", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "HeadUint32PtrNilString", data: struct { A *uint32 `json:"a,string"` }{A: nil}, @@ -185,35 +114,19 @@ func TestCoverUint32(t *testing.T) { // PtrHeadUint32Zero { - name: "PtrHeadUint32Zero", - expected: `{"a":0}`, - indentExpected: ` -{ - "a": 0 -} -`, + name: "PtrHeadUint32Zero", data: &struct { A uint32 `json:"a"` }{}, }, { - name: "PtrHeadUint32ZeroOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadUint32ZeroOmitEmpty", data: &struct { A uint32 `json:"a,omitempty"` }{}, }, { - name: "PtrHeadUint32ZeroString", - expected: `{"a":"0"}`, - indentExpected: ` -{ - "a": "0" -} -`, + name: "PtrHeadUint32ZeroString", data: &struct { A uint32 `json:"a,string"` }{}, @@ -221,37 +134,19 @@ func TestCoverUint32(t *testing.T) { // PtrHeadUint32 { - name: "PtrHeadUint32", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrHeadUint32", data: &struct { A uint32 `json:"a"` }{A: 1}, }, { - name: "PtrHeadUint32OmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrHeadUint32OmitEmpty", data: &struct { A uint32 `json:"a,omitempty"` }{A: 1}, }, { - name: "PtrHeadUint32String", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "PtrHeadUint32String", data: &struct { A uint32 `json:"a,string"` }{A: 1}, @@ -259,37 +154,19 @@ func TestCoverUint32(t *testing.T) { // PtrHeadUint32Ptr { - name: "PtrHeadUint32Ptr", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrHeadUint32Ptr", data: &struct { A *uint32 `json:"a"` }{A: uint32ptr(1)}, }, { - name: "PtrHeadUint32PtrOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrHeadUint32PtrOmitEmpty", data: &struct { A *uint32 `json:"a,omitempty"` }{A: uint32ptr(1)}, }, { - name: "PtrHeadUint32PtrString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "PtrHeadUint32PtrString", data: &struct { A *uint32 `json:"a,string"` }{A: uint32ptr(1)}, @@ -297,35 +174,19 @@ func TestCoverUint32(t *testing.T) { // PtrHeadUint32PtrNil { - name: "PtrHeadUint32PtrNil", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "PtrHeadUint32PtrNil", data: &struct { A *uint32 `json:"a"` }{A: nil}, }, { - name: "PtrHeadUint32PtrNilOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadUint32PtrNilOmitEmpty", data: &struct { A *uint32 `json:"a,omitempty"` }{A: nil}, }, { - name: "PtrHeadUint32PtrNilString", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "PtrHeadUint32PtrNilString", data: &struct { A *uint32 `json:"a,string"` }{A: nil}, @@ -333,31 +194,19 @@ func TestCoverUint32(t *testing.T) { // PtrHeadUint32Nil { - name: "PtrHeadUint32Nil", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint32Nil", data: (*struct { A *uint32 `json:"a"` })(nil), }, { - name: "PtrHeadUint32NilOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint32NilOmitEmpty", data: (*struct { A *uint32 `json:"a,omitempty"` })(nil), }, { - name: "PtrHeadUint32NilString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint32NilString", data: (*struct { A *uint32 `json:"a,string"` })(nil), @@ -365,209 +214,125 @@ null // HeadUint32ZeroMultiFields { - name: "HeadUint32ZeroMultiFields", - expected: `{"a":0,"b":0}`, - indentExpected: ` -{ - "a": 0, - "b": 0 -} -`, + name: "HeadUint32ZeroMultiFields", data: struct { A uint32 `json:"a"` B uint32 `json:"b"` + C uint32 `json:"c"` }{}, }, { - name: "HeadUint32ZeroMultiFieldsOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "HeadUint32ZeroMultiFieldsOmitEmpty", data: struct { A uint32 `json:"a,omitempty"` B uint32 `json:"b,omitempty"` + C uint32 `json:"c,omitempty"` }{}, }, { - name: "HeadUint32ZeroMultiFields", - expected: `{"a":"0","b":"0"}`, - indentExpected: ` -{ - "a": "0", - "b": "0" -} -`, + name: "HeadUint32ZeroMultiFields", data: struct { A uint32 `json:"a,string"` B uint32 `json:"b,string"` + C uint32 `json:"c,string"` }{}, }, // HeadUint32MultiFields { - name: "HeadUint32MultiFields", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "HeadUint32MultiFields", data: struct { A uint32 `json:"a"` B uint32 `json:"b"` - }{A: 1, B: 2}, + C uint32 `json:"c"` + }{A: 1, B: 2, C: 3}, }, { - name: "HeadUint32MultiFieldsOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "HeadUint32MultiFieldsOmitEmpty", data: struct { A uint32 `json:"a,omitempty"` B uint32 `json:"b,omitempty"` - }{A: 1, B: 2}, + C uint32 `json:"c,omitempty"` + }{A: 1, B: 2, C: 3}, }, { - name: "HeadUint32MultiFieldsString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "HeadUint32MultiFieldsString", data: struct { A uint32 `json:"a,string"` B uint32 `json:"b,string"` - }{A: 1, B: 2}, + C uint32 `json:"c,string"` + }{A: 1, B: 2, C: 3}, }, // HeadUint32PtrMultiFields { - name: "HeadUint32PtrMultiFields", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "HeadUint32PtrMultiFields", data: struct { A *uint32 `json:"a"` B *uint32 `json:"b"` - }{A: uint32ptr(1), B: uint32ptr(2)}, + C *uint32 `json:"c"` + }{A: uint32ptr(1), B: uint32ptr(2), C: uint32ptr(3)}, }, { - name: "HeadUint32PtrMultiFieldsOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "HeadUint32PtrMultiFieldsOmitEmpty", data: struct { A *uint32 `json:"a,omitempty"` B *uint32 `json:"b,omitempty"` - }{A: uint32ptr(1), B: uint32ptr(2)}, + C *uint32 `json:"c,omitempty"` + }{A: uint32ptr(1), B: uint32ptr(2), C: uint32ptr(3)}, }, { - name: "HeadUint32PtrMultiFieldsString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "HeadUint32PtrMultiFieldsString", data: struct { A *uint32 `json:"a,string"` B *uint32 `json:"b,string"` - }{A: uint32ptr(1), B: uint32ptr(2)}, + C *uint32 `json:"c,string"` + }{A: uint32ptr(1), B: uint32ptr(2), C: uint32ptr(3)}, }, // HeadUint32PtrNilMultiFields { - name: "HeadUint32PtrNilMultiFields", - expected: `{"a":null,"b":null}`, - indentExpected: ` -{ - "a": null, - "b": null -} -`, + name: "HeadUint32PtrNilMultiFields", data: struct { A *uint32 `json:"a"` B *uint32 `json:"b"` - }{A: nil, B: nil}, + C *uint32 `json:"c"` + }{A: nil, B: nil, C: nil}, }, { - name: "HeadUint32PtrNilMultiFieldsOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "HeadUint32PtrNilMultiFieldsOmitEmpty", data: struct { A *uint32 `json:"a,omitempty"` B *uint32 `json:"b,omitempty"` - }{A: nil, B: nil}, + C *uint32 `json:"c,omitempty"` + }{A: nil, B: nil, C: nil}, }, { - name: "HeadUint32PtrNilMultiFieldsString", - expected: `{"a":null,"b":null}`, - indentExpected: ` -{ - "a": null, - "b": null -} -`, + name: "HeadUint32PtrNilMultiFieldsString", data: struct { A *uint32 `json:"a,string"` B *uint32 `json:"b,string"` - }{A: nil, B: nil}, + C *uint32 `json:"c,string"` + }{A: nil, B: nil, C: nil}, }, // PtrHeadUint32ZeroMultiFields { - name: "PtrHeadUint32ZeroMultiFields", - expected: `{"a":0,"b":0}`, - indentExpected: ` -{ - "a": 0, - "b": 0 -} -`, + name: "PtrHeadUint32ZeroMultiFields", data: &struct { A uint32 `json:"a"` B uint32 `json:"b"` }{}, }, { - name: "PtrHeadUint32ZeroMultiFieldsOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadUint32ZeroMultiFieldsOmitEmpty", data: &struct { A uint32 `json:"a,omitempty"` B uint32 `json:"b,omitempty"` }{}, }, { - name: "PtrHeadUint32ZeroMultiFieldsString", - expected: `{"a":"0","b":"0"}`, - indentExpected: ` -{ - "a": "0", - "b": "0" -} -`, + name: "PtrHeadUint32ZeroMultiFieldsString", data: &struct { A uint32 `json:"a,string"` B uint32 `json:"b,string"` @@ -576,42 +341,21 @@ null // PtrHeadUint32MultiFields { - name: "PtrHeadUint32MultiFields", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrHeadUint32MultiFields", data: &struct { A uint32 `json:"a"` B uint32 `json:"b"` }{A: 1, B: 2}, }, { - name: "PtrHeadUint32MultiFieldsOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrHeadUint32MultiFieldsOmitEmpty", data: &struct { A uint32 `json:"a,omitempty"` B uint32 `json:"b,omitempty"` }{A: 1, B: 2}, }, { - name: "PtrHeadUint32MultiFieldsString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "PtrHeadUint32MultiFieldsString", data: &struct { A uint32 `json:"a,string"` B uint32 `json:"b,string"` @@ -620,42 +364,21 @@ null // PtrHeadUint32PtrMultiFields { - name: "PtrHeadUint32PtrMultiFields", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrHeadUint32PtrMultiFields", data: &struct { A *uint32 `json:"a"` B *uint32 `json:"b"` }{A: uint32ptr(1), B: uint32ptr(2)}, }, { - name: "PtrHeadUint32PtrMultiFieldsOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrHeadUint32PtrMultiFieldsOmitEmpty", data: &struct { A *uint32 `json:"a,omitempty"` B *uint32 `json:"b,omitempty"` }{A: uint32ptr(1), B: uint32ptr(2)}, }, { - name: "PtrHeadUint32PtrMultiFieldsString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "PtrHeadUint32PtrMultiFieldsString", data: &struct { A *uint32 `json:"a,string"` B *uint32 `json:"b,string"` @@ -664,39 +387,21 @@ null // PtrHeadUint32PtrNilMultiFields { - name: "PtrHeadUint32PtrNilMultiFields", - expected: `{"a":null,"b":null}`, - indentExpected: ` -{ - "a": null, - "b": null -} -`, + name: "PtrHeadUint32PtrNilMultiFields", data: &struct { A *uint32 `json:"a"` B *uint32 `json:"b"` }{A: nil, B: nil}, }, { - name: "PtrHeadUint32PtrNilMultiFieldsOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadUint32PtrNilMultiFieldsOmitEmpty", data: &struct { A *uint32 `json:"a,omitempty"` B *uint32 `json:"b,omitempty"` }{A: nil, B: nil}, }, { - name: "PtrHeadUint32PtrNilMultiFieldsString", - expected: `{"a":null,"b":null}`, - indentExpected: ` -{ - "a": null, - "b": null -} -`, + name: "PtrHeadUint32PtrNilMultiFieldsString", data: &struct { A *uint32 `json:"a,string"` B *uint32 `json:"b,string"` @@ -705,33 +410,21 @@ null // PtrHeadUint32NilMultiFields { - name: "PtrHeadUint32NilMultiFields", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint32NilMultiFields", data: (*struct { A *uint32 `json:"a"` B *uint32 `json:"b"` })(nil), }, { - name: "PtrHeadUint32NilMultiFieldsOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint32NilMultiFieldsOmitEmpty", data: (*struct { A *uint32 `json:"a,omitempty"` B *uint32 `json:"b,omitempty"` })(nil), }, { - name: "PtrHeadUint32NilMultiFieldsString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint32NilMultiFieldsString", data: (*struct { A *uint32 `json:"a,string"` B *uint32 `json:"b,string"` @@ -740,15 +433,7 @@ null // HeadUint32ZeroNotRoot { - name: "HeadUint32ZeroNotRoot", - expected: `{"A":{"a":0}}`, - indentExpected: ` -{ - "A": { - "a": 0 - } -} -`, + name: "HeadUint32ZeroNotRoot", data: struct { A struct { A uint32 `json:"a"` @@ -756,13 +441,7 @@ null }{}, }, { - name: "HeadUint32ZeroNotRootOmitEmpty", - expected: `{"A":{}}`, - indentExpected: ` -{ - "A": {} -} -`, + name: "HeadUint32ZeroNotRootOmitEmpty", data: struct { A struct { A uint32 `json:"a,omitempty"` @@ -770,15 +449,7 @@ null }{}, }, { - name: "HeadUint32ZeroNotRootString", - expected: `{"A":{"a":"0"}}`, - indentExpected: ` -{ - "A": { - "a": "0" - } -} -`, + name: "HeadUint32ZeroNotRootString", data: struct { A struct { A uint32 `json:"a,string"` @@ -788,15 +459,7 @@ null // HeadUint32NotRoot { - name: "HeadUint32NotRoot", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "HeadUint32NotRoot", data: struct { A struct { A uint32 `json:"a"` @@ -806,15 +469,7 @@ null }{A: 1}}, }, { - name: "HeadUint32NotRootOmitEmpty", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "HeadUint32NotRootOmitEmpty", data: struct { A struct { A uint32 `json:"a,omitempty"` @@ -824,15 +479,7 @@ null }{A: 1}}, }, { - name: "HeadUint32NotRootString", - expected: `{"A":{"a":"1"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - } -} -`, + name: "HeadUint32NotRootString", data: struct { A struct { A uint32 `json:"a,string"` @@ -844,15 +491,7 @@ null // HeadUint32PtrNotRoot { - name: "HeadUint32PtrNotRoot", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "HeadUint32PtrNotRoot", data: struct { A struct { A *uint32 `json:"a"` @@ -862,15 +501,7 @@ null }{uint32ptr(1)}}, }, { - name: "HeadUint32PtrNotRootOmitEmpty", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "HeadUint32PtrNotRootOmitEmpty", data: struct { A struct { A *uint32 `json:"a,omitempty"` @@ -880,15 +511,7 @@ null }{uint32ptr(1)}}, }, { - name: "HeadUint32PtrNotRootString", - expected: `{"A":{"a":"1"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - } -} -`, + name: "HeadUint32PtrNotRootString", data: struct { A struct { A *uint32 `json:"a,string"` @@ -900,15 +523,7 @@ null // HeadUint32PtrNilNotRoot { - name: "HeadUint32PtrNilNotRoot", - expected: `{"A":{"a":null}}`, - indentExpected: ` -{ - "A": { - "a": null - } -} -`, + name: "HeadUint32PtrNilNotRoot", data: struct { A struct { A *uint32 `json:"a"` @@ -916,13 +531,7 @@ null }{}, }, { - name: "HeadUint32PtrNilNotRootOmitEmpty", - expected: `{"A":{}}`, - indentExpected: ` -{ - "A": {} -} -`, + name: "HeadUint32PtrNilNotRootOmitEmpty", data: struct { A struct { A *uint32 `json:"a,omitempty"` @@ -930,15 +539,7 @@ null }{}, }, { - name: "HeadUint32PtrNilNotRootString", - expected: `{"A":{"a":null}}`, - indentExpected: ` -{ - "A": { - "a": null - } -} -`, + name: "HeadUint32PtrNilNotRootString", data: struct { A struct { A *uint32 `json:"a,string"` @@ -948,15 +549,7 @@ null // PtrHeadUint32ZeroNotRoot { - name: "PtrHeadUint32ZeroNotRoot", - expected: `{"A":{"a":0}}`, - indentExpected: ` -{ - "A": { - "a": 0 - } -} -`, + name: "PtrHeadUint32ZeroNotRoot", data: struct { A *struct { A uint32 `json:"a"` @@ -966,13 +559,7 @@ null })}, }, { - name: "PtrHeadUint32ZeroNotRootOmitEmpty", - expected: `{"A":{}}`, - indentExpected: ` -{ - "A": {} -} -`, + name: "PtrHeadUint32ZeroNotRootOmitEmpty", data: struct { A *struct { A uint32 `json:"a,omitempty"` @@ -982,15 +569,7 @@ null })}, }, { - name: "PtrHeadUint32ZeroNotRootString", - expected: `{"A":{"a":"0"}}`, - indentExpected: ` -{ - "A": { - "a": "0" - } -} -`, + name: "PtrHeadUint32ZeroNotRootString", data: struct { A *struct { A uint32 `json:"a,string"` @@ -1002,15 +581,7 @@ null // PtrHeadUint32NotRoot { - name: "PtrHeadUint32NotRoot", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "PtrHeadUint32NotRoot", data: struct { A *struct { A uint32 `json:"a"` @@ -1020,15 +591,7 @@ null }{A: 1})}, }, { - name: "PtrHeadUint32NotRootOmitEmpty", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "PtrHeadUint32NotRootOmitEmpty", data: struct { A *struct { A uint32 `json:"a,omitempty"` @@ -1038,15 +601,7 @@ null }{A: 1})}, }, { - name: "PtrHeadUint32NotRootString", - expected: `{"A":{"a":"1"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - } -} -`, + name: "PtrHeadUint32NotRootString", data: struct { A *struct { A uint32 `json:"a,string"` @@ -1058,15 +613,7 @@ null // PtrHeadUint32PtrNotRoot { - name: "PtrHeadUint32PtrNotRoot", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "PtrHeadUint32PtrNotRoot", data: struct { A *struct { A *uint32 `json:"a"` @@ -1076,15 +623,7 @@ null }{A: uint32ptr(1)})}, }, { - name: "PtrHeadUint32PtrNotRootOmitEmpty", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "PtrHeadUint32PtrNotRootOmitEmpty", data: struct { A *struct { A *uint32 `json:"a,omitempty"` @@ -1094,15 +633,7 @@ null }{A: uint32ptr(1)})}, }, { - name: "PtrHeadUint32PtrNotRootString", - expected: `{"A":{"a":"1"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - } -} -`, + name: "PtrHeadUint32PtrNotRootString", data: struct { A *struct { A *uint32 `json:"a,string"` @@ -1114,15 +645,7 @@ null // PtrHeadUint32PtrNilNotRoot { - name: "PtrHeadUint32PtrNilNotRoot", - expected: `{"A":{"a":null}}`, - indentExpected: ` -{ - "A": { - "a": null - } -} -`, + name: "PtrHeadUint32PtrNilNotRoot", data: struct { A *struct { A *uint32 `json:"a"` @@ -1132,13 +655,7 @@ null }{A: nil})}, }, { - name: "PtrHeadUint32PtrNilNotRootOmitEmpty", - expected: `{"A":{}}`, - indentExpected: ` -{ - "A": {} -} -`, + name: "PtrHeadUint32PtrNilNotRootOmitEmpty", data: struct { A *struct { A *uint32 `json:"a,omitempty"` @@ -1148,15 +665,7 @@ null }{A: nil})}, }, { - name: "PtrHeadUint32PtrNilNotRootString", - expected: `{"A":{"a":null}}`, - indentExpected: ` -{ - "A": { - "a": null - } -} -`, + name: "PtrHeadUint32PtrNilNotRootString", data: struct { A *struct { A *uint32 `json:"a,string"` @@ -1168,13 +677,7 @@ null // PtrHeadUint32NilNotRoot { - name: "PtrHeadUint32NilNotRoot", - expected: `{"A":null}`, - indentExpected: ` -{ - "A": null -} -`, + name: "PtrHeadUint32NilNotRoot", data: struct { A *struct { A *uint32 `json:"a"` @@ -1182,11 +685,7 @@ null }{A: nil}, }, { - name: "PtrHeadUint32NilNotRootOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadUint32NilNotRootOmitEmpty", data: struct { A *struct { A *uint32 `json:"a,omitempty"` @@ -1194,13 +693,7 @@ null }{A: nil}, }, { - name: "PtrHeadUint32NilNotRootString", - expected: `{"A":null}`, - indentExpected: ` -{ - "A": null -} -`, + name: "PtrHeadUint32NilNotRootString", data: struct { A *struct { A *uint32 `json:"a,string"` @@ -1210,18 +703,7 @@ null // HeadUint32ZeroMultiFieldsNotRoot { - name: "HeadUint32ZeroMultiFieldsNotRoot", - expected: `{"A":{"a":0},"B":{"b":0}}`, - indentExpected: ` -{ - "A": { - "a": 0 - }, - "B": { - "b": 0 - } -} -`, + name: "HeadUint32ZeroMultiFieldsNotRoot", data: struct { A struct { A uint32 `json:"a"` @@ -1232,14 +714,7 @@ null }{}, }, { - name: "HeadUint32ZeroMultiFieldsNotRootOmitEmpty", - expected: `{"A":{},"B":{}}`, - indentExpected: ` -{ - "A": {}, - "B": {} -} -`, + name: "HeadUint32ZeroMultiFieldsNotRootOmitEmpty", data: struct { A struct { A uint32 `json:"a,omitempty"` @@ -1250,18 +725,7 @@ null }{}, }, { - name: "HeadUint32ZeroMultiFieldsNotRootString", - expected: `{"A":{"a":"0"},"B":{"b":"0"}}`, - indentExpected: ` -{ - "A": { - "a": "0" - }, - "B": { - "b": "0" - } -} -`, + name: "HeadUint32ZeroMultiFieldsNotRootString", data: struct { A struct { A uint32 `json:"a,string"` @@ -1274,18 +738,7 @@ null // HeadUint32MultiFieldsNotRoot { - name: "HeadUint32MultiFieldsNotRoot", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "HeadUint32MultiFieldsNotRoot", data: struct { A struct { A uint32 `json:"a"` @@ -1300,18 +753,7 @@ null }{B: 2}}, }, { - name: "HeadUint32MultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "HeadUint32MultiFieldsNotRootOmitEmpty", data: struct { A struct { A uint32 `json:"a,omitempty"` @@ -1326,18 +768,7 @@ null }{B: 2}}, }, { - name: "HeadUint32MultiFieldsNotRootString", - expected: `{"A":{"a":"1"},"B":{"b":"2"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - }, - "B": { - "b": "2" - } -} -`, + name: "HeadUint32MultiFieldsNotRootString", data: struct { A struct { A uint32 `json:"a,string"` @@ -1354,18 +785,7 @@ null // HeadUint32PtrMultiFieldsNotRoot { - name: "HeadUint32PtrMultiFieldsNotRoot", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "HeadUint32PtrMultiFieldsNotRoot", data: struct { A struct { A *uint32 `json:"a"` @@ -1380,18 +800,7 @@ null }{B: uint32ptr(2)}}, }, { - name: "HeadUint32PtrMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "HeadUint32PtrMultiFieldsNotRootOmitEmpty", data: struct { A struct { A *uint32 `json:"a,omitempty"` @@ -1406,18 +815,7 @@ null }{B: uint32ptr(2)}}, }, { - name: "HeadUint32PtrMultiFieldsNotRootString", - expected: `{"A":{"a":"1"},"B":{"b":"2"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - }, - "B": { - "b": "2" - } -} -`, + name: "HeadUint32PtrMultiFieldsNotRootString", data: struct { A struct { A *uint32 `json:"a,string"` @@ -1434,18 +832,7 @@ null // HeadUint32PtrNilMultiFieldsNotRoot { - name: "HeadUint32PtrNilMultiFieldsNotRoot", - expected: `{"A":{"a":null},"B":{"b":null}}`, - indentExpected: ` -{ - "A": { - "a": null - }, - "B": { - "b": null - } -} -`, + name: "HeadUint32PtrNilMultiFieldsNotRoot", data: struct { A struct { A *uint32 `json:"a"` @@ -1460,14 +847,7 @@ null }{B: nil}}, }, { - name: "HeadUint32PtrNilMultiFieldsNotRootOmitEmpty", - expected: `{"A":{},"B":{}}`, - indentExpected: ` -{ - "A": {}, - "B": {} -} -`, + name: "HeadUint32PtrNilMultiFieldsNotRootOmitEmpty", data: struct { A struct { A *uint32 `json:"a,omitempty"` @@ -1482,18 +862,7 @@ null }{B: nil}}, }, { - name: "HeadUint32PtrNilMultiFieldsNotRootString", - expected: `{"A":{"a":null},"B":{"b":null}}`, - indentExpected: ` -{ - "A": { - "a": null - }, - "B": { - "b": null - } -} -`, + name: "HeadUint32PtrNilMultiFieldsNotRootString", data: struct { A struct { A *uint32 `json:"a,string"` @@ -1510,18 +879,7 @@ null // PtrHeadUint32ZeroMultiFieldsNotRoot { - name: "PtrHeadUint32ZeroMultiFieldsNotRoot", - expected: `{"A":{"a":0},"B":{"b":0}}`, - indentExpected: ` -{ - "A": { - "a": 0 - }, - "B": { - "b": 0 - } -} -`, + name: "PtrHeadUint32ZeroMultiFieldsNotRoot", data: &struct { A struct { A uint32 `json:"a"` @@ -1532,14 +890,7 @@ null }{}, }, { - name: "PtrHeadUint32ZeroMultiFieldsNotRootOmitEmpty", - expected: `{"A":{},"B":{}}`, - indentExpected: ` -{ - "A": {}, - "B": {} -} -`, + name: "PtrHeadUint32ZeroMultiFieldsNotRootOmitEmpty", data: &struct { A struct { A uint32 `json:"a,omitempty"` @@ -1550,18 +901,7 @@ null }{}, }, { - name: "PtrHeadUint32ZeroMultiFieldsNotRootString", - expected: `{"A":{"a":"0"},"B":{"b":"0"}}`, - indentExpected: ` -{ - "A": { - "a": "0" - }, - "B": { - "b": "0" - } -} -`, + name: "PtrHeadUint32ZeroMultiFieldsNotRootString", data: &struct { A struct { A uint32 `json:"a,string"` @@ -1574,18 +914,7 @@ null // PtrHeadUint32MultiFieldsNotRoot { - name: "PtrHeadUint32MultiFieldsNotRoot", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "PtrHeadUint32MultiFieldsNotRoot", data: &struct { A struct { A uint32 `json:"a"` @@ -1600,18 +929,7 @@ null }{B: 2}}, }, { - name: "PtrHeadUint32MultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "PtrHeadUint32MultiFieldsNotRootOmitEmpty", data: &struct { A struct { A uint32 `json:"a,omitempty"` @@ -1626,18 +944,7 @@ null }{B: 2}}, }, { - name: "PtrHeadUint32MultiFieldsNotRootString", - expected: `{"A":{"a":"1"},"B":{"b":"2"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - }, - "B": { - "b": "2" - } -} -`, + name: "PtrHeadUint32MultiFieldsNotRootString", data: &struct { A struct { A uint32 `json:"a,string"` @@ -1654,18 +961,7 @@ null // PtrHeadUint32PtrMultiFieldsNotRoot { - name: "PtrHeadUint32PtrMultiFieldsNotRoot", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "PtrHeadUint32PtrMultiFieldsNotRoot", data: &struct { A *struct { A *uint32 `json:"a"` @@ -1680,18 +976,7 @@ null }{B: uint32ptr(2)})}, }, { - name: "PtrHeadUint32PtrMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "PtrHeadUint32PtrMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A *uint32 `json:"a,omitempty"` @@ -1706,18 +991,7 @@ null }{B: uint32ptr(2)})}, }, { - name: "PtrHeadUint32PtrMultiFieldsNotRootString", - expected: `{"A":{"a":"1"},"B":{"b":"2"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - }, - "B": { - "b": "2" - } -} -`, + name: "PtrHeadUint32PtrMultiFieldsNotRootString", data: &struct { A *struct { A *uint32 `json:"a,string"` @@ -1734,14 +1008,7 @@ null // PtrHeadUint32PtrNilMultiFieldsNotRoot { - name: "PtrHeadUint32PtrNilMultiFieldsNotRoot", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadUint32PtrNilMultiFieldsNotRoot", data: &struct { A *struct { A *uint32 `json:"a"` @@ -1752,11 +1019,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadUint32PtrNilMultiFieldsNotRootOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadUint32PtrNilMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A *uint32 `json:"a,omitempty"` @@ -1767,14 +1030,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadUint32PtrNilMultiFieldsNotRootString", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadUint32PtrNilMultiFieldsNotRootString", data: &struct { A *struct { A *uint32 `json:"a,string"` @@ -1787,11 +1043,7 @@ null // PtrHeadUint32NilMultiFieldsNotRoot { - name: "PtrHeadUint32NilMultiFieldsNotRoot", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint32NilMultiFieldsNotRoot", data: (*struct { A *struct { A *uint32 `json:"a"` @@ -1802,11 +1054,7 @@ null })(nil), }, { - name: "PtrHeadUint32NilMultiFieldsNotRootOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint32NilMultiFieldsNotRootOmitEmpty", data: (*struct { A *struct { A *uint32 `json:"a,omitempty"` @@ -1817,11 +1065,7 @@ null })(nil), }, { - name: "PtrHeadUint32NilMultiFieldsNotRootString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint32NilMultiFieldsNotRootString", data: (*struct { A *struct { A *uint32 `json:"a,string"` @@ -1834,20 +1078,7 @@ null // PtrHeadUint32DoubleMultiFieldsNotRoot { - name: "PtrHeadUint32DoubleMultiFieldsNotRoot", - expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`, - indentExpected: ` -{ - "A": { - "a": 1, - "b": 2 - }, - "B": { - "a": 3, - "b": 4 - } -} -`, + name: "PtrHeadUint32DoubleMultiFieldsNotRoot", data: &struct { A *struct { A uint32 `json:"a"` @@ -1866,20 +1097,7 @@ null }{A: 3, B: 4})}, }, { - name: "PtrHeadUint32DoubleMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`, - indentExpected: ` -{ - "A": { - "a": 1, - "b": 2 - }, - "B": { - "a": 3, - "b": 4 - } -} -`, + name: "PtrHeadUint32DoubleMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A uint32 `json:"a,omitempty"` @@ -1898,20 +1116,7 @@ null }{A: 3, B: 4})}, }, { - name: "PtrHeadUint32DoubleMultiFieldsNotRootString", - expected: `{"A":{"a":"1","b":"2"},"B":{"a":"3","b":"4"}}`, - indentExpected: ` -{ - "A": { - "a": "1", - "b": "2" - }, - "B": { - "a": "3", - "b": "4" - } -} -`, + name: "PtrHeadUint32DoubleMultiFieldsNotRootString", data: &struct { A *struct { A uint32 `json:"a,string"` @@ -1932,14 +1137,7 @@ null // PtrHeadUint32NilDoubleMultiFieldsNotRoot { - name: "PtrHeadUint32NilDoubleMultiFieldsNotRoot", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadUint32NilDoubleMultiFieldsNotRoot", data: &struct { A *struct { A uint32 `json:"a"` @@ -1952,11 +1150,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadUint32NilDoubleMultiFieldsNotRootOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadUint32NilDoubleMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A uint32 `json:"a,omitempty"` @@ -1969,14 +1163,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadUint32NilDoubleMultiFieldsNotRootString", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadUint32NilDoubleMultiFieldsNotRootString", data: &struct { A *struct { A uint32 `json:"a,string"` @@ -1991,11 +1178,7 @@ null // PtrHeadUint32NilDoubleMultiFieldsNotRoot { - name: "PtrHeadUint32NilDoubleMultiFieldsNotRoot", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint32NilDoubleMultiFieldsNotRoot", data: (*struct { A *struct { A uint32 `json:"a"` @@ -2008,11 +1191,7 @@ null })(nil), }, { - name: "PtrHeadUint32NilDoubleMultiFieldsNotRootOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint32NilDoubleMultiFieldsNotRootOmitEmpty", data: (*struct { A *struct { A uint32 `json:"a,omitempty"` @@ -2025,11 +1204,7 @@ null })(nil), }, { - name: "PtrHeadUint32NilDoubleMultiFieldsNotRootString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint32NilDoubleMultiFieldsNotRootString", data: (*struct { A *struct { A uint32 `json:"a,string"` @@ -2044,20 +1219,7 @@ null // PtrHeadUint32PtrDoubleMultiFieldsNotRoot { - name: "PtrHeadUint32PtrDoubleMultiFieldsNotRoot", - expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`, - indentExpected: ` -{ - "A": { - "a": 1, - "b": 2 - }, - "B": { - "a": 3, - "b": 4 - } -} -`, + name: "PtrHeadUint32PtrDoubleMultiFieldsNotRoot", data: &struct { A *struct { A *uint32 `json:"a"` @@ -2076,20 +1238,7 @@ null }{A: uint32ptr(3), B: uint32ptr(4)})}, }, { - name: "PtrHeadUint32PtrDoubleMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`, - indentExpected: ` -{ - "A": { - "a": 1, - "b": 2 - }, - "B": { - "a": 3, - "b": 4 - } -} -`, + name: "PtrHeadUint32PtrDoubleMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A *uint32 `json:"a,omitempty"` @@ -2108,20 +1257,7 @@ null }{A: uint32ptr(3), B: uint32ptr(4)})}, }, { - name: "PtrHeadUint32PtrDoubleMultiFieldsNotRootString", - expected: `{"A":{"a":"1","b":"2"},"B":{"a":"3","b":"4"}}`, - indentExpected: ` -{ - "A": { - "a": "1", - "b": "2" - }, - "B": { - "a": "3", - "b": "4" - } -} -`, + name: "PtrHeadUint32PtrDoubleMultiFieldsNotRootString", data: &struct { A *struct { A *uint32 `json:"a,string"` @@ -2142,14 +1278,7 @@ null // PtrHeadUint32PtrNilDoubleMultiFieldsNotRoot { - name: "PtrHeadUint32PtrNilDoubleMultiFieldsNotRoot", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadUint32PtrNilDoubleMultiFieldsNotRoot", data: &struct { A *struct { A *uint32 `json:"a"` @@ -2162,11 +1291,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadUint32PtrNilDoubleMultiFieldsNotRootOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadUint32PtrNilDoubleMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A *uint32 `json:"a,omitempty"` @@ -2179,14 +1304,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadUint32PtrNilDoubleMultiFieldsNotRootString", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadUint32PtrNilDoubleMultiFieldsNotRootString", data: &struct { A *struct { A *uint32 `json:"a,string"` @@ -2201,11 +1319,7 @@ null // PtrHeadUint32PtrNilDoubleMultiFieldsNotRoot { - name: "PtrHeadUint32PtrNilDoubleMultiFieldsNotRoot", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint32PtrNilDoubleMultiFieldsNotRoot", data: (*struct { A *struct { A *uint32 `json:"a"` @@ -2218,11 +1332,7 @@ null })(nil), }, { - name: "PtrHeadUint32PtrNilDoubleMultiFieldsNotRootOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint32PtrNilDoubleMultiFieldsNotRootOmitEmpty", data: (*struct { A *struct { A *uint32 `json:"a,omitempty"` @@ -2235,11 +1345,7 @@ null })(nil), }, { - name: "PtrHeadUint32PtrNilDoubleMultiFieldsNotRootString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint32PtrNilDoubleMultiFieldsNotRootString", data: (*struct { A *struct { A *uint32 `json:"a,string"` @@ -2254,14 +1360,7 @@ null // AnonymousHeadUint32 { - name: "AnonymousHeadUint32", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "AnonymousHeadUint32", data: struct { structUint32 B uint32 `json:"b"` @@ -2271,14 +1370,7 @@ null }, }, { - name: "AnonymousHeadUint32OmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "AnonymousHeadUint32OmitEmpty", data: struct { structUint32OmitEmpty B uint32 `json:"b,omitempty"` @@ -2288,14 +1380,7 @@ null }, }, { - name: "AnonymousHeadUint32String", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "AnonymousHeadUint32String", data: struct { structUint32String B uint32 `json:"b,string"` @@ -2307,14 +1392,7 @@ null // PtrAnonymousHeadUint32 { - name: "PtrAnonymousHeadUint32", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrAnonymousHeadUint32", data: struct { *structUint32 B uint32 `json:"b"` @@ -2324,14 +1402,7 @@ null }, }, { - name: "PtrAnonymousHeadUint32OmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrAnonymousHeadUint32OmitEmpty", data: struct { *structUint32OmitEmpty B uint32 `json:"b,omitempty"` @@ -2341,14 +1412,7 @@ null }, }, { - name: "PtrAnonymousHeadUint32String", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "PtrAnonymousHeadUint32String", data: struct { *structUint32String B uint32 `json:"b,string"` @@ -2360,13 +1424,7 @@ null // NilPtrAnonymousHeadUint32 { - name: "NilPtrAnonymousHeadUint32", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "NilPtrAnonymousHeadUint32", data: struct { *structUint32 B uint32 `json:"b"` @@ -2376,13 +1434,7 @@ null }, }, { - name: "NilPtrAnonymousHeadUint32OmitEmpty", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "NilPtrAnonymousHeadUint32OmitEmpty", data: struct { *structUint32OmitEmpty B uint32 `json:"b,omitempty"` @@ -2392,13 +1444,7 @@ null }, }, { - name: "NilPtrAnonymousHeadUint32String", - expected: `{"b":"2"}`, - indentExpected: ` -{ - "b": "2" -} -`, + name: "NilPtrAnonymousHeadUint32String", data: struct { *structUint32String B uint32 `json:"b,string"` @@ -2410,14 +1456,7 @@ null // AnonymousHeadUint32Ptr { - name: "AnonymousHeadUint32Ptr", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "AnonymousHeadUint32Ptr", data: struct { structUint32Ptr B *uint32 `json:"b"` @@ -2427,14 +1466,7 @@ null }, }, { - name: "AnonymousHeadUint32PtrOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "AnonymousHeadUint32PtrOmitEmpty", data: struct { structUint32PtrOmitEmpty B *uint32 `json:"b,omitempty"` @@ -2444,14 +1476,7 @@ null }, }, { - name: "AnonymousHeadUint32PtrString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "AnonymousHeadUint32PtrString", data: struct { structUint32PtrString B *uint32 `json:"b,string"` @@ -2463,14 +1488,7 @@ null // AnonymousHeadUint32PtrNil { - name: "AnonymousHeadUint32PtrNil", - expected: `{"a":null,"b":2}`, - indentExpected: ` -{ - "a": null, - "b": 2 -} -`, + name: "AnonymousHeadUint32PtrNil", data: struct { structUint32Ptr B *uint32 `json:"b"` @@ -2480,13 +1498,7 @@ null }, }, { - name: "AnonymousHeadUint32PtrNilOmitEmpty", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "AnonymousHeadUint32PtrNilOmitEmpty", data: struct { structUint32PtrOmitEmpty B *uint32 `json:"b,omitempty"` @@ -2496,14 +1508,7 @@ null }, }, { - name: "AnonymousHeadUint32PtrNilString", - expected: `{"a":null,"b":"2"}`, - indentExpected: ` -{ - "a": null, - "b": "2" -} -`, + name: "AnonymousHeadUint32PtrNilString", data: struct { structUint32PtrString B *uint32 `json:"b,string"` @@ -2515,14 +1520,7 @@ null // PtrAnonymousHeadUint32Ptr { - name: "PtrAnonymousHeadUint32Ptr", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrAnonymousHeadUint32Ptr", data: struct { *structUint32Ptr B *uint32 `json:"b"` @@ -2532,14 +1530,7 @@ null }, }, { - name: "PtrAnonymousHeadUint32PtrOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrAnonymousHeadUint32PtrOmitEmpty", data: struct { *structUint32PtrOmitEmpty B *uint32 `json:"b,omitempty"` @@ -2549,14 +1540,7 @@ null }, }, { - name: "PtrAnonymousHeadUint32PtrString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "PtrAnonymousHeadUint32PtrString", data: struct { *structUint32PtrString B *uint32 `json:"b,string"` @@ -2568,13 +1552,7 @@ null // NilPtrAnonymousHeadUint32Ptr { - name: "NilPtrAnonymousHeadUint32Ptr", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "NilPtrAnonymousHeadUint32Ptr", data: struct { *structUint32Ptr B *uint32 `json:"b"` @@ -2584,13 +1562,7 @@ null }, }, { - name: "NilPtrAnonymousHeadUint32PtrOmitEmpty", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "NilPtrAnonymousHeadUint32PtrOmitEmpty", data: struct { *structUint32PtrOmitEmpty B *uint32 `json:"b,omitempty"` @@ -2600,13 +1572,7 @@ null }, }, { - name: "NilPtrAnonymousHeadUint32PtrString", - expected: `{"b":"2"}`, - indentExpected: ` -{ - "b": "2" -} -`, + name: "NilPtrAnonymousHeadUint32PtrString", data: struct { *structUint32PtrString B *uint32 `json:"b,string"` @@ -2618,13 +1584,7 @@ null // AnonymousHeadUint32Only { - name: "AnonymousHeadUint32Only", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "AnonymousHeadUint32Only", data: struct { structUint32 }{ @@ -2632,13 +1592,7 @@ null }, }, { - name: "AnonymousHeadUint32OnlyOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "AnonymousHeadUint32OnlyOmitEmpty", data: struct { structUint32OmitEmpty }{ @@ -2646,13 +1600,7 @@ null }, }, { - name: "AnonymousHeadUint32OnlyString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "AnonymousHeadUint32OnlyString", data: struct { structUint32String }{ @@ -2662,13 +1610,7 @@ null // PtrAnonymousHeadUint32Only { - name: "PtrAnonymousHeadUint32Only", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrAnonymousHeadUint32Only", data: struct { *structUint32 }{ @@ -2676,13 +1618,7 @@ null }, }, { - name: "PtrAnonymousHeadUint32OnlyOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrAnonymousHeadUint32OnlyOmitEmpty", data: struct { *structUint32OmitEmpty }{ @@ -2690,13 +1626,7 @@ null }, }, { - name: "PtrAnonymousHeadUint32OnlyString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "PtrAnonymousHeadUint32OnlyString", data: struct { *structUint32String }{ @@ -2706,11 +1636,7 @@ null // NilPtrAnonymousHeadUint32Only { - name: "NilPtrAnonymousHeadUint32Only", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadUint32Only", data: struct { *structUint32 }{ @@ -2718,11 +1644,7 @@ null }, }, { - name: "NilPtrAnonymousHeadUint32OnlyOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadUint32OnlyOmitEmpty", data: struct { *structUint32OmitEmpty }{ @@ -2730,11 +1652,7 @@ null }, }, { - name: "NilPtrAnonymousHeadUint32OnlyString", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadUint32OnlyString", data: struct { *structUint32String }{ @@ -2744,13 +1662,7 @@ null // AnonymousHeadUint32PtrOnly { - name: "AnonymousHeadUint32PtrOnly", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "AnonymousHeadUint32PtrOnly", data: struct { structUint32Ptr }{ @@ -2758,13 +1670,7 @@ null }, }, { - name: "AnonymousHeadUint32PtrOnlyOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "AnonymousHeadUint32PtrOnlyOmitEmpty", data: struct { structUint32PtrOmitEmpty }{ @@ -2772,13 +1678,7 @@ null }, }, { - name: "AnonymousHeadUint32PtrOnlyString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "AnonymousHeadUint32PtrOnlyString", data: struct { structUint32PtrString }{ @@ -2788,13 +1688,7 @@ null // AnonymousHeadUint32PtrNilOnly { - name: "AnonymousHeadUint32PtrNilOnly", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "AnonymousHeadUint32PtrNilOnly", data: struct { structUint32Ptr }{ @@ -2802,11 +1696,7 @@ null }, }, { - name: "AnonymousHeadUint32PtrNilOnlyOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "AnonymousHeadUint32PtrNilOnlyOmitEmpty", data: struct { structUint32PtrOmitEmpty }{ @@ -2814,13 +1704,7 @@ null }, }, { - name: "AnonymousHeadUint32PtrNilOnlyString", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "AnonymousHeadUint32PtrNilOnlyString", data: struct { structUint32PtrString }{ @@ -2830,13 +1714,7 @@ null // PtrAnonymousHeadUint32PtrOnly { - name: "PtrAnonymousHeadUint32PtrOnly", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrAnonymousHeadUint32PtrOnly", data: struct { *structUint32Ptr }{ @@ -2844,13 +1722,7 @@ null }, }, { - name: "PtrAnonymousHeadUint32PtrOnlyOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrAnonymousHeadUint32PtrOnlyOmitEmpty", data: struct { *structUint32PtrOmitEmpty }{ @@ -2858,13 +1730,7 @@ null }, }, { - name: "PtrAnonymousHeadUint32PtrOnlyString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "PtrAnonymousHeadUint32PtrOnlyString", data: struct { *structUint32PtrString }{ @@ -2874,11 +1740,7 @@ null // NilPtrAnonymousHeadUint32PtrOnly { - name: "NilPtrAnonymousHeadUint32PtrOnly", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadUint32PtrOnly", data: struct { *structUint32Ptr }{ @@ -2886,11 +1748,7 @@ null }, }, { - name: "NilPtrAnonymousHeadUint32PtrOnlyOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadUint32PtrOnlyOmitEmpty", data: struct { *structUint32PtrOmitEmpty }{ @@ -2898,11 +1756,7 @@ null }, }, { - name: "NilPtrAnonymousHeadUint32PtrOnlyString", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadUint32PtrOnlyString", data: struct { *structUint32PtrString }{ @@ -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()) - } - } } } } From 77dd50697ff9b3c37d4a0addff32c6d6e5848106 Mon Sep 17 00:00:00 2001 From: Masaaki Goshima Date: Mon, 15 Feb 2021 11:28:09 +0900 Subject: [PATCH 10/15] Refactor cover_uint64_test.go --- cover_uint64_test.go | 1540 ++++++------------------------------------ 1 file changed, 192 insertions(+), 1348 deletions(-) diff --git a/cover_uint64_test.go b/cover_uint64_test.go index 92f6c46..354cda5 100644 --- a/cover_uint64_test.go +++ b/cover_uint64_test.go @@ -2,7 +2,6 @@ package json_test import ( "bytes" - "strings" "testing" "github.com/goccy/go-json" @@ -30,42 +29,24 @@ func TestCoverUint64(t *testing.T) { } tests := []struct { - name string - expected string - indentExpected string - data interface{} + name string + data interface{} }{ // HeadUint64Zero { - name: "HeadUint64Zero", - expected: `{"a":0}`, - indentExpected: ` -{ - "a": 0 -} -`, + name: "HeadUint64Zero", data: struct { A uint64 `json:"a"` }{}, }, { - name: "HeadUint64ZeroOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "HeadUint64ZeroOmitEmpty", data: struct { A uint64 `json:"a,omitempty"` }{}, }, { - name: "HeadUint64ZeroString", - expected: `{"a":"0"}`, - indentExpected: ` -{ - "a": "0" -} -`, + name: "HeadUint64ZeroString", data: struct { A uint64 `json:"a,string"` }{}, @@ -73,37 +54,19 @@ func TestCoverUint64(t *testing.T) { // HeadUint64 { - name: "HeadUint64", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "HeadUint64", data: struct { A uint64 `json:"a"` }{A: 1}, }, { - name: "HeadUint64OmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "HeadUint64OmitEmpty", data: struct { A uint64 `json:"a,omitempty"` }{A: 1}, }, { - name: "HeadUint64String", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "HeadUint64String", data: struct { A uint64 `json:"a,string"` }{A: 1}, @@ -111,37 +74,19 @@ func TestCoverUint64(t *testing.T) { // HeadUint64Ptr { - name: "HeadUint64Ptr", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "HeadUint64Ptr", data: struct { A *uint64 `json:"a"` }{A: uint64ptr(1)}, }, { - name: "HeadUint64PtrOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "HeadUint64PtrOmitEmpty", data: struct { A *uint64 `json:"a,omitempty"` }{A: uint64ptr(1)}, }, { - name: "HeadUint64PtrString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "HeadUint64PtrString", data: struct { A *uint64 `json:"a,string"` }{A: uint64ptr(1)}, @@ -149,35 +94,19 @@ func TestCoverUint64(t *testing.T) { // HeadUint64PtrNil { - name: "HeadUint64PtrNil", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "HeadUint64PtrNil", data: struct { A *uint64 `json:"a"` }{A: nil}, }, { - name: "HeadUint64PtrNilOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "HeadUint64PtrNilOmitEmpty", data: struct { A *uint64 `json:"a,omitempty"` }{A: nil}, }, { - name: "HeadUint64PtrNilString", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "HeadUint64PtrNilString", data: struct { A *uint64 `json:"a,string"` }{A: nil}, @@ -185,35 +114,19 @@ func TestCoverUint64(t *testing.T) { // PtrHeadUint64Zero { - name: "PtrHeadUint64Zero", - expected: `{"a":0}`, - indentExpected: ` -{ - "a": 0 -} -`, + name: "PtrHeadUint64Zero", data: &struct { A uint64 `json:"a"` }{}, }, { - name: "PtrHeadUint64ZeroOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadUint64ZeroOmitEmpty", data: &struct { A uint64 `json:"a,omitempty"` }{}, }, { - name: "PtrHeadUint64ZeroString", - expected: `{"a":"0"}`, - indentExpected: ` -{ - "a": "0" -} -`, + name: "PtrHeadUint64ZeroString", data: &struct { A uint64 `json:"a,string"` }{}, @@ -221,37 +134,19 @@ func TestCoverUint64(t *testing.T) { // PtrHeadUint64 { - name: "PtrHeadUint64", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrHeadUint64", data: &struct { A uint64 `json:"a"` }{A: 1}, }, { - name: "PtrHeadUint64OmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrHeadUint64OmitEmpty", data: &struct { A uint64 `json:"a,omitempty"` }{A: 1}, }, { - name: "PtrHeadUint64String", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "PtrHeadUint64String", data: &struct { A uint64 `json:"a,string"` }{A: 1}, @@ -259,37 +154,19 @@ func TestCoverUint64(t *testing.T) { // PtrHeadUint64Ptr { - name: "PtrHeadUint64Ptr", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrHeadUint64Ptr", data: &struct { A *uint64 `json:"a"` }{A: uint64ptr(1)}, }, { - name: "PtrHeadUint64PtrOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrHeadUint64PtrOmitEmpty", data: &struct { A *uint64 `json:"a,omitempty"` }{A: uint64ptr(1)}, }, { - name: "PtrHeadUint64PtrString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "PtrHeadUint64PtrString", data: &struct { A *uint64 `json:"a,string"` }{A: uint64ptr(1)}, @@ -297,35 +174,19 @@ func TestCoverUint64(t *testing.T) { // PtrHeadUint64PtrNil { - name: "PtrHeadUint64PtrNil", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "PtrHeadUint64PtrNil", data: &struct { A *uint64 `json:"a"` }{A: nil}, }, { - name: "PtrHeadUint64PtrNilOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadUint64PtrNilOmitEmpty", data: &struct { A *uint64 `json:"a,omitempty"` }{A: nil}, }, { - name: "PtrHeadUint64PtrNilString", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "PtrHeadUint64PtrNilString", data: &struct { A *uint64 `json:"a,string"` }{A: nil}, @@ -333,31 +194,19 @@ func TestCoverUint64(t *testing.T) { // PtrHeadUint64Nil { - name: "PtrHeadUint64Nil", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint64Nil", data: (*struct { A *uint64 `json:"a"` })(nil), }, { - name: "PtrHeadUint64NilOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint64NilOmitEmpty", data: (*struct { A *uint64 `json:"a,omitempty"` })(nil), }, { - name: "PtrHeadUint64NilString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint64NilString", data: (*struct { A *uint64 `json:"a,string"` })(nil), @@ -365,209 +214,125 @@ null // HeadUint64ZeroMultiFields { - name: "HeadUint64ZeroMultiFields", - expected: `{"a":0,"b":0}`, - indentExpected: ` -{ - "a": 0, - "b": 0 -} -`, + name: "HeadUint64ZeroMultiFields", data: struct { A uint64 `json:"a"` B uint64 `json:"b"` + C uint64 `json:"c"` }{}, }, { - name: "HeadUint64ZeroMultiFieldsOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "HeadUint64ZeroMultiFieldsOmitEmpty", data: struct { A uint64 `json:"a,omitempty"` B uint64 `json:"b,omitempty"` + C uint64 `json:"c,omitempty"` }{}, }, { - name: "HeadUint64ZeroMultiFields", - expected: `{"a":"0","b":"0"}`, - indentExpected: ` -{ - "a": "0", - "b": "0" -} -`, + name: "HeadUint64ZeroMultiFields", data: struct { A uint64 `json:"a,string"` B uint64 `json:"b,string"` + C uint64 `json:"c,string"` }{}, }, // HeadUint64MultiFields { - name: "HeadUint64MultiFields", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "HeadUint64MultiFields", data: struct { A uint64 `json:"a"` B uint64 `json:"b"` - }{A: 1, B: 2}, + C uint64 `json:"c"` + }{A: 1, B: 2, C: 3}, }, { - name: "HeadUint64MultiFieldsOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "HeadUint64MultiFieldsOmitEmpty", data: struct { A uint64 `json:"a,omitempty"` B uint64 `json:"b,omitempty"` - }{A: 1, B: 2}, + C uint64 `json:"c,omitempty"` + }{A: 1, B: 2, C: 3}, }, { - name: "HeadUint64MultiFieldsString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "HeadUint64MultiFieldsString", data: struct { A uint64 `json:"a,string"` B uint64 `json:"b,string"` - }{A: 1, B: 2}, + C uint64 `json:"c,string"` + }{A: 1, B: 2, C: 3}, }, // HeadUint64PtrMultiFields { - name: "HeadUint64PtrMultiFields", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "HeadUint64PtrMultiFields", data: struct { A *uint64 `json:"a"` B *uint64 `json:"b"` - }{A: uint64ptr(1), B: uint64ptr(2)}, + C *uint64 `json:"c"` + }{A: uint64ptr(1), B: uint64ptr(2), C: uint64ptr(3)}, }, { - name: "HeadUint64PtrMultiFieldsOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "HeadUint64PtrMultiFieldsOmitEmpty", data: struct { A *uint64 `json:"a,omitempty"` B *uint64 `json:"b,omitempty"` - }{A: uint64ptr(1), B: uint64ptr(2)}, + C *uint64 `json:"c,omitempty"` + }{A: uint64ptr(1), B: uint64ptr(2), C: uint64ptr(3)}, }, { - name: "HeadUint64PtrMultiFieldsString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "HeadUint64PtrMultiFieldsString", data: struct { A *uint64 `json:"a,string"` B *uint64 `json:"b,string"` - }{A: uint64ptr(1), B: uint64ptr(2)}, + C *uint64 `json:"c,string"` + }{A: uint64ptr(1), B: uint64ptr(2), C: uint64ptr(3)}, }, // HeadUint64PtrNilMultiFields { - name: "HeadUint64PtrNilMultiFields", - expected: `{"a":null,"b":null}`, - indentExpected: ` -{ - "a": null, - "b": null -} -`, + name: "HeadUint64PtrNilMultiFields", data: struct { A *uint64 `json:"a"` B *uint64 `json:"b"` - }{A: nil, B: nil}, + C *uint64 `json:"c"` + }{A: nil, B: nil, C: nil}, }, { - name: "HeadUint64PtrNilMultiFieldsOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "HeadUint64PtrNilMultiFieldsOmitEmpty", data: struct { A *uint64 `json:"a,omitempty"` B *uint64 `json:"b,omitempty"` - }{A: nil, B: nil}, + C *uint64 `json:"c,omitempty"` + }{A: nil, B: nil, C: nil}, }, { - name: "HeadUint64PtrNilMultiFieldsString", - expected: `{"a":null,"b":null}`, - indentExpected: ` -{ - "a": null, - "b": null -} -`, + name: "HeadUint64PtrNilMultiFieldsString", data: struct { A *uint64 `json:"a,string"` B *uint64 `json:"b,string"` - }{A: nil, B: nil}, + C *uint64 `json:"c,string"` + }{A: nil, B: nil, C: nil}, }, // PtrHeadUint64ZeroMultiFields { - name: "PtrHeadUint64ZeroMultiFields", - expected: `{"a":0,"b":0}`, - indentExpected: ` -{ - "a": 0, - "b": 0 -} -`, + name: "PtrHeadUint64ZeroMultiFields", data: &struct { A uint64 `json:"a"` B uint64 `json:"b"` }{}, }, { - name: "PtrHeadUint64ZeroMultiFieldsOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadUint64ZeroMultiFieldsOmitEmpty", data: &struct { A uint64 `json:"a,omitempty"` B uint64 `json:"b,omitempty"` }{}, }, { - name: "PtrHeadUint64ZeroMultiFieldsString", - expected: `{"a":"0","b":"0"}`, - indentExpected: ` -{ - "a": "0", - "b": "0" -} -`, + name: "PtrHeadUint64ZeroMultiFieldsString", data: &struct { A uint64 `json:"a,string"` B uint64 `json:"b,string"` @@ -576,42 +341,21 @@ null // PtrHeadUint64MultiFields { - name: "PtrHeadUint64MultiFields", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrHeadUint64MultiFields", data: &struct { A uint64 `json:"a"` B uint64 `json:"b"` }{A: 1, B: 2}, }, { - name: "PtrHeadUint64MultiFieldsOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrHeadUint64MultiFieldsOmitEmpty", data: &struct { A uint64 `json:"a,omitempty"` B uint64 `json:"b,omitempty"` }{A: 1, B: 2}, }, { - name: "PtrHeadUint64MultiFieldsString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "PtrHeadUint64MultiFieldsString", data: &struct { A uint64 `json:"a,string"` B uint64 `json:"b,string"` @@ -620,42 +364,21 @@ null // PtrHeadUint64PtrMultiFields { - name: "PtrHeadUint64PtrMultiFields", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrHeadUint64PtrMultiFields", data: &struct { A *uint64 `json:"a"` B *uint64 `json:"b"` }{A: uint64ptr(1), B: uint64ptr(2)}, }, { - name: "PtrHeadUint64PtrMultiFieldsOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrHeadUint64PtrMultiFieldsOmitEmpty", data: &struct { A *uint64 `json:"a,omitempty"` B *uint64 `json:"b,omitempty"` }{A: uint64ptr(1), B: uint64ptr(2)}, }, { - name: "PtrHeadUint64PtrMultiFieldsString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "PtrHeadUint64PtrMultiFieldsString", data: &struct { A *uint64 `json:"a,string"` B *uint64 `json:"b,string"` @@ -664,39 +387,21 @@ null // PtrHeadUint64PtrNilMultiFields { - name: "PtrHeadUint64PtrNilMultiFields", - expected: `{"a":null,"b":null}`, - indentExpected: ` -{ - "a": null, - "b": null -} -`, + name: "PtrHeadUint64PtrNilMultiFields", data: &struct { A *uint64 `json:"a"` B *uint64 `json:"b"` }{A: nil, B: nil}, }, { - name: "PtrHeadUint64PtrNilMultiFieldsOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadUint64PtrNilMultiFieldsOmitEmpty", data: &struct { A *uint64 `json:"a,omitempty"` B *uint64 `json:"b,omitempty"` }{A: nil, B: nil}, }, { - name: "PtrHeadUint64PtrNilMultiFieldsString", - expected: `{"a":null,"b":null}`, - indentExpected: ` -{ - "a": null, - "b": null -} -`, + name: "PtrHeadUint64PtrNilMultiFieldsString", data: &struct { A *uint64 `json:"a,string"` B *uint64 `json:"b,string"` @@ -705,33 +410,21 @@ null // PtrHeadUint64NilMultiFields { - name: "PtrHeadUint64NilMultiFields", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint64NilMultiFields", data: (*struct { A *uint64 `json:"a"` B *uint64 `json:"b"` })(nil), }, { - name: "PtrHeadUint64NilMultiFieldsOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint64NilMultiFieldsOmitEmpty", data: (*struct { A *uint64 `json:"a,omitempty"` B *uint64 `json:"b,omitempty"` })(nil), }, { - name: "PtrHeadUint64NilMultiFieldsString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint64NilMultiFieldsString", data: (*struct { A *uint64 `json:"a,string"` B *uint64 `json:"b,string"` @@ -740,15 +433,7 @@ null // HeadUint64ZeroNotRoot { - name: "HeadUint64ZeroNotRoot", - expected: `{"A":{"a":0}}`, - indentExpected: ` -{ - "A": { - "a": 0 - } -} -`, + name: "HeadUint64ZeroNotRoot", data: struct { A struct { A uint64 `json:"a"` @@ -756,13 +441,7 @@ null }{}, }, { - name: "HeadUint64ZeroNotRootOmitEmpty", - expected: `{"A":{}}`, - indentExpected: ` -{ - "A": {} -} -`, + name: "HeadUint64ZeroNotRootOmitEmpty", data: struct { A struct { A uint64 `json:"a,omitempty"` @@ -770,15 +449,7 @@ null }{}, }, { - name: "HeadUint64ZeroNotRootString", - expected: `{"A":{"a":"0"}}`, - indentExpected: ` -{ - "A": { - "a": "0" - } -} -`, + name: "HeadUint64ZeroNotRootString", data: struct { A struct { A uint64 `json:"a,string"` @@ -788,15 +459,7 @@ null // HeadUint64NotRoot { - name: "HeadUint64NotRoot", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "HeadUint64NotRoot", data: struct { A struct { A uint64 `json:"a"` @@ -806,15 +469,7 @@ null }{A: 1}}, }, { - name: "HeadUint64NotRootOmitEmpty", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "HeadUint64NotRootOmitEmpty", data: struct { A struct { A uint64 `json:"a,omitempty"` @@ -824,15 +479,7 @@ null }{A: 1}}, }, { - name: "HeadUint64NotRootString", - expected: `{"A":{"a":"1"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - } -} -`, + name: "HeadUint64NotRootString", data: struct { A struct { A uint64 `json:"a,string"` @@ -844,15 +491,7 @@ null // HeadUint64PtrNotRoot { - name: "HeadUint64PtrNotRoot", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "HeadUint64PtrNotRoot", data: struct { A struct { A *uint64 `json:"a"` @@ -862,15 +501,7 @@ null }{uint64ptr(1)}}, }, { - name: "HeadUint64PtrNotRootOmitEmpty", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "HeadUint64PtrNotRootOmitEmpty", data: struct { A struct { A *uint64 `json:"a,omitempty"` @@ -880,15 +511,7 @@ null }{uint64ptr(1)}}, }, { - name: "HeadUint64PtrNotRootString", - expected: `{"A":{"a":"1"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - } -} -`, + name: "HeadUint64PtrNotRootString", data: struct { A struct { A *uint64 `json:"a,string"` @@ -900,15 +523,7 @@ null // HeadUint64PtrNilNotRoot { - name: "HeadUint64PtrNilNotRoot", - expected: `{"A":{"a":null}}`, - indentExpected: ` -{ - "A": { - "a": null - } -} -`, + name: "HeadUint64PtrNilNotRoot", data: struct { A struct { A *uint64 `json:"a"` @@ -916,13 +531,7 @@ null }{}, }, { - name: "HeadUint64PtrNilNotRootOmitEmpty", - expected: `{"A":{}}`, - indentExpected: ` -{ - "A": {} -} -`, + name: "HeadUint64PtrNilNotRootOmitEmpty", data: struct { A struct { A *uint64 `json:"a,omitempty"` @@ -930,15 +539,7 @@ null }{}, }, { - name: "HeadUint64PtrNilNotRootString", - expected: `{"A":{"a":null}}`, - indentExpected: ` -{ - "A": { - "a": null - } -} -`, + name: "HeadUint64PtrNilNotRootString", data: struct { A struct { A *uint64 `json:"a,string"` @@ -948,15 +549,7 @@ null // PtrHeadUint64ZeroNotRoot { - name: "PtrHeadUint64ZeroNotRoot", - expected: `{"A":{"a":0}}`, - indentExpected: ` -{ - "A": { - "a": 0 - } -} -`, + name: "PtrHeadUint64ZeroNotRoot", data: struct { A *struct { A uint64 `json:"a"` @@ -966,13 +559,7 @@ null })}, }, { - name: "PtrHeadUint64ZeroNotRootOmitEmpty", - expected: `{"A":{}}`, - indentExpected: ` -{ - "A": {} -} -`, + name: "PtrHeadUint64ZeroNotRootOmitEmpty", data: struct { A *struct { A uint64 `json:"a,omitempty"` @@ -982,15 +569,7 @@ null })}, }, { - name: "PtrHeadUint64ZeroNotRootString", - expected: `{"A":{"a":"0"}}`, - indentExpected: ` -{ - "A": { - "a": "0" - } -} -`, + name: "PtrHeadUint64ZeroNotRootString", data: struct { A *struct { A uint64 `json:"a,string"` @@ -1002,15 +581,7 @@ null // PtrHeadUint64NotRoot { - name: "PtrHeadUint64NotRoot", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "PtrHeadUint64NotRoot", data: struct { A *struct { A uint64 `json:"a"` @@ -1020,15 +591,7 @@ null }{A: 1})}, }, { - name: "PtrHeadUint64NotRootOmitEmpty", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "PtrHeadUint64NotRootOmitEmpty", data: struct { A *struct { A uint64 `json:"a,omitempty"` @@ -1038,15 +601,7 @@ null }{A: 1})}, }, { - name: "PtrHeadUint64NotRootString", - expected: `{"A":{"a":"1"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - } -} -`, + name: "PtrHeadUint64NotRootString", data: struct { A *struct { A uint64 `json:"a,string"` @@ -1058,15 +613,7 @@ null // PtrHeadUint64PtrNotRoot { - name: "PtrHeadUint64PtrNotRoot", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "PtrHeadUint64PtrNotRoot", data: struct { A *struct { A *uint64 `json:"a"` @@ -1076,15 +623,7 @@ null }{A: uint64ptr(1)})}, }, { - name: "PtrHeadUint64PtrNotRootOmitEmpty", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "PtrHeadUint64PtrNotRootOmitEmpty", data: struct { A *struct { A *uint64 `json:"a,omitempty"` @@ -1094,15 +633,7 @@ null }{A: uint64ptr(1)})}, }, { - name: "PtrHeadUint64PtrNotRootString", - expected: `{"A":{"a":"1"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - } -} -`, + name: "PtrHeadUint64PtrNotRootString", data: struct { A *struct { A *uint64 `json:"a,string"` @@ -1114,15 +645,7 @@ null // PtrHeadUint64PtrNilNotRoot { - name: "PtrHeadUint64PtrNilNotRoot", - expected: `{"A":{"a":null}}`, - indentExpected: ` -{ - "A": { - "a": null - } -} -`, + name: "PtrHeadUint64PtrNilNotRoot", data: struct { A *struct { A *uint64 `json:"a"` @@ -1132,13 +655,7 @@ null }{A: nil})}, }, { - name: "PtrHeadUint64PtrNilNotRootOmitEmpty", - expected: `{"A":{}}`, - indentExpected: ` -{ - "A": {} -} -`, + name: "PtrHeadUint64PtrNilNotRootOmitEmpty", data: struct { A *struct { A *uint64 `json:"a,omitempty"` @@ -1148,15 +665,7 @@ null }{A: nil})}, }, { - name: "PtrHeadUint64PtrNilNotRootString", - expected: `{"A":{"a":null}}`, - indentExpected: ` -{ - "A": { - "a": null - } -} -`, + name: "PtrHeadUint64PtrNilNotRootString", data: struct { A *struct { A *uint64 `json:"a,string"` @@ -1168,13 +677,7 @@ null // PtrHeadUint64NilNotRoot { - name: "PtrHeadUint64NilNotRoot", - expected: `{"A":null}`, - indentExpected: ` -{ - "A": null -} -`, + name: "PtrHeadUint64NilNotRoot", data: struct { A *struct { A *uint64 `json:"a"` @@ -1182,11 +685,7 @@ null }{A: nil}, }, { - name: "PtrHeadUint64NilNotRootOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadUint64NilNotRootOmitEmpty", data: struct { A *struct { A *uint64 `json:"a,omitempty"` @@ -1194,13 +693,7 @@ null }{A: nil}, }, { - name: "PtrHeadUint64NilNotRootString", - expected: `{"A":null}`, - indentExpected: ` -{ - "A": null -} -`, + name: "PtrHeadUint64NilNotRootString", data: struct { A *struct { A *uint64 `json:"a,string"` @@ -1210,18 +703,7 @@ null // HeadUint64ZeroMultiFieldsNotRoot { - name: "HeadUint64ZeroMultiFieldsNotRoot", - expected: `{"A":{"a":0},"B":{"b":0}}`, - indentExpected: ` -{ - "A": { - "a": 0 - }, - "B": { - "b": 0 - } -} -`, + name: "HeadUint64ZeroMultiFieldsNotRoot", data: struct { A struct { A uint64 `json:"a"` @@ -1232,14 +714,7 @@ null }{}, }, { - name: "HeadUint64ZeroMultiFieldsNotRootOmitEmpty", - expected: `{"A":{},"B":{}}`, - indentExpected: ` -{ - "A": {}, - "B": {} -} -`, + name: "HeadUint64ZeroMultiFieldsNotRootOmitEmpty", data: struct { A struct { A uint64 `json:"a,omitempty"` @@ -1250,18 +725,7 @@ null }{}, }, { - name: "HeadUint64ZeroMultiFieldsNotRootString", - expected: `{"A":{"a":"0"},"B":{"b":"0"}}`, - indentExpected: ` -{ - "A": { - "a": "0" - }, - "B": { - "b": "0" - } -} -`, + name: "HeadUint64ZeroMultiFieldsNotRootString", data: struct { A struct { A uint64 `json:"a,string"` @@ -1274,18 +738,7 @@ null // HeadUint64MultiFieldsNotRoot { - name: "HeadUint64MultiFieldsNotRoot", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "HeadUint64MultiFieldsNotRoot", data: struct { A struct { A uint64 `json:"a"` @@ -1300,18 +753,7 @@ null }{B: 2}}, }, { - name: "HeadUint64MultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "HeadUint64MultiFieldsNotRootOmitEmpty", data: struct { A struct { A uint64 `json:"a,omitempty"` @@ -1326,18 +768,7 @@ null }{B: 2}}, }, { - name: "HeadUint64MultiFieldsNotRootString", - expected: `{"A":{"a":"1"},"B":{"b":"2"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - }, - "B": { - "b": "2" - } -} -`, + name: "HeadUint64MultiFieldsNotRootString", data: struct { A struct { A uint64 `json:"a,string"` @@ -1354,18 +785,7 @@ null // HeadUint64PtrMultiFieldsNotRoot { - name: "HeadUint64PtrMultiFieldsNotRoot", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "HeadUint64PtrMultiFieldsNotRoot", data: struct { A struct { A *uint64 `json:"a"` @@ -1380,18 +800,7 @@ null }{B: uint64ptr(2)}}, }, { - name: "HeadUint64PtrMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "HeadUint64PtrMultiFieldsNotRootOmitEmpty", data: struct { A struct { A *uint64 `json:"a,omitempty"` @@ -1406,18 +815,7 @@ null }{B: uint64ptr(2)}}, }, { - name: "HeadUint64PtrMultiFieldsNotRootString", - expected: `{"A":{"a":"1"},"B":{"b":"2"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - }, - "B": { - "b": "2" - } -} -`, + name: "HeadUint64PtrMultiFieldsNotRootString", data: struct { A struct { A *uint64 `json:"a,string"` @@ -1434,18 +832,7 @@ null // HeadUint64PtrNilMultiFieldsNotRoot { - name: "HeadUint64PtrNilMultiFieldsNotRoot", - expected: `{"A":{"a":null},"B":{"b":null}}`, - indentExpected: ` -{ - "A": { - "a": null - }, - "B": { - "b": null - } -} -`, + name: "HeadUint64PtrNilMultiFieldsNotRoot", data: struct { A struct { A *uint64 `json:"a"` @@ -1460,14 +847,7 @@ null }{B: nil}}, }, { - name: "HeadUint64PtrNilMultiFieldsNotRootOmitEmpty", - expected: `{"A":{},"B":{}}`, - indentExpected: ` -{ - "A": {}, - "B": {} -} -`, + name: "HeadUint64PtrNilMultiFieldsNotRootOmitEmpty", data: struct { A struct { A *uint64 `json:"a,omitempty"` @@ -1482,18 +862,7 @@ null }{B: nil}}, }, { - name: "HeadUint64PtrNilMultiFieldsNotRootString", - expected: `{"A":{"a":null},"B":{"b":null}}`, - indentExpected: ` -{ - "A": { - "a": null - }, - "B": { - "b": null - } -} -`, + name: "HeadUint64PtrNilMultiFieldsNotRootString", data: struct { A struct { A *uint64 `json:"a,string"` @@ -1510,18 +879,7 @@ null // PtrHeadUint64ZeroMultiFieldsNotRoot { - name: "PtrHeadUint64ZeroMultiFieldsNotRoot", - expected: `{"A":{"a":0},"B":{"b":0}}`, - indentExpected: ` -{ - "A": { - "a": 0 - }, - "B": { - "b": 0 - } -} -`, + name: "PtrHeadUint64ZeroMultiFieldsNotRoot", data: &struct { A struct { A uint64 `json:"a"` @@ -1532,14 +890,7 @@ null }{}, }, { - name: "PtrHeadUint64ZeroMultiFieldsNotRootOmitEmpty", - expected: `{"A":{},"B":{}}`, - indentExpected: ` -{ - "A": {}, - "B": {} -} -`, + name: "PtrHeadUint64ZeroMultiFieldsNotRootOmitEmpty", data: &struct { A struct { A uint64 `json:"a,omitempty"` @@ -1550,18 +901,7 @@ null }{}, }, { - name: "PtrHeadUint64ZeroMultiFieldsNotRootString", - expected: `{"A":{"a":"0"},"B":{"b":"0"}}`, - indentExpected: ` -{ - "A": { - "a": "0" - }, - "B": { - "b": "0" - } -} -`, + name: "PtrHeadUint64ZeroMultiFieldsNotRootString", data: &struct { A struct { A uint64 `json:"a,string"` @@ -1574,18 +914,7 @@ null // PtrHeadUint64MultiFieldsNotRoot { - name: "PtrHeadUint64MultiFieldsNotRoot", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "PtrHeadUint64MultiFieldsNotRoot", data: &struct { A struct { A uint64 `json:"a"` @@ -1600,18 +929,7 @@ null }{B: 2}}, }, { - name: "PtrHeadUint64MultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "PtrHeadUint64MultiFieldsNotRootOmitEmpty", data: &struct { A struct { A uint64 `json:"a,omitempty"` @@ -1626,18 +944,7 @@ null }{B: 2}}, }, { - name: "PtrHeadUint64MultiFieldsNotRootString", - expected: `{"A":{"a":"1"},"B":{"b":"2"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - }, - "B": { - "b": "2" - } -} -`, + name: "PtrHeadUint64MultiFieldsNotRootString", data: &struct { A struct { A uint64 `json:"a,string"` @@ -1654,18 +961,7 @@ null // PtrHeadUint64PtrMultiFieldsNotRoot { - name: "PtrHeadUint64PtrMultiFieldsNotRoot", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "PtrHeadUint64PtrMultiFieldsNotRoot", data: &struct { A *struct { A *uint64 `json:"a"` @@ -1680,18 +976,7 @@ null }{B: uint64ptr(2)})}, }, { - name: "PtrHeadUint64PtrMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "PtrHeadUint64PtrMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A *uint64 `json:"a,omitempty"` @@ -1706,18 +991,7 @@ null }{B: uint64ptr(2)})}, }, { - name: "PtrHeadUint64PtrMultiFieldsNotRootString", - expected: `{"A":{"a":"1"},"B":{"b":"2"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - }, - "B": { - "b": "2" - } -} -`, + name: "PtrHeadUint64PtrMultiFieldsNotRootString", data: &struct { A *struct { A *uint64 `json:"a,string"` @@ -1734,14 +1008,7 @@ null // PtrHeadUint64PtrNilMultiFieldsNotRoot { - name: "PtrHeadUint64PtrNilMultiFieldsNotRoot", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadUint64PtrNilMultiFieldsNotRoot", data: &struct { A *struct { A *uint64 `json:"a"` @@ -1752,11 +1019,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadUint64PtrNilMultiFieldsNotRootOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadUint64PtrNilMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A *uint64 `json:"a,omitempty"` @@ -1767,14 +1030,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadUint64PtrNilMultiFieldsNotRootString", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadUint64PtrNilMultiFieldsNotRootString", data: &struct { A *struct { A *uint64 `json:"a,string"` @@ -1787,11 +1043,7 @@ null // PtrHeadUint64NilMultiFieldsNotRoot { - name: "PtrHeadUint64NilMultiFieldsNotRoot", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint64NilMultiFieldsNotRoot", data: (*struct { A *struct { A *uint64 `json:"a"` @@ -1802,11 +1054,7 @@ null })(nil), }, { - name: "PtrHeadUint64NilMultiFieldsNotRootOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint64NilMultiFieldsNotRootOmitEmpty", data: (*struct { A *struct { A *uint64 `json:"a,omitempty"` @@ -1817,11 +1065,7 @@ null })(nil), }, { - name: "PtrHeadUint64NilMultiFieldsNotRootString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint64NilMultiFieldsNotRootString", data: (*struct { A *struct { A *uint64 `json:"a,string"` @@ -1834,20 +1078,7 @@ null // PtrHeadUint64DoubleMultiFieldsNotRoot { - name: "PtrHeadUint64DoubleMultiFieldsNotRoot", - expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`, - indentExpected: ` -{ - "A": { - "a": 1, - "b": 2 - }, - "B": { - "a": 3, - "b": 4 - } -} -`, + name: "PtrHeadUint64DoubleMultiFieldsNotRoot", data: &struct { A *struct { A uint64 `json:"a"` @@ -1866,20 +1097,7 @@ null }{A: 3, B: 4})}, }, { - name: "PtrHeadUint64DoubleMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`, - indentExpected: ` -{ - "A": { - "a": 1, - "b": 2 - }, - "B": { - "a": 3, - "b": 4 - } -} -`, + name: "PtrHeadUint64DoubleMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A uint64 `json:"a,omitempty"` @@ -1898,20 +1116,7 @@ null }{A: 3, B: 4})}, }, { - name: "PtrHeadUint64DoubleMultiFieldsNotRootString", - expected: `{"A":{"a":"1","b":"2"},"B":{"a":"3","b":"4"}}`, - indentExpected: ` -{ - "A": { - "a": "1", - "b": "2" - }, - "B": { - "a": "3", - "b": "4" - } -} -`, + name: "PtrHeadUint64DoubleMultiFieldsNotRootString", data: &struct { A *struct { A uint64 `json:"a,string"` @@ -1932,14 +1137,7 @@ null // PtrHeadUint64NilDoubleMultiFieldsNotRoot { - name: "PtrHeadUint64NilDoubleMultiFieldsNotRoot", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadUint64NilDoubleMultiFieldsNotRoot", data: &struct { A *struct { A uint64 `json:"a"` @@ -1952,11 +1150,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadUint64NilDoubleMultiFieldsNotRootOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadUint64NilDoubleMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A uint64 `json:"a,omitempty"` @@ -1969,14 +1163,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadUint64NilDoubleMultiFieldsNotRootString", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadUint64NilDoubleMultiFieldsNotRootString", data: &struct { A *struct { A uint64 `json:"a,string"` @@ -1991,11 +1178,7 @@ null // PtrHeadUint64NilDoubleMultiFieldsNotRoot { - name: "PtrHeadUint64NilDoubleMultiFieldsNotRoot", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint64NilDoubleMultiFieldsNotRoot", data: (*struct { A *struct { A uint64 `json:"a"` @@ -2008,11 +1191,7 @@ null })(nil), }, { - name: "PtrHeadUint64NilDoubleMultiFieldsNotRootOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint64NilDoubleMultiFieldsNotRootOmitEmpty", data: (*struct { A *struct { A uint64 `json:"a,omitempty"` @@ -2025,11 +1204,7 @@ null })(nil), }, { - name: "PtrHeadUint64NilDoubleMultiFieldsNotRootString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint64NilDoubleMultiFieldsNotRootString", data: (*struct { A *struct { A uint64 `json:"a,string"` @@ -2044,20 +1219,7 @@ null // PtrHeadUint64PtrDoubleMultiFieldsNotRoot { - name: "PtrHeadUint64PtrDoubleMultiFieldsNotRoot", - expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`, - indentExpected: ` -{ - "A": { - "a": 1, - "b": 2 - }, - "B": { - "a": 3, - "b": 4 - } -} -`, + name: "PtrHeadUint64PtrDoubleMultiFieldsNotRoot", data: &struct { A *struct { A *uint64 `json:"a"` @@ -2076,20 +1238,7 @@ null }{A: uint64ptr(3), B: uint64ptr(4)})}, }, { - name: "PtrHeadUint64PtrDoubleMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`, - indentExpected: ` -{ - "A": { - "a": 1, - "b": 2 - }, - "B": { - "a": 3, - "b": 4 - } -} -`, + name: "PtrHeadUint64PtrDoubleMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A *uint64 `json:"a,omitempty"` @@ -2108,20 +1257,7 @@ null }{A: uint64ptr(3), B: uint64ptr(4)})}, }, { - name: "PtrHeadUint64PtrDoubleMultiFieldsNotRootString", - expected: `{"A":{"a":"1","b":"2"},"B":{"a":"3","b":"4"}}`, - indentExpected: ` -{ - "A": { - "a": "1", - "b": "2" - }, - "B": { - "a": "3", - "b": "4" - } -} -`, + name: "PtrHeadUint64PtrDoubleMultiFieldsNotRootString", data: &struct { A *struct { A *uint64 `json:"a,string"` @@ -2142,14 +1278,7 @@ null // PtrHeadUint64PtrNilDoubleMultiFieldsNotRoot { - name: "PtrHeadUint64PtrNilDoubleMultiFieldsNotRoot", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadUint64PtrNilDoubleMultiFieldsNotRoot", data: &struct { A *struct { A *uint64 `json:"a"` @@ -2162,11 +1291,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadUint64PtrNilDoubleMultiFieldsNotRootOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadUint64PtrNilDoubleMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A *uint64 `json:"a,omitempty"` @@ -2179,14 +1304,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadUint64PtrNilDoubleMultiFieldsNotRootString", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadUint64PtrNilDoubleMultiFieldsNotRootString", data: &struct { A *struct { A *uint64 `json:"a,string"` @@ -2201,11 +1319,7 @@ null // PtrHeadUint64PtrNilDoubleMultiFieldsNotRoot { - name: "PtrHeadUint64PtrNilDoubleMultiFieldsNotRoot", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint64PtrNilDoubleMultiFieldsNotRoot", data: (*struct { A *struct { A *uint64 `json:"a"` @@ -2218,11 +1332,7 @@ null })(nil), }, { - name: "PtrHeadUint64PtrNilDoubleMultiFieldsNotRootOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint64PtrNilDoubleMultiFieldsNotRootOmitEmpty", data: (*struct { A *struct { A *uint64 `json:"a,omitempty"` @@ -2235,11 +1345,7 @@ null })(nil), }, { - name: "PtrHeadUint64PtrNilDoubleMultiFieldsNotRootString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadUint64PtrNilDoubleMultiFieldsNotRootString", data: (*struct { A *struct { A *uint64 `json:"a,string"` @@ -2254,14 +1360,7 @@ null // AnonymousHeadUint64 { - name: "AnonymousHeadUint64", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "AnonymousHeadUint64", data: struct { structUint64 B uint64 `json:"b"` @@ -2271,14 +1370,7 @@ null }, }, { - name: "AnonymousHeadUint64OmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "AnonymousHeadUint64OmitEmpty", data: struct { structUint64OmitEmpty B uint64 `json:"b,omitempty"` @@ -2288,14 +1380,7 @@ null }, }, { - name: "AnonymousHeadUint64String", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "AnonymousHeadUint64String", data: struct { structUint64String B uint64 `json:"b,string"` @@ -2307,14 +1392,7 @@ null // PtrAnonymousHeadUint64 { - name: "PtrAnonymousHeadUint64", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrAnonymousHeadUint64", data: struct { *structUint64 B uint64 `json:"b"` @@ -2324,14 +1402,7 @@ null }, }, { - name: "PtrAnonymousHeadUint64OmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrAnonymousHeadUint64OmitEmpty", data: struct { *structUint64OmitEmpty B uint64 `json:"b,omitempty"` @@ -2341,14 +1412,7 @@ null }, }, { - name: "PtrAnonymousHeadUint64String", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "PtrAnonymousHeadUint64String", data: struct { *structUint64String B uint64 `json:"b,string"` @@ -2360,13 +1424,7 @@ null // NilPtrAnonymousHeadUint64 { - name: "NilPtrAnonymousHeadUint64", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "NilPtrAnonymousHeadUint64", data: struct { *structUint64 B uint64 `json:"b"` @@ -2376,13 +1434,7 @@ null }, }, { - name: "NilPtrAnonymousHeadUint64OmitEmpty", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "NilPtrAnonymousHeadUint64OmitEmpty", data: struct { *structUint64OmitEmpty B uint64 `json:"b,omitempty"` @@ -2392,13 +1444,7 @@ null }, }, { - name: "NilPtrAnonymousHeadUint64String", - expected: `{"b":"2"}`, - indentExpected: ` -{ - "b": "2" -} -`, + name: "NilPtrAnonymousHeadUint64String", data: struct { *structUint64String B uint64 `json:"b,string"` @@ -2410,14 +1456,7 @@ null // AnonymousHeadUint64Ptr { - name: "AnonymousHeadUint64Ptr", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "AnonymousHeadUint64Ptr", data: struct { structUint64Ptr B *uint64 `json:"b"` @@ -2427,14 +1466,7 @@ null }, }, { - name: "AnonymousHeadUint64PtrOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "AnonymousHeadUint64PtrOmitEmpty", data: struct { structUint64PtrOmitEmpty B *uint64 `json:"b,omitempty"` @@ -2444,14 +1476,7 @@ null }, }, { - name: "AnonymousHeadUint64PtrString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "AnonymousHeadUint64PtrString", data: struct { structUint64PtrString B *uint64 `json:"b,string"` @@ -2463,14 +1488,7 @@ null // AnonymousHeadUint64PtrNil { - name: "AnonymousHeadUint64PtrNil", - expected: `{"a":null,"b":2}`, - indentExpected: ` -{ - "a": null, - "b": 2 -} -`, + name: "AnonymousHeadUint64PtrNil", data: struct { structUint64Ptr B *uint64 `json:"b"` @@ -2480,13 +1498,7 @@ null }, }, { - name: "AnonymousHeadUint64PtrNilOmitEmpty", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "AnonymousHeadUint64PtrNilOmitEmpty", data: struct { structUint64PtrOmitEmpty B *uint64 `json:"b,omitempty"` @@ -2496,14 +1508,7 @@ null }, }, { - name: "AnonymousHeadUint64PtrNilString", - expected: `{"a":null,"b":"2"}`, - indentExpected: ` -{ - "a": null, - "b": "2" -} -`, + name: "AnonymousHeadUint64PtrNilString", data: struct { structUint64PtrString B *uint64 `json:"b,string"` @@ -2515,14 +1520,7 @@ null // PtrAnonymousHeadUint64Ptr { - name: "PtrAnonymousHeadUint64Ptr", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrAnonymousHeadUint64Ptr", data: struct { *structUint64Ptr B *uint64 `json:"b"` @@ -2532,14 +1530,7 @@ null }, }, { - name: "PtrAnonymousHeadUint64PtrOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrAnonymousHeadUint64PtrOmitEmpty", data: struct { *structUint64PtrOmitEmpty B *uint64 `json:"b,omitempty"` @@ -2549,14 +1540,7 @@ null }, }, { - name: "PtrAnonymousHeadUint64PtrString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "PtrAnonymousHeadUint64PtrString", data: struct { *structUint64PtrString B *uint64 `json:"b,string"` @@ -2568,13 +1552,7 @@ null // NilPtrAnonymousHeadUint64Ptr { - name: "NilPtrAnonymousHeadUint64Ptr", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "NilPtrAnonymousHeadUint64Ptr", data: struct { *structUint64Ptr B *uint64 `json:"b"` @@ -2584,13 +1562,7 @@ null }, }, { - name: "NilPtrAnonymousHeadUint64PtrOmitEmpty", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "NilPtrAnonymousHeadUint64PtrOmitEmpty", data: struct { *structUint64PtrOmitEmpty B *uint64 `json:"b,omitempty"` @@ -2600,13 +1572,7 @@ null }, }, { - name: "NilPtrAnonymousHeadUint64PtrString", - expected: `{"b":"2"}`, - indentExpected: ` -{ - "b": "2" -} -`, + name: "NilPtrAnonymousHeadUint64PtrString", data: struct { *structUint64PtrString B *uint64 `json:"b,string"` @@ -2618,13 +1584,7 @@ null // AnonymousHeadUint64Only { - name: "AnonymousHeadUint64Only", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "AnonymousHeadUint64Only", data: struct { structUint64 }{ @@ -2632,13 +1592,7 @@ null }, }, { - name: "AnonymousHeadUint64OnlyOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "AnonymousHeadUint64OnlyOmitEmpty", data: struct { structUint64OmitEmpty }{ @@ -2646,13 +1600,7 @@ null }, }, { - name: "AnonymousHeadUint64OnlyString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "AnonymousHeadUint64OnlyString", data: struct { structUint64String }{ @@ -2662,13 +1610,7 @@ null // PtrAnonymousHeadUint64Only { - name: "PtrAnonymousHeadUint64Only", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrAnonymousHeadUint64Only", data: struct { *structUint64 }{ @@ -2676,13 +1618,7 @@ null }, }, { - name: "PtrAnonymousHeadUint64OnlyOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrAnonymousHeadUint64OnlyOmitEmpty", data: struct { *structUint64OmitEmpty }{ @@ -2690,13 +1626,7 @@ null }, }, { - name: "PtrAnonymousHeadUint64OnlyString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "PtrAnonymousHeadUint64OnlyString", data: struct { *structUint64String }{ @@ -2706,11 +1636,7 @@ null // NilPtrAnonymousHeadUint64Only { - name: "NilPtrAnonymousHeadUint64Only", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadUint64Only", data: struct { *structUint64 }{ @@ -2718,11 +1644,7 @@ null }, }, { - name: "NilPtrAnonymousHeadUint64OnlyOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadUint64OnlyOmitEmpty", data: struct { *structUint64OmitEmpty }{ @@ -2730,11 +1652,7 @@ null }, }, { - name: "NilPtrAnonymousHeadUint64OnlyString", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadUint64OnlyString", data: struct { *structUint64String }{ @@ -2744,13 +1662,7 @@ null // AnonymousHeadUint64PtrOnly { - name: "AnonymousHeadUint64PtrOnly", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "AnonymousHeadUint64PtrOnly", data: struct { structUint64Ptr }{ @@ -2758,13 +1670,7 @@ null }, }, { - name: "AnonymousHeadUint64PtrOnlyOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "AnonymousHeadUint64PtrOnlyOmitEmpty", data: struct { structUint64PtrOmitEmpty }{ @@ -2772,13 +1678,7 @@ null }, }, { - name: "AnonymousHeadUint64PtrOnlyString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "AnonymousHeadUint64PtrOnlyString", data: struct { structUint64PtrString }{ @@ -2788,13 +1688,7 @@ null // AnonymousHeadUint64PtrNilOnly { - name: "AnonymousHeadUint64PtrNilOnly", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "AnonymousHeadUint64PtrNilOnly", data: struct { structUint64Ptr }{ @@ -2802,11 +1696,7 @@ null }, }, { - name: "AnonymousHeadUint64PtrNilOnlyOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "AnonymousHeadUint64PtrNilOnlyOmitEmpty", data: struct { structUint64PtrOmitEmpty }{ @@ -2814,13 +1704,7 @@ null }, }, { - name: "AnonymousHeadUint64PtrNilOnlyString", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "AnonymousHeadUint64PtrNilOnlyString", data: struct { structUint64PtrString }{ @@ -2830,13 +1714,7 @@ null // PtrAnonymousHeadUint64PtrOnly { - name: "PtrAnonymousHeadUint64PtrOnly", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrAnonymousHeadUint64PtrOnly", data: struct { *structUint64Ptr }{ @@ -2844,13 +1722,7 @@ null }, }, { - name: "PtrAnonymousHeadUint64PtrOnlyOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrAnonymousHeadUint64PtrOnlyOmitEmpty", data: struct { *structUint64PtrOmitEmpty }{ @@ -2858,13 +1730,7 @@ null }, }, { - name: "PtrAnonymousHeadUint64PtrOnlyString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "PtrAnonymousHeadUint64PtrOnlyString", data: struct { *structUint64PtrString }{ @@ -2874,11 +1740,7 @@ null // NilPtrAnonymousHeadUint64PtrOnly { - name: "NilPtrAnonymousHeadUint64PtrOnly", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadUint64PtrOnly", data: struct { *structUint64Ptr }{ @@ -2886,11 +1748,7 @@ null }, }, { - name: "NilPtrAnonymousHeadUint64PtrOnlyOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadUint64PtrOnlyOmitEmpty", data: struct { *structUint64PtrOmitEmpty }{ @@ -2898,11 +1756,7 @@ null }, }, { - name: "NilPtrAnonymousHeadUint64PtrOnlyString", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadUint64PtrOnlyString", data: struct { *structUint64PtrString }{ @@ -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()) - } - } } } } From d8af48454dfa957545eb6cad063f18a12cda0916 Mon Sep 17 00:00:00 2001 From: Masaaki Goshima Date: Mon, 15 Feb 2021 11:29:42 +0900 Subject: [PATCH 11/15] Refactor cover_float32_test.go --- cover_float32_test.go | 1540 +++++------------------------------------ 1 file changed, 192 insertions(+), 1348 deletions(-) diff --git a/cover_float32_test.go b/cover_float32_test.go index 785a54e..1b49bd8 100644 --- a/cover_float32_test.go +++ b/cover_float32_test.go @@ -2,7 +2,6 @@ package json_test import ( "bytes" - "strings" "testing" "github.com/goccy/go-json" @@ -30,42 +29,24 @@ func TestCoverFloat32(t *testing.T) { } tests := []struct { - name string - expected string - indentExpected string - data interface{} + name string + data interface{} }{ // HeadFloat32Zero { - name: "HeadFloat32Zero", - expected: `{"a":0}`, - indentExpected: ` -{ - "a": 0 -} -`, + name: "HeadFloat32Zero", data: struct { A float32 `json:"a"` }{}, }, { - name: "HeadFloat32ZeroOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "HeadFloat32ZeroOmitEmpty", data: struct { A float32 `json:"a,omitempty"` }{}, }, { - name: "HeadFloat32ZeroString", - expected: `{"a":"0"}`, - indentExpected: ` -{ - "a": "0" -} -`, + name: "HeadFloat32ZeroString", data: struct { A float32 `json:"a,string"` }{}, @@ -73,37 +54,19 @@ func TestCoverFloat32(t *testing.T) { // HeadFloat32 { - name: "HeadFloat32", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "HeadFloat32", data: struct { A float32 `json:"a"` }{A: 1}, }, { - name: "HeadFloat32OmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "HeadFloat32OmitEmpty", data: struct { A float32 `json:"a,omitempty"` }{A: 1}, }, { - name: "HeadFloat32String", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "HeadFloat32String", data: struct { A float32 `json:"a,string"` }{A: 1}, @@ -111,37 +74,19 @@ func TestCoverFloat32(t *testing.T) { // HeadFloat32Ptr { - name: "HeadFloat32Ptr", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "HeadFloat32Ptr", data: struct { A *float32 `json:"a"` }{A: float32ptr(1)}, }, { - name: "HeadFloat32PtrOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "HeadFloat32PtrOmitEmpty", data: struct { A *float32 `json:"a,omitempty"` }{A: float32ptr(1)}, }, { - name: "HeadFloat32PtrString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "HeadFloat32PtrString", data: struct { A *float32 `json:"a,string"` }{A: float32ptr(1)}, @@ -149,35 +94,19 @@ func TestCoverFloat32(t *testing.T) { // HeadFloat32PtrNil { - name: "HeadFloat32PtrNil", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "HeadFloat32PtrNil", data: struct { A *float32 `json:"a"` }{A: nil}, }, { - name: "HeadFloat32PtrNilOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "HeadFloat32PtrNilOmitEmpty", data: struct { A *float32 `json:"a,omitempty"` }{A: nil}, }, { - name: "HeadFloat32PtrNilString", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "HeadFloat32PtrNilString", data: struct { A *float32 `json:"a,string"` }{A: nil}, @@ -185,35 +114,19 @@ func TestCoverFloat32(t *testing.T) { // PtrHeadFloat32Zero { - name: "PtrHeadFloat32Zero", - expected: `{"a":0}`, - indentExpected: ` -{ - "a": 0 -} -`, + name: "PtrHeadFloat32Zero", data: &struct { A float32 `json:"a"` }{}, }, { - name: "PtrHeadFloat32ZeroOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadFloat32ZeroOmitEmpty", data: &struct { A float32 `json:"a,omitempty"` }{}, }, { - name: "PtrHeadFloat32ZeroString", - expected: `{"a":"0"}`, - indentExpected: ` -{ - "a": "0" -} -`, + name: "PtrHeadFloat32ZeroString", data: &struct { A float32 `json:"a,string"` }{}, @@ -221,37 +134,19 @@ func TestCoverFloat32(t *testing.T) { // PtrHeadFloat32 { - name: "PtrHeadFloat32", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrHeadFloat32", data: &struct { A float32 `json:"a"` }{A: 1}, }, { - name: "PtrHeadFloat32OmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrHeadFloat32OmitEmpty", data: &struct { A float32 `json:"a,omitempty"` }{A: 1}, }, { - name: "PtrHeadFloat32String", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "PtrHeadFloat32String", data: &struct { A float32 `json:"a,string"` }{A: 1}, @@ -259,37 +154,19 @@ func TestCoverFloat32(t *testing.T) { // PtrHeadFloat32Ptr { - name: "PtrHeadFloat32Ptr", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrHeadFloat32Ptr", data: &struct { A *float32 `json:"a"` }{A: float32ptr(1)}, }, { - name: "PtrHeadFloat32PtrOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrHeadFloat32PtrOmitEmpty", data: &struct { A *float32 `json:"a,omitempty"` }{A: float32ptr(1)}, }, { - name: "PtrHeadFloat32PtrString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "PtrHeadFloat32PtrString", data: &struct { A *float32 `json:"a,string"` }{A: float32ptr(1)}, @@ -297,35 +174,19 @@ func TestCoverFloat32(t *testing.T) { // PtrHeadFloat32PtrNil { - name: "PtrHeadFloat32PtrNil", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "PtrHeadFloat32PtrNil", data: &struct { A *float32 `json:"a"` }{A: nil}, }, { - name: "PtrHeadFloat32PtrNilOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadFloat32PtrNilOmitEmpty", data: &struct { A *float32 `json:"a,omitempty"` }{A: nil}, }, { - name: "PtrHeadFloat32PtrNilString", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "PtrHeadFloat32PtrNilString", data: &struct { A *float32 `json:"a,string"` }{A: nil}, @@ -333,31 +194,19 @@ func TestCoverFloat32(t *testing.T) { // PtrHeadFloat32Nil { - name: "PtrHeadFloat32Nil", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadFloat32Nil", data: (*struct { A *float32 `json:"a"` })(nil), }, { - name: "PtrHeadFloat32NilOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadFloat32NilOmitEmpty", data: (*struct { A *float32 `json:"a,omitempty"` })(nil), }, { - name: "PtrHeadFloat32NilString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadFloat32NilString", data: (*struct { A *float32 `json:"a,string"` })(nil), @@ -365,209 +214,125 @@ null // HeadFloat32ZeroMultiFields { - name: "HeadFloat32ZeroMultiFields", - expected: `{"a":0,"b":0}`, - indentExpected: ` -{ - "a": 0, - "b": 0 -} -`, + name: "HeadFloat32ZeroMultiFields", data: struct { A float32 `json:"a"` B float32 `json:"b"` + C float32 `json:"c"` }{}, }, { - name: "HeadFloat32ZeroMultiFieldsOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "HeadFloat32ZeroMultiFieldsOmitEmpty", data: struct { A float32 `json:"a,omitempty"` B float32 `json:"b,omitempty"` + C float32 `json:"c,omitempty"` }{}, }, { - name: "HeadFloat32ZeroMultiFields", - expected: `{"a":"0","b":"0"}`, - indentExpected: ` -{ - "a": "0", - "b": "0" -} -`, + name: "HeadFloat32ZeroMultiFields", data: struct { A float32 `json:"a,string"` B float32 `json:"b,string"` + C float32 `json:"c,string"` }{}, }, // HeadFloat32MultiFields { - name: "HeadFloat32MultiFields", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "HeadFloat32MultiFields", data: struct { A float32 `json:"a"` B float32 `json:"b"` - }{A: 1, B: 2}, + C float32 `json:"c"` + }{A: 1, B: 2, C: 3}, }, { - name: "HeadFloat32MultiFieldsOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "HeadFloat32MultiFieldsOmitEmpty", data: struct { A float32 `json:"a,omitempty"` B float32 `json:"b,omitempty"` - }{A: 1, B: 2}, + C float32 `json:"c,omitempty"` + }{A: 1, B: 2, C: 3}, }, { - name: "HeadFloat32MultiFieldsString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "HeadFloat32MultiFieldsString", data: struct { A float32 `json:"a,string"` B float32 `json:"b,string"` - }{A: 1, B: 2}, + C float32 `json:"c,string"` + }{A: 1, B: 2, C: 3}, }, // HeadFloat32PtrMultiFields { - name: "HeadFloat32PtrMultiFields", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "HeadFloat32PtrMultiFields", data: struct { A *float32 `json:"a"` B *float32 `json:"b"` - }{A: float32ptr(1), B: float32ptr(2)}, + C *float32 `json:"c"` + }{A: float32ptr(1), B: float32ptr(2), C: float32ptr(3)}, }, { - name: "HeadFloat32PtrMultiFieldsOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "HeadFloat32PtrMultiFieldsOmitEmpty", data: struct { A *float32 `json:"a,omitempty"` B *float32 `json:"b,omitempty"` - }{A: float32ptr(1), B: float32ptr(2)}, + C *float32 `json:"c,omitempty"` + }{A: float32ptr(1), B: float32ptr(2), C: float32ptr(3)}, }, { - name: "HeadFloat32PtrMultiFieldsString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "HeadFloat32PtrMultiFieldsString", data: struct { A *float32 `json:"a,string"` B *float32 `json:"b,string"` - }{A: float32ptr(1), B: float32ptr(2)}, + C *float32 `json:"c,string"` + }{A: float32ptr(1), B: float32ptr(2), C: float32ptr(3)}, }, // HeadFloat32PtrNilMultiFields { - name: "HeadFloat32PtrNilMultiFields", - expected: `{"a":null,"b":null}`, - indentExpected: ` -{ - "a": null, - "b": null -} -`, + name: "HeadFloat32PtrNilMultiFields", data: struct { A *float32 `json:"a"` B *float32 `json:"b"` - }{A: nil, B: nil}, + C *float32 `json:"c"` + }{A: nil, B: nil, C: nil}, }, { - name: "HeadFloat32PtrNilMultiFieldsOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "HeadFloat32PtrNilMultiFieldsOmitEmpty", data: struct { A *float32 `json:"a,omitempty"` B *float32 `json:"b,omitempty"` - }{A: nil, B: nil}, + C *float32 `json:"c,omitempty"` + }{A: nil, B: nil, C: nil}, }, { - name: "HeadFloat32PtrNilMultiFieldsString", - expected: `{"a":null,"b":null}`, - indentExpected: ` -{ - "a": null, - "b": null -} -`, + name: "HeadFloat32PtrNilMultiFieldsString", data: struct { A *float32 `json:"a,string"` B *float32 `json:"b,string"` - }{A: nil, B: nil}, + C *float32 `json:"c,string"` + }{A: nil, B: nil, C: nil}, }, // PtrHeadFloat32ZeroMultiFields { - name: "PtrHeadFloat32ZeroMultiFields", - expected: `{"a":0,"b":0}`, - indentExpected: ` -{ - "a": 0, - "b": 0 -} -`, + name: "PtrHeadFloat32ZeroMultiFields", data: &struct { A float32 `json:"a"` B float32 `json:"b"` }{}, }, { - name: "PtrHeadFloat32ZeroMultiFieldsOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadFloat32ZeroMultiFieldsOmitEmpty", data: &struct { A float32 `json:"a,omitempty"` B float32 `json:"b,omitempty"` }{}, }, { - name: "PtrHeadFloat32ZeroMultiFieldsString", - expected: `{"a":"0","b":"0"}`, - indentExpected: ` -{ - "a": "0", - "b": "0" -} -`, + name: "PtrHeadFloat32ZeroMultiFieldsString", data: &struct { A float32 `json:"a,string"` B float32 `json:"b,string"` @@ -576,42 +341,21 @@ null // PtrHeadFloat32MultiFields { - name: "PtrHeadFloat32MultiFields", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrHeadFloat32MultiFields", data: &struct { A float32 `json:"a"` B float32 `json:"b"` }{A: 1, B: 2}, }, { - name: "PtrHeadFloat32MultiFieldsOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrHeadFloat32MultiFieldsOmitEmpty", data: &struct { A float32 `json:"a,omitempty"` B float32 `json:"b,omitempty"` }{A: 1, B: 2}, }, { - name: "PtrHeadFloat32MultiFieldsString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "PtrHeadFloat32MultiFieldsString", data: &struct { A float32 `json:"a,string"` B float32 `json:"b,string"` @@ -620,42 +364,21 @@ null // PtrHeadFloat32PtrMultiFields { - name: "PtrHeadFloat32PtrMultiFields", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrHeadFloat32PtrMultiFields", data: &struct { A *float32 `json:"a"` B *float32 `json:"b"` }{A: float32ptr(1), B: float32ptr(2)}, }, { - name: "PtrHeadFloat32PtrMultiFieldsOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrHeadFloat32PtrMultiFieldsOmitEmpty", data: &struct { A *float32 `json:"a,omitempty"` B *float32 `json:"b,omitempty"` }{A: float32ptr(1), B: float32ptr(2)}, }, { - name: "PtrHeadFloat32PtrMultiFieldsString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "PtrHeadFloat32PtrMultiFieldsString", data: &struct { A *float32 `json:"a,string"` B *float32 `json:"b,string"` @@ -664,39 +387,21 @@ null // PtrHeadFloat32PtrNilMultiFields { - name: "PtrHeadFloat32PtrNilMultiFields", - expected: `{"a":null,"b":null}`, - indentExpected: ` -{ - "a": null, - "b": null -} -`, + name: "PtrHeadFloat32PtrNilMultiFields", data: &struct { A *float32 `json:"a"` B *float32 `json:"b"` }{A: nil, B: nil}, }, { - name: "PtrHeadFloat32PtrNilMultiFieldsOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadFloat32PtrNilMultiFieldsOmitEmpty", data: &struct { A *float32 `json:"a,omitempty"` B *float32 `json:"b,omitempty"` }{A: nil, B: nil}, }, { - name: "PtrHeadFloat32PtrNilMultiFieldsString", - expected: `{"a":null,"b":null}`, - indentExpected: ` -{ - "a": null, - "b": null -} -`, + name: "PtrHeadFloat32PtrNilMultiFieldsString", data: &struct { A *float32 `json:"a,string"` B *float32 `json:"b,string"` @@ -705,33 +410,21 @@ null // PtrHeadFloat32NilMultiFields { - name: "PtrHeadFloat32NilMultiFields", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadFloat32NilMultiFields", data: (*struct { A *float32 `json:"a"` B *float32 `json:"b"` })(nil), }, { - name: "PtrHeadFloat32NilMultiFieldsOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadFloat32NilMultiFieldsOmitEmpty", data: (*struct { A *float32 `json:"a,omitempty"` B *float32 `json:"b,omitempty"` })(nil), }, { - name: "PtrHeadFloat32NilMultiFieldsString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadFloat32NilMultiFieldsString", data: (*struct { A *float32 `json:"a,string"` B *float32 `json:"b,string"` @@ -740,15 +433,7 @@ null // HeadFloat32ZeroNotRoot { - name: "HeadFloat32ZeroNotRoot", - expected: `{"A":{"a":0}}`, - indentExpected: ` -{ - "A": { - "a": 0 - } -} -`, + name: "HeadFloat32ZeroNotRoot", data: struct { A struct { A float32 `json:"a"` @@ -756,13 +441,7 @@ null }{}, }, { - name: "HeadFloat32ZeroNotRootOmitEmpty", - expected: `{"A":{}}`, - indentExpected: ` -{ - "A": {} -} -`, + name: "HeadFloat32ZeroNotRootOmitEmpty", data: struct { A struct { A float32 `json:"a,omitempty"` @@ -770,15 +449,7 @@ null }{}, }, { - name: "HeadFloat32ZeroNotRootString", - expected: `{"A":{"a":"0"}}`, - indentExpected: ` -{ - "A": { - "a": "0" - } -} -`, + name: "HeadFloat32ZeroNotRootString", data: struct { A struct { A float32 `json:"a,string"` @@ -788,15 +459,7 @@ null // HeadFloat32NotRoot { - name: "HeadFloat32NotRoot", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "HeadFloat32NotRoot", data: struct { A struct { A float32 `json:"a"` @@ -806,15 +469,7 @@ null }{A: 1}}, }, { - name: "HeadFloat32NotRootOmitEmpty", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "HeadFloat32NotRootOmitEmpty", data: struct { A struct { A float32 `json:"a,omitempty"` @@ -824,15 +479,7 @@ null }{A: 1}}, }, { - name: "HeadFloat32NotRootString", - expected: `{"A":{"a":"1"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - } -} -`, + name: "HeadFloat32NotRootString", data: struct { A struct { A float32 `json:"a,string"` @@ -844,15 +491,7 @@ null // HeadFloat32PtrNotRoot { - name: "HeadFloat32PtrNotRoot", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "HeadFloat32PtrNotRoot", data: struct { A struct { A *float32 `json:"a"` @@ -862,15 +501,7 @@ null }{float32ptr(1)}}, }, { - name: "HeadFloat32PtrNotRootOmitEmpty", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "HeadFloat32PtrNotRootOmitEmpty", data: struct { A struct { A *float32 `json:"a,omitempty"` @@ -880,15 +511,7 @@ null }{float32ptr(1)}}, }, { - name: "HeadFloat32PtrNotRootString", - expected: `{"A":{"a":"1"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - } -} -`, + name: "HeadFloat32PtrNotRootString", data: struct { A struct { A *float32 `json:"a,string"` @@ -900,15 +523,7 @@ null // HeadFloat32PtrNilNotRoot { - name: "HeadFloat32PtrNilNotRoot", - expected: `{"A":{"a":null}}`, - indentExpected: ` -{ - "A": { - "a": null - } -} -`, + name: "HeadFloat32PtrNilNotRoot", data: struct { A struct { A *float32 `json:"a"` @@ -916,13 +531,7 @@ null }{}, }, { - name: "HeadFloat32PtrNilNotRootOmitEmpty", - expected: `{"A":{}}`, - indentExpected: ` -{ - "A": {} -} -`, + name: "HeadFloat32PtrNilNotRootOmitEmpty", data: struct { A struct { A *float32 `json:"a,omitempty"` @@ -930,15 +539,7 @@ null }{}, }, { - name: "HeadFloat32PtrNilNotRootString", - expected: `{"A":{"a":null}}`, - indentExpected: ` -{ - "A": { - "a": null - } -} -`, + name: "HeadFloat32PtrNilNotRootString", data: struct { A struct { A *float32 `json:"a,string"` @@ -948,15 +549,7 @@ null // PtrHeadFloat32ZeroNotRoot { - name: "PtrHeadFloat32ZeroNotRoot", - expected: `{"A":{"a":0}}`, - indentExpected: ` -{ - "A": { - "a": 0 - } -} -`, + name: "PtrHeadFloat32ZeroNotRoot", data: struct { A *struct { A float32 `json:"a"` @@ -966,13 +559,7 @@ null })}, }, { - name: "PtrHeadFloat32ZeroNotRootOmitEmpty", - expected: `{"A":{}}`, - indentExpected: ` -{ - "A": {} -} -`, + name: "PtrHeadFloat32ZeroNotRootOmitEmpty", data: struct { A *struct { A float32 `json:"a,omitempty"` @@ -982,15 +569,7 @@ null })}, }, { - name: "PtrHeadFloat32ZeroNotRootString", - expected: `{"A":{"a":"0"}}`, - indentExpected: ` -{ - "A": { - "a": "0" - } -} -`, + name: "PtrHeadFloat32ZeroNotRootString", data: struct { A *struct { A float32 `json:"a,string"` @@ -1002,15 +581,7 @@ null // PtrHeadFloat32NotRoot { - name: "PtrHeadFloat32NotRoot", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "PtrHeadFloat32NotRoot", data: struct { A *struct { A float32 `json:"a"` @@ -1020,15 +591,7 @@ null }{A: 1})}, }, { - name: "PtrHeadFloat32NotRootOmitEmpty", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "PtrHeadFloat32NotRootOmitEmpty", data: struct { A *struct { A float32 `json:"a,omitempty"` @@ -1038,15 +601,7 @@ null }{A: 1})}, }, { - name: "PtrHeadFloat32NotRootString", - expected: `{"A":{"a":"1"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - } -} -`, + name: "PtrHeadFloat32NotRootString", data: struct { A *struct { A float32 `json:"a,string"` @@ -1058,15 +613,7 @@ null // PtrHeadFloat32PtrNotRoot { - name: "PtrHeadFloat32PtrNotRoot", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "PtrHeadFloat32PtrNotRoot", data: struct { A *struct { A *float32 `json:"a"` @@ -1076,15 +623,7 @@ null }{A: float32ptr(1)})}, }, { - name: "PtrHeadFloat32PtrNotRootOmitEmpty", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "PtrHeadFloat32PtrNotRootOmitEmpty", data: struct { A *struct { A *float32 `json:"a,omitempty"` @@ -1094,15 +633,7 @@ null }{A: float32ptr(1)})}, }, { - name: "PtrHeadFloat32PtrNotRootString", - expected: `{"A":{"a":"1"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - } -} -`, + name: "PtrHeadFloat32PtrNotRootString", data: struct { A *struct { A *float32 `json:"a,string"` @@ -1114,15 +645,7 @@ null // PtrHeadFloat32PtrNilNotRoot { - name: "PtrHeadFloat32PtrNilNotRoot", - expected: `{"A":{"a":null}}`, - indentExpected: ` -{ - "A": { - "a": null - } -} -`, + name: "PtrHeadFloat32PtrNilNotRoot", data: struct { A *struct { A *float32 `json:"a"` @@ -1132,13 +655,7 @@ null }{A: nil})}, }, { - name: "PtrHeadFloat32PtrNilNotRootOmitEmpty", - expected: `{"A":{}}`, - indentExpected: ` -{ - "A": {} -} -`, + name: "PtrHeadFloat32PtrNilNotRootOmitEmpty", data: struct { A *struct { A *float32 `json:"a,omitempty"` @@ -1148,15 +665,7 @@ null }{A: nil})}, }, { - name: "PtrHeadFloat32PtrNilNotRootString", - expected: `{"A":{"a":null}}`, - indentExpected: ` -{ - "A": { - "a": null - } -} -`, + name: "PtrHeadFloat32PtrNilNotRootString", data: struct { A *struct { A *float32 `json:"a,string"` @@ -1168,13 +677,7 @@ null // PtrHeadFloat32NilNotRoot { - name: "PtrHeadFloat32NilNotRoot", - expected: `{"A":null}`, - indentExpected: ` -{ - "A": null -} -`, + name: "PtrHeadFloat32NilNotRoot", data: struct { A *struct { A *float32 `json:"a"` @@ -1182,11 +685,7 @@ null }{A: nil}, }, { - name: "PtrHeadFloat32NilNotRootOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadFloat32NilNotRootOmitEmpty", data: struct { A *struct { A *float32 `json:"a,omitempty"` @@ -1194,13 +693,7 @@ null }{A: nil}, }, { - name: "PtrHeadFloat32NilNotRootString", - expected: `{"A":null}`, - indentExpected: ` -{ - "A": null -} -`, + name: "PtrHeadFloat32NilNotRootString", data: struct { A *struct { A *float32 `json:"a,string"` @@ -1210,18 +703,7 @@ null // HeadFloat32ZeroMultiFieldsNotRoot { - name: "HeadFloat32ZeroMultiFieldsNotRoot", - expected: `{"A":{"a":0},"B":{"b":0}}`, - indentExpected: ` -{ - "A": { - "a": 0 - }, - "B": { - "b": 0 - } -} -`, + name: "HeadFloat32ZeroMultiFieldsNotRoot", data: struct { A struct { A float32 `json:"a"` @@ -1232,14 +714,7 @@ null }{}, }, { - name: "HeadFloat32ZeroMultiFieldsNotRootOmitEmpty", - expected: `{"A":{},"B":{}}`, - indentExpected: ` -{ - "A": {}, - "B": {} -} -`, + name: "HeadFloat32ZeroMultiFieldsNotRootOmitEmpty", data: struct { A struct { A float32 `json:"a,omitempty"` @@ -1250,18 +725,7 @@ null }{}, }, { - name: "HeadFloat32ZeroMultiFieldsNotRootString", - expected: `{"A":{"a":"0"},"B":{"b":"0"}}`, - indentExpected: ` -{ - "A": { - "a": "0" - }, - "B": { - "b": "0" - } -} -`, + name: "HeadFloat32ZeroMultiFieldsNotRootString", data: struct { A struct { A float32 `json:"a,string"` @@ -1274,18 +738,7 @@ null // HeadFloat32MultiFieldsNotRoot { - name: "HeadFloat32MultiFieldsNotRoot", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "HeadFloat32MultiFieldsNotRoot", data: struct { A struct { A float32 `json:"a"` @@ -1300,18 +753,7 @@ null }{B: 2}}, }, { - name: "HeadFloat32MultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "HeadFloat32MultiFieldsNotRootOmitEmpty", data: struct { A struct { A float32 `json:"a,omitempty"` @@ -1326,18 +768,7 @@ null }{B: 2}}, }, { - name: "HeadFloat32MultiFieldsNotRootString", - expected: `{"A":{"a":"1"},"B":{"b":"2"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - }, - "B": { - "b": "2" - } -} -`, + name: "HeadFloat32MultiFieldsNotRootString", data: struct { A struct { A float32 `json:"a,string"` @@ -1354,18 +785,7 @@ null // HeadFloat32PtrMultiFieldsNotRoot { - name: "HeadFloat32PtrMultiFieldsNotRoot", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "HeadFloat32PtrMultiFieldsNotRoot", data: struct { A struct { A *float32 `json:"a"` @@ -1380,18 +800,7 @@ null }{B: float32ptr(2)}}, }, { - name: "HeadFloat32PtrMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "HeadFloat32PtrMultiFieldsNotRootOmitEmpty", data: struct { A struct { A *float32 `json:"a,omitempty"` @@ -1406,18 +815,7 @@ null }{B: float32ptr(2)}}, }, { - name: "HeadFloat32PtrMultiFieldsNotRootString", - expected: `{"A":{"a":"1"},"B":{"b":"2"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - }, - "B": { - "b": "2" - } -} -`, + name: "HeadFloat32PtrMultiFieldsNotRootString", data: struct { A struct { A *float32 `json:"a,string"` @@ -1434,18 +832,7 @@ null // HeadFloat32PtrNilMultiFieldsNotRoot { - name: "HeadFloat32PtrNilMultiFieldsNotRoot", - expected: `{"A":{"a":null},"B":{"b":null}}`, - indentExpected: ` -{ - "A": { - "a": null - }, - "B": { - "b": null - } -} -`, + name: "HeadFloat32PtrNilMultiFieldsNotRoot", data: struct { A struct { A *float32 `json:"a"` @@ -1460,14 +847,7 @@ null }{B: nil}}, }, { - name: "HeadFloat32PtrNilMultiFieldsNotRootOmitEmpty", - expected: `{"A":{},"B":{}}`, - indentExpected: ` -{ - "A": {}, - "B": {} -} -`, + name: "HeadFloat32PtrNilMultiFieldsNotRootOmitEmpty", data: struct { A struct { A *float32 `json:"a,omitempty"` @@ -1482,18 +862,7 @@ null }{B: nil}}, }, { - name: "HeadFloat32PtrNilMultiFieldsNotRootString", - expected: `{"A":{"a":null},"B":{"b":null}}`, - indentExpected: ` -{ - "A": { - "a": null - }, - "B": { - "b": null - } -} -`, + name: "HeadFloat32PtrNilMultiFieldsNotRootString", data: struct { A struct { A *float32 `json:"a,string"` @@ -1510,18 +879,7 @@ null // PtrHeadFloat32ZeroMultiFieldsNotRoot { - name: "PtrHeadFloat32ZeroMultiFieldsNotRoot", - expected: `{"A":{"a":0},"B":{"b":0}}`, - indentExpected: ` -{ - "A": { - "a": 0 - }, - "B": { - "b": 0 - } -} -`, + name: "PtrHeadFloat32ZeroMultiFieldsNotRoot", data: &struct { A struct { A float32 `json:"a"` @@ -1532,14 +890,7 @@ null }{}, }, { - name: "PtrHeadFloat32ZeroMultiFieldsNotRootOmitEmpty", - expected: `{"A":{},"B":{}}`, - indentExpected: ` -{ - "A": {}, - "B": {} -} -`, + name: "PtrHeadFloat32ZeroMultiFieldsNotRootOmitEmpty", data: &struct { A struct { A float32 `json:"a,omitempty"` @@ -1550,18 +901,7 @@ null }{}, }, { - name: "PtrHeadFloat32ZeroMultiFieldsNotRootString", - expected: `{"A":{"a":"0"},"B":{"b":"0"}}`, - indentExpected: ` -{ - "A": { - "a": "0" - }, - "B": { - "b": "0" - } -} -`, + name: "PtrHeadFloat32ZeroMultiFieldsNotRootString", data: &struct { A struct { A float32 `json:"a,string"` @@ -1574,18 +914,7 @@ null // PtrHeadFloat32MultiFieldsNotRoot { - name: "PtrHeadFloat32MultiFieldsNotRoot", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "PtrHeadFloat32MultiFieldsNotRoot", data: &struct { A struct { A float32 `json:"a"` @@ -1600,18 +929,7 @@ null }{B: 2}}, }, { - name: "PtrHeadFloat32MultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "PtrHeadFloat32MultiFieldsNotRootOmitEmpty", data: &struct { A struct { A float32 `json:"a,omitempty"` @@ -1626,18 +944,7 @@ null }{B: 2}}, }, { - name: "PtrHeadFloat32MultiFieldsNotRootString", - expected: `{"A":{"a":"1"},"B":{"b":"2"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - }, - "B": { - "b": "2" - } -} -`, + name: "PtrHeadFloat32MultiFieldsNotRootString", data: &struct { A struct { A float32 `json:"a,string"` @@ -1654,18 +961,7 @@ null // PtrHeadFloat32PtrMultiFieldsNotRoot { - name: "PtrHeadFloat32PtrMultiFieldsNotRoot", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "PtrHeadFloat32PtrMultiFieldsNotRoot", data: &struct { A *struct { A *float32 `json:"a"` @@ -1680,18 +976,7 @@ null }{B: float32ptr(2)})}, }, { - name: "PtrHeadFloat32PtrMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "PtrHeadFloat32PtrMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A *float32 `json:"a,omitempty"` @@ -1706,18 +991,7 @@ null }{B: float32ptr(2)})}, }, { - name: "PtrHeadFloat32PtrMultiFieldsNotRootString", - expected: `{"A":{"a":"1"},"B":{"b":"2"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - }, - "B": { - "b": "2" - } -} -`, + name: "PtrHeadFloat32PtrMultiFieldsNotRootString", data: &struct { A *struct { A *float32 `json:"a,string"` @@ -1734,14 +1008,7 @@ null // PtrHeadFloat32PtrNilMultiFieldsNotRoot { - name: "PtrHeadFloat32PtrNilMultiFieldsNotRoot", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadFloat32PtrNilMultiFieldsNotRoot", data: &struct { A *struct { A *float32 `json:"a"` @@ -1752,11 +1019,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadFloat32PtrNilMultiFieldsNotRootOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadFloat32PtrNilMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A *float32 `json:"a,omitempty"` @@ -1767,14 +1030,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadFloat32PtrNilMultiFieldsNotRootString", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadFloat32PtrNilMultiFieldsNotRootString", data: &struct { A *struct { A *float32 `json:"a,string"` @@ -1787,11 +1043,7 @@ null // PtrHeadFloat32NilMultiFieldsNotRoot { - name: "PtrHeadFloat32NilMultiFieldsNotRoot", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadFloat32NilMultiFieldsNotRoot", data: (*struct { A *struct { A *float32 `json:"a"` @@ -1802,11 +1054,7 @@ null })(nil), }, { - name: "PtrHeadFloat32NilMultiFieldsNotRootOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadFloat32NilMultiFieldsNotRootOmitEmpty", data: (*struct { A *struct { A *float32 `json:"a,omitempty"` @@ -1817,11 +1065,7 @@ null })(nil), }, { - name: "PtrHeadFloat32NilMultiFieldsNotRootString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadFloat32NilMultiFieldsNotRootString", data: (*struct { A *struct { A *float32 `json:"a,string"` @@ -1834,20 +1078,7 @@ null // PtrHeadFloat32DoubleMultiFieldsNotRoot { - name: "PtrHeadFloat32DoubleMultiFieldsNotRoot", - expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`, - indentExpected: ` -{ - "A": { - "a": 1, - "b": 2 - }, - "B": { - "a": 3, - "b": 4 - } -} -`, + name: "PtrHeadFloat32DoubleMultiFieldsNotRoot", data: &struct { A *struct { A float32 `json:"a"` @@ -1866,20 +1097,7 @@ null }{A: 3, B: 4})}, }, { - name: "PtrHeadFloat32DoubleMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`, - indentExpected: ` -{ - "A": { - "a": 1, - "b": 2 - }, - "B": { - "a": 3, - "b": 4 - } -} -`, + name: "PtrHeadFloat32DoubleMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A float32 `json:"a,omitempty"` @@ -1898,20 +1116,7 @@ null }{A: 3, B: 4})}, }, { - name: "PtrHeadFloat32DoubleMultiFieldsNotRootString", - expected: `{"A":{"a":"1","b":"2"},"B":{"a":"3","b":"4"}}`, - indentExpected: ` -{ - "A": { - "a": "1", - "b": "2" - }, - "B": { - "a": "3", - "b": "4" - } -} -`, + name: "PtrHeadFloat32DoubleMultiFieldsNotRootString", data: &struct { A *struct { A float32 `json:"a,string"` @@ -1932,14 +1137,7 @@ null // PtrHeadFloat32NilDoubleMultiFieldsNotRoot { - name: "PtrHeadFloat32NilDoubleMultiFieldsNotRoot", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadFloat32NilDoubleMultiFieldsNotRoot", data: &struct { A *struct { A float32 `json:"a"` @@ -1952,11 +1150,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadFloat32NilDoubleMultiFieldsNotRootOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadFloat32NilDoubleMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A float32 `json:"a,omitempty"` @@ -1969,14 +1163,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadFloat32NilDoubleMultiFieldsNotRootString", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadFloat32NilDoubleMultiFieldsNotRootString", data: &struct { A *struct { A float32 `json:"a,string"` @@ -1991,11 +1178,7 @@ null // PtrHeadFloat32NilDoubleMultiFieldsNotRoot { - name: "PtrHeadFloat32NilDoubleMultiFieldsNotRoot", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadFloat32NilDoubleMultiFieldsNotRoot", data: (*struct { A *struct { A float32 `json:"a"` @@ -2008,11 +1191,7 @@ null })(nil), }, { - name: "PtrHeadFloat32NilDoubleMultiFieldsNotRootOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadFloat32NilDoubleMultiFieldsNotRootOmitEmpty", data: (*struct { A *struct { A float32 `json:"a,omitempty"` @@ -2025,11 +1204,7 @@ null })(nil), }, { - name: "PtrHeadFloat32NilDoubleMultiFieldsNotRootString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadFloat32NilDoubleMultiFieldsNotRootString", data: (*struct { A *struct { A float32 `json:"a,string"` @@ -2044,20 +1219,7 @@ null // PtrHeadFloat32PtrDoubleMultiFieldsNotRoot { - name: "PtrHeadFloat32PtrDoubleMultiFieldsNotRoot", - expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`, - indentExpected: ` -{ - "A": { - "a": 1, - "b": 2 - }, - "B": { - "a": 3, - "b": 4 - } -} -`, + name: "PtrHeadFloat32PtrDoubleMultiFieldsNotRoot", data: &struct { A *struct { A *float32 `json:"a"` @@ -2076,20 +1238,7 @@ null }{A: float32ptr(3), B: float32ptr(4)})}, }, { - name: "PtrHeadFloat32PtrDoubleMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`, - indentExpected: ` -{ - "A": { - "a": 1, - "b": 2 - }, - "B": { - "a": 3, - "b": 4 - } -} -`, + name: "PtrHeadFloat32PtrDoubleMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A *float32 `json:"a,omitempty"` @@ -2108,20 +1257,7 @@ null }{A: float32ptr(3), B: float32ptr(4)})}, }, { - name: "PtrHeadFloat32PtrDoubleMultiFieldsNotRootString", - expected: `{"A":{"a":"1","b":"2"},"B":{"a":"3","b":"4"}}`, - indentExpected: ` -{ - "A": { - "a": "1", - "b": "2" - }, - "B": { - "a": "3", - "b": "4" - } -} -`, + name: "PtrHeadFloat32PtrDoubleMultiFieldsNotRootString", data: &struct { A *struct { A *float32 `json:"a,string"` @@ -2142,14 +1278,7 @@ null // PtrHeadFloat32PtrNilDoubleMultiFieldsNotRoot { - name: "PtrHeadFloat32PtrNilDoubleMultiFieldsNotRoot", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadFloat32PtrNilDoubleMultiFieldsNotRoot", data: &struct { A *struct { A *float32 `json:"a"` @@ -2162,11 +1291,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadFloat32PtrNilDoubleMultiFieldsNotRootOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadFloat32PtrNilDoubleMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A *float32 `json:"a,omitempty"` @@ -2179,14 +1304,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadFloat32PtrNilDoubleMultiFieldsNotRootString", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadFloat32PtrNilDoubleMultiFieldsNotRootString", data: &struct { A *struct { A *float32 `json:"a,string"` @@ -2201,11 +1319,7 @@ null // PtrHeadFloat32PtrNilDoubleMultiFieldsNotRoot { - name: "PtrHeadFloat32PtrNilDoubleMultiFieldsNotRoot", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadFloat32PtrNilDoubleMultiFieldsNotRoot", data: (*struct { A *struct { A *float32 `json:"a"` @@ -2218,11 +1332,7 @@ null })(nil), }, { - name: "PtrHeadFloat32PtrNilDoubleMultiFieldsNotRootOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadFloat32PtrNilDoubleMultiFieldsNotRootOmitEmpty", data: (*struct { A *struct { A *float32 `json:"a,omitempty"` @@ -2235,11 +1345,7 @@ null })(nil), }, { - name: "PtrHeadFloat32PtrNilDoubleMultiFieldsNotRootString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadFloat32PtrNilDoubleMultiFieldsNotRootString", data: (*struct { A *struct { A *float32 `json:"a,string"` @@ -2254,14 +1360,7 @@ null // AnonymousHeadFloat32 { - name: "AnonymousHeadFloat32", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "AnonymousHeadFloat32", data: struct { structFloat32 B float32 `json:"b"` @@ -2271,14 +1370,7 @@ null }, }, { - name: "AnonymousHeadFloat32OmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "AnonymousHeadFloat32OmitEmpty", data: struct { structFloat32OmitEmpty B float32 `json:"b,omitempty"` @@ -2288,14 +1380,7 @@ null }, }, { - name: "AnonymousHeadFloat32String", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "AnonymousHeadFloat32String", data: struct { structFloat32String B float32 `json:"b,string"` @@ -2307,14 +1392,7 @@ null // PtrAnonymousHeadFloat32 { - name: "PtrAnonymousHeadFloat32", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrAnonymousHeadFloat32", data: struct { *structFloat32 B float32 `json:"b"` @@ -2324,14 +1402,7 @@ null }, }, { - name: "PtrAnonymousHeadFloat32OmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrAnonymousHeadFloat32OmitEmpty", data: struct { *structFloat32OmitEmpty B float32 `json:"b,omitempty"` @@ -2341,14 +1412,7 @@ null }, }, { - name: "PtrAnonymousHeadFloat32String", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "PtrAnonymousHeadFloat32String", data: struct { *structFloat32String B float32 `json:"b,string"` @@ -2360,13 +1424,7 @@ null // NilPtrAnonymousHeadFloat32 { - name: "NilPtrAnonymousHeadFloat32", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "NilPtrAnonymousHeadFloat32", data: struct { *structFloat32 B float32 `json:"b"` @@ -2376,13 +1434,7 @@ null }, }, { - name: "NilPtrAnonymousHeadFloat32OmitEmpty", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "NilPtrAnonymousHeadFloat32OmitEmpty", data: struct { *structFloat32OmitEmpty B float32 `json:"b,omitempty"` @@ -2392,13 +1444,7 @@ null }, }, { - name: "NilPtrAnonymousHeadFloat32String", - expected: `{"b":"2"}`, - indentExpected: ` -{ - "b": "2" -} -`, + name: "NilPtrAnonymousHeadFloat32String", data: struct { *structFloat32String B float32 `json:"b,string"` @@ -2410,14 +1456,7 @@ null // AnonymousHeadFloat32Ptr { - name: "AnonymousHeadFloat32Ptr", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "AnonymousHeadFloat32Ptr", data: struct { structFloat32Ptr B *float32 `json:"b"` @@ -2427,14 +1466,7 @@ null }, }, { - name: "AnonymousHeadFloat32PtrOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "AnonymousHeadFloat32PtrOmitEmpty", data: struct { structFloat32PtrOmitEmpty B *float32 `json:"b,omitempty"` @@ -2444,14 +1476,7 @@ null }, }, { - name: "AnonymousHeadFloat32PtrString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "AnonymousHeadFloat32PtrString", data: struct { structFloat32PtrString B *float32 `json:"b,string"` @@ -2463,14 +1488,7 @@ null // AnonymousHeadFloat32PtrNil { - name: "AnonymousHeadFloat32PtrNil", - expected: `{"a":null,"b":2}`, - indentExpected: ` -{ - "a": null, - "b": 2 -} -`, + name: "AnonymousHeadFloat32PtrNil", data: struct { structFloat32Ptr B *float32 `json:"b"` @@ -2480,13 +1498,7 @@ null }, }, { - name: "AnonymousHeadFloat32PtrNilOmitEmpty", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "AnonymousHeadFloat32PtrNilOmitEmpty", data: struct { structFloat32PtrOmitEmpty B *float32 `json:"b,omitempty"` @@ -2496,14 +1508,7 @@ null }, }, { - name: "AnonymousHeadFloat32PtrNilString", - expected: `{"a":null,"b":"2"}`, - indentExpected: ` -{ - "a": null, - "b": "2" -} -`, + name: "AnonymousHeadFloat32PtrNilString", data: struct { structFloat32PtrString B *float32 `json:"b,string"` @@ -2515,14 +1520,7 @@ null // PtrAnonymousHeadFloat32Ptr { - name: "PtrAnonymousHeadFloat32Ptr", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrAnonymousHeadFloat32Ptr", data: struct { *structFloat32Ptr B *float32 `json:"b"` @@ -2532,14 +1530,7 @@ null }, }, { - name: "PtrAnonymousHeadFloat32PtrOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrAnonymousHeadFloat32PtrOmitEmpty", data: struct { *structFloat32PtrOmitEmpty B *float32 `json:"b,omitempty"` @@ -2549,14 +1540,7 @@ null }, }, { - name: "PtrAnonymousHeadFloat32PtrString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "PtrAnonymousHeadFloat32PtrString", data: struct { *structFloat32PtrString B *float32 `json:"b,string"` @@ -2568,13 +1552,7 @@ null // NilPtrAnonymousHeadFloat32Ptr { - name: "NilPtrAnonymousHeadFloat32Ptr", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "NilPtrAnonymousHeadFloat32Ptr", data: struct { *structFloat32Ptr B *float32 `json:"b"` @@ -2584,13 +1562,7 @@ null }, }, { - name: "NilPtrAnonymousHeadFloat32PtrOmitEmpty", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "NilPtrAnonymousHeadFloat32PtrOmitEmpty", data: struct { *structFloat32PtrOmitEmpty B *float32 `json:"b,omitempty"` @@ -2600,13 +1572,7 @@ null }, }, { - name: "NilPtrAnonymousHeadFloat32PtrString", - expected: `{"b":"2"}`, - indentExpected: ` -{ - "b": "2" -} -`, + name: "NilPtrAnonymousHeadFloat32PtrString", data: struct { *structFloat32PtrString B *float32 `json:"b,string"` @@ -2618,13 +1584,7 @@ null // AnonymousHeadFloat32Only { - name: "AnonymousHeadFloat32Only", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "AnonymousHeadFloat32Only", data: struct { structFloat32 }{ @@ -2632,13 +1592,7 @@ null }, }, { - name: "AnonymousHeadFloat32OnlyOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "AnonymousHeadFloat32OnlyOmitEmpty", data: struct { structFloat32OmitEmpty }{ @@ -2646,13 +1600,7 @@ null }, }, { - name: "AnonymousHeadFloat32OnlyString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "AnonymousHeadFloat32OnlyString", data: struct { structFloat32String }{ @@ -2662,13 +1610,7 @@ null // PtrAnonymousHeadFloat32Only { - name: "PtrAnonymousHeadFloat32Only", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrAnonymousHeadFloat32Only", data: struct { *structFloat32 }{ @@ -2676,13 +1618,7 @@ null }, }, { - name: "PtrAnonymousHeadFloat32OnlyOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrAnonymousHeadFloat32OnlyOmitEmpty", data: struct { *structFloat32OmitEmpty }{ @@ -2690,13 +1626,7 @@ null }, }, { - name: "PtrAnonymousHeadFloat32OnlyString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "PtrAnonymousHeadFloat32OnlyString", data: struct { *structFloat32String }{ @@ -2706,11 +1636,7 @@ null // NilPtrAnonymousHeadFloat32Only { - name: "NilPtrAnonymousHeadFloat32Only", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadFloat32Only", data: struct { *structFloat32 }{ @@ -2718,11 +1644,7 @@ null }, }, { - name: "NilPtrAnonymousHeadFloat32OnlyOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadFloat32OnlyOmitEmpty", data: struct { *structFloat32OmitEmpty }{ @@ -2730,11 +1652,7 @@ null }, }, { - name: "NilPtrAnonymousHeadFloat32OnlyString", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadFloat32OnlyString", data: struct { *structFloat32String }{ @@ -2744,13 +1662,7 @@ null // AnonymousHeadFloat32PtrOnly { - name: "AnonymousHeadFloat32PtrOnly", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "AnonymousHeadFloat32PtrOnly", data: struct { structFloat32Ptr }{ @@ -2758,13 +1670,7 @@ null }, }, { - name: "AnonymousHeadFloat32PtrOnlyOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "AnonymousHeadFloat32PtrOnlyOmitEmpty", data: struct { structFloat32PtrOmitEmpty }{ @@ -2772,13 +1678,7 @@ null }, }, { - name: "AnonymousHeadFloat32PtrOnlyString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "AnonymousHeadFloat32PtrOnlyString", data: struct { structFloat32PtrString }{ @@ -2788,13 +1688,7 @@ null // AnonymousHeadFloat32PtrNilOnly { - name: "AnonymousHeadFloat32PtrNilOnly", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "AnonymousHeadFloat32PtrNilOnly", data: struct { structFloat32Ptr }{ @@ -2802,11 +1696,7 @@ null }, }, { - name: "AnonymousHeadFloat32PtrNilOnlyOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "AnonymousHeadFloat32PtrNilOnlyOmitEmpty", data: struct { structFloat32PtrOmitEmpty }{ @@ -2814,13 +1704,7 @@ null }, }, { - name: "AnonymousHeadFloat32PtrNilOnlyString", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "AnonymousHeadFloat32PtrNilOnlyString", data: struct { structFloat32PtrString }{ @@ -2830,13 +1714,7 @@ null // PtrAnonymousHeadFloat32PtrOnly { - name: "PtrAnonymousHeadFloat32PtrOnly", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrAnonymousHeadFloat32PtrOnly", data: struct { *structFloat32Ptr }{ @@ -2844,13 +1722,7 @@ null }, }, { - name: "PtrAnonymousHeadFloat32PtrOnlyOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrAnonymousHeadFloat32PtrOnlyOmitEmpty", data: struct { *structFloat32PtrOmitEmpty }{ @@ -2858,13 +1730,7 @@ null }, }, { - name: "PtrAnonymousHeadFloat32PtrOnlyString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "PtrAnonymousHeadFloat32PtrOnlyString", data: struct { *structFloat32PtrString }{ @@ -2874,11 +1740,7 @@ null // NilPtrAnonymousHeadFloat32PtrOnly { - name: "NilPtrAnonymousHeadFloat32PtrOnly", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadFloat32PtrOnly", data: struct { *structFloat32Ptr }{ @@ -2886,11 +1748,7 @@ null }, }, { - name: "NilPtrAnonymousHeadFloat32PtrOnlyOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadFloat32PtrOnlyOmitEmpty", data: struct { *structFloat32PtrOmitEmpty }{ @@ -2898,11 +1756,7 @@ null }, }, { - name: "NilPtrAnonymousHeadFloat32PtrOnlyString", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadFloat32PtrOnlyString", data: struct { *structFloat32PtrString }{ @@ -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()) - } - } } } } From 589c4b035011befc192c461138cb0d1fc3583f2e Mon Sep 17 00:00:00 2001 From: Masaaki Goshima Date: Mon, 15 Feb 2021 11:31:26 +0900 Subject: [PATCH 12/15] Refactor cover_float64_test.go --- cover_float64_test.go | 1540 +++++------------------------------------ 1 file changed, 192 insertions(+), 1348 deletions(-) diff --git a/cover_float64_test.go b/cover_float64_test.go index 3d2c14e..4d046af 100644 --- a/cover_float64_test.go +++ b/cover_float64_test.go @@ -2,7 +2,6 @@ package json_test import ( "bytes" - "strings" "testing" "github.com/goccy/go-json" @@ -30,42 +29,24 @@ func TestCoverFloat64(t *testing.T) { } tests := []struct { - name string - expected string - indentExpected string - data interface{} + name string + data interface{} }{ // HeadFloat64Zero { - name: "HeadFloat64Zero", - expected: `{"a":0}`, - indentExpected: ` -{ - "a": 0 -} -`, + name: "HeadFloat64Zero", data: struct { A float64 `json:"a"` }{}, }, { - name: "HeadFloat64ZeroOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "HeadFloat64ZeroOmitEmpty", data: struct { A float64 `json:"a,omitempty"` }{}, }, { - name: "HeadFloat64ZeroString", - expected: `{"a":"0"}`, - indentExpected: ` -{ - "a": "0" -} -`, + name: "HeadFloat64ZeroString", data: struct { A float64 `json:"a,string"` }{}, @@ -73,37 +54,19 @@ func TestCoverFloat64(t *testing.T) { // HeadFloat64 { - name: "HeadFloat64", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "HeadFloat64", data: struct { A float64 `json:"a"` }{A: 1}, }, { - name: "HeadFloat64OmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "HeadFloat64OmitEmpty", data: struct { A float64 `json:"a,omitempty"` }{A: 1}, }, { - name: "HeadFloat64String", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "HeadFloat64String", data: struct { A float64 `json:"a,string"` }{A: 1}, @@ -111,37 +74,19 @@ func TestCoverFloat64(t *testing.T) { // HeadFloat64Ptr { - name: "HeadFloat64Ptr", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "HeadFloat64Ptr", data: struct { A *float64 `json:"a"` }{A: float64ptr(1)}, }, { - name: "HeadFloat64PtrOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "HeadFloat64PtrOmitEmpty", data: struct { A *float64 `json:"a,omitempty"` }{A: float64ptr(1)}, }, { - name: "HeadFloat64PtrString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "HeadFloat64PtrString", data: struct { A *float64 `json:"a,string"` }{A: float64ptr(1)}, @@ -149,35 +94,19 @@ func TestCoverFloat64(t *testing.T) { // HeadFloat64PtrNil { - name: "HeadFloat64PtrNil", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "HeadFloat64PtrNil", data: struct { A *float64 `json:"a"` }{A: nil}, }, { - name: "HeadFloat64PtrNilOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "HeadFloat64PtrNilOmitEmpty", data: struct { A *float64 `json:"a,omitempty"` }{A: nil}, }, { - name: "HeadFloat64PtrNilString", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "HeadFloat64PtrNilString", data: struct { A *float64 `json:"a,string"` }{A: nil}, @@ -185,35 +114,19 @@ func TestCoverFloat64(t *testing.T) { // PtrHeadFloat64Zero { - name: "PtrHeadFloat64Zero", - expected: `{"a":0}`, - indentExpected: ` -{ - "a": 0 -} -`, + name: "PtrHeadFloat64Zero", data: &struct { A float64 `json:"a"` }{}, }, { - name: "PtrHeadFloat64ZeroOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadFloat64ZeroOmitEmpty", data: &struct { A float64 `json:"a,omitempty"` }{}, }, { - name: "PtrHeadFloat64ZeroString", - expected: `{"a":"0"}`, - indentExpected: ` -{ - "a": "0" -} -`, + name: "PtrHeadFloat64ZeroString", data: &struct { A float64 `json:"a,string"` }{}, @@ -221,37 +134,19 @@ func TestCoverFloat64(t *testing.T) { // PtrHeadFloat64 { - name: "PtrHeadFloat64", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrHeadFloat64", data: &struct { A float64 `json:"a"` }{A: 1}, }, { - name: "PtrHeadFloat64OmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrHeadFloat64OmitEmpty", data: &struct { A float64 `json:"a,omitempty"` }{A: 1}, }, { - name: "PtrHeadFloat64String", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "PtrHeadFloat64String", data: &struct { A float64 `json:"a,string"` }{A: 1}, @@ -259,37 +154,19 @@ func TestCoverFloat64(t *testing.T) { // PtrHeadFloat64Ptr { - name: "PtrHeadFloat64Ptr", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrHeadFloat64Ptr", data: &struct { A *float64 `json:"a"` }{A: float64ptr(1)}, }, { - name: "PtrHeadFloat64PtrOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrHeadFloat64PtrOmitEmpty", data: &struct { A *float64 `json:"a,omitempty"` }{A: float64ptr(1)}, }, { - name: "PtrHeadFloat64PtrString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "PtrHeadFloat64PtrString", data: &struct { A *float64 `json:"a,string"` }{A: float64ptr(1)}, @@ -297,35 +174,19 @@ func TestCoverFloat64(t *testing.T) { // PtrHeadFloat64PtrNil { - name: "PtrHeadFloat64PtrNil", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "PtrHeadFloat64PtrNil", data: &struct { A *float64 `json:"a"` }{A: nil}, }, { - name: "PtrHeadFloat64PtrNilOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadFloat64PtrNilOmitEmpty", data: &struct { A *float64 `json:"a,omitempty"` }{A: nil}, }, { - name: "PtrHeadFloat64PtrNilString", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "PtrHeadFloat64PtrNilString", data: &struct { A *float64 `json:"a,string"` }{A: nil}, @@ -333,31 +194,19 @@ func TestCoverFloat64(t *testing.T) { // PtrHeadFloat64Nil { - name: "PtrHeadFloat64Nil", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadFloat64Nil", data: (*struct { A *float64 `json:"a"` })(nil), }, { - name: "PtrHeadFloat64NilOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadFloat64NilOmitEmpty", data: (*struct { A *float64 `json:"a,omitempty"` })(nil), }, { - name: "PtrHeadFloat64NilString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadFloat64NilString", data: (*struct { A *float64 `json:"a,string"` })(nil), @@ -365,209 +214,125 @@ null // HeadFloat64ZeroMultiFields { - name: "HeadFloat64ZeroMultiFields", - expected: `{"a":0,"b":0}`, - indentExpected: ` -{ - "a": 0, - "b": 0 -} -`, + name: "HeadFloat64ZeroMultiFields", data: struct { A float64 `json:"a"` B float64 `json:"b"` + C float64 `json:"c"` }{}, }, { - name: "HeadFloat64ZeroMultiFieldsOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "HeadFloat64ZeroMultiFieldsOmitEmpty", data: struct { A float64 `json:"a,omitempty"` B float64 `json:"b,omitempty"` + C float64 `json:"c,omitempty"` }{}, }, { - name: "HeadFloat64ZeroMultiFields", - expected: `{"a":"0","b":"0"}`, - indentExpected: ` -{ - "a": "0", - "b": "0" -} -`, + name: "HeadFloat64ZeroMultiFields", data: struct { A float64 `json:"a,string"` B float64 `json:"b,string"` + C float64 `json:"c,string"` }{}, }, // HeadFloat64MultiFields { - name: "HeadFloat64MultiFields", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "HeadFloat64MultiFields", data: struct { A float64 `json:"a"` B float64 `json:"b"` - }{A: 1, B: 2}, + C float64 `json:"c"` + }{A: 1, B: 2, C: 3}, }, { - name: "HeadFloat64MultiFieldsOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "HeadFloat64MultiFieldsOmitEmpty", data: struct { A float64 `json:"a,omitempty"` B float64 `json:"b,omitempty"` - }{A: 1, B: 2}, + C float64 `json:"c,omitempty"` + }{A: 1, B: 2, C: 3}, }, { - name: "HeadFloat64MultiFieldsString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "HeadFloat64MultiFieldsString", data: struct { A float64 `json:"a,string"` B float64 `json:"b,string"` - }{A: 1, B: 2}, + C float64 `json:"c,string"` + }{A: 1, B: 2, C: 3}, }, // HeadFloat64PtrMultiFields { - name: "HeadFloat64PtrMultiFields", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "HeadFloat64PtrMultiFields", data: struct { A *float64 `json:"a"` B *float64 `json:"b"` - }{A: float64ptr(1), B: float64ptr(2)}, + C *float64 `json:"c"` + }{A: float64ptr(1), B: float64ptr(2), C: float64ptr(3)}, }, { - name: "HeadFloat64PtrMultiFieldsOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "HeadFloat64PtrMultiFieldsOmitEmpty", data: struct { A *float64 `json:"a,omitempty"` B *float64 `json:"b,omitempty"` - }{A: float64ptr(1), B: float64ptr(2)}, + C *float64 `json:"c,omitempty"` + }{A: float64ptr(1), B: float64ptr(2), C: float64ptr(3)}, }, { - name: "HeadFloat64PtrMultiFieldsString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "HeadFloat64PtrMultiFieldsString", data: struct { A *float64 `json:"a,string"` B *float64 `json:"b,string"` - }{A: float64ptr(1), B: float64ptr(2)}, + C *float64 `json:"c,string"` + }{A: float64ptr(1), B: float64ptr(2), C: float64ptr(3)}, }, // HeadFloat64PtrNilMultiFields { - name: "HeadFloat64PtrNilMultiFields", - expected: `{"a":null,"b":null}`, - indentExpected: ` -{ - "a": null, - "b": null -} -`, + name: "HeadFloat64PtrNilMultiFields", data: struct { A *float64 `json:"a"` B *float64 `json:"b"` - }{A: nil, B: nil}, + C *float64 `json:"c"` + }{A: nil, B: nil, C: nil}, }, { - name: "HeadFloat64PtrNilMultiFieldsOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "HeadFloat64PtrNilMultiFieldsOmitEmpty", data: struct { A *float64 `json:"a,omitempty"` B *float64 `json:"b,omitempty"` - }{A: nil, B: nil}, + C *float64 `json:"c,omitempty"` + }{A: nil, B: nil, C: nil}, }, { - name: "HeadFloat64PtrNilMultiFieldsString", - expected: `{"a":null,"b":null}`, - indentExpected: ` -{ - "a": null, - "b": null -} -`, + name: "HeadFloat64PtrNilMultiFieldsString", data: struct { A *float64 `json:"a,string"` B *float64 `json:"b,string"` - }{A: nil, B: nil}, + C *float64 `json:"c,string"` + }{A: nil, B: nil, C: nil}, }, // PtrHeadFloat64ZeroMultiFields { - name: "PtrHeadFloat64ZeroMultiFields", - expected: `{"a":0,"b":0}`, - indentExpected: ` -{ - "a": 0, - "b": 0 -} -`, + name: "PtrHeadFloat64ZeroMultiFields", data: &struct { A float64 `json:"a"` B float64 `json:"b"` }{}, }, { - name: "PtrHeadFloat64ZeroMultiFieldsOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadFloat64ZeroMultiFieldsOmitEmpty", data: &struct { A float64 `json:"a,omitempty"` B float64 `json:"b,omitempty"` }{}, }, { - name: "PtrHeadFloat64ZeroMultiFieldsString", - expected: `{"a":"0","b":"0"}`, - indentExpected: ` -{ - "a": "0", - "b": "0" -} -`, + name: "PtrHeadFloat64ZeroMultiFieldsString", data: &struct { A float64 `json:"a,string"` B float64 `json:"b,string"` @@ -576,42 +341,21 @@ null // PtrHeadFloat64MultiFields { - name: "PtrHeadFloat64MultiFields", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrHeadFloat64MultiFields", data: &struct { A float64 `json:"a"` B float64 `json:"b"` }{A: 1, B: 2}, }, { - name: "PtrHeadFloat64MultiFieldsOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrHeadFloat64MultiFieldsOmitEmpty", data: &struct { A float64 `json:"a,omitempty"` B float64 `json:"b,omitempty"` }{A: 1, B: 2}, }, { - name: "PtrHeadFloat64MultiFieldsString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "PtrHeadFloat64MultiFieldsString", data: &struct { A float64 `json:"a,string"` B float64 `json:"b,string"` @@ -620,42 +364,21 @@ null // PtrHeadFloat64PtrMultiFields { - name: "PtrHeadFloat64PtrMultiFields", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrHeadFloat64PtrMultiFields", data: &struct { A *float64 `json:"a"` B *float64 `json:"b"` }{A: float64ptr(1), B: float64ptr(2)}, }, { - name: "PtrHeadFloat64PtrMultiFieldsOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrHeadFloat64PtrMultiFieldsOmitEmpty", data: &struct { A *float64 `json:"a,omitempty"` B *float64 `json:"b,omitempty"` }{A: float64ptr(1), B: float64ptr(2)}, }, { - name: "PtrHeadFloat64PtrMultiFieldsString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "PtrHeadFloat64PtrMultiFieldsString", data: &struct { A *float64 `json:"a,string"` B *float64 `json:"b,string"` @@ -664,39 +387,21 @@ null // PtrHeadFloat64PtrNilMultiFields { - name: "PtrHeadFloat64PtrNilMultiFields", - expected: `{"a":null,"b":null}`, - indentExpected: ` -{ - "a": null, - "b": null -} -`, + name: "PtrHeadFloat64PtrNilMultiFields", data: &struct { A *float64 `json:"a"` B *float64 `json:"b"` }{A: nil, B: nil}, }, { - name: "PtrHeadFloat64PtrNilMultiFieldsOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadFloat64PtrNilMultiFieldsOmitEmpty", data: &struct { A *float64 `json:"a,omitempty"` B *float64 `json:"b,omitempty"` }{A: nil, B: nil}, }, { - name: "PtrHeadFloat64PtrNilMultiFieldsString", - expected: `{"a":null,"b":null}`, - indentExpected: ` -{ - "a": null, - "b": null -} -`, + name: "PtrHeadFloat64PtrNilMultiFieldsString", data: &struct { A *float64 `json:"a,string"` B *float64 `json:"b,string"` @@ -705,33 +410,21 @@ null // PtrHeadFloat64NilMultiFields { - name: "PtrHeadFloat64NilMultiFields", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadFloat64NilMultiFields", data: (*struct { A *float64 `json:"a"` B *float64 `json:"b"` })(nil), }, { - name: "PtrHeadFloat64NilMultiFieldsOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadFloat64NilMultiFieldsOmitEmpty", data: (*struct { A *float64 `json:"a,omitempty"` B *float64 `json:"b,omitempty"` })(nil), }, { - name: "PtrHeadFloat64NilMultiFieldsString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadFloat64NilMultiFieldsString", data: (*struct { A *float64 `json:"a,string"` B *float64 `json:"b,string"` @@ -740,15 +433,7 @@ null // HeadFloat64ZeroNotRoot { - name: "HeadFloat64ZeroNotRoot", - expected: `{"A":{"a":0}}`, - indentExpected: ` -{ - "A": { - "a": 0 - } -} -`, + name: "HeadFloat64ZeroNotRoot", data: struct { A struct { A float64 `json:"a"` @@ -756,13 +441,7 @@ null }{}, }, { - name: "HeadFloat64ZeroNotRootOmitEmpty", - expected: `{"A":{}}`, - indentExpected: ` -{ - "A": {} -} -`, + name: "HeadFloat64ZeroNotRootOmitEmpty", data: struct { A struct { A float64 `json:"a,omitempty"` @@ -770,15 +449,7 @@ null }{}, }, { - name: "HeadFloat64ZeroNotRootString", - expected: `{"A":{"a":"0"}}`, - indentExpected: ` -{ - "A": { - "a": "0" - } -} -`, + name: "HeadFloat64ZeroNotRootString", data: struct { A struct { A float64 `json:"a,string"` @@ -788,15 +459,7 @@ null // HeadFloat64NotRoot { - name: "HeadFloat64NotRoot", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "HeadFloat64NotRoot", data: struct { A struct { A float64 `json:"a"` @@ -806,15 +469,7 @@ null }{A: 1}}, }, { - name: "HeadFloat64NotRootOmitEmpty", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "HeadFloat64NotRootOmitEmpty", data: struct { A struct { A float64 `json:"a,omitempty"` @@ -824,15 +479,7 @@ null }{A: 1}}, }, { - name: "HeadFloat64NotRootString", - expected: `{"A":{"a":"1"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - } -} -`, + name: "HeadFloat64NotRootString", data: struct { A struct { A float64 `json:"a,string"` @@ -844,15 +491,7 @@ null // HeadFloat64PtrNotRoot { - name: "HeadFloat64PtrNotRoot", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "HeadFloat64PtrNotRoot", data: struct { A struct { A *float64 `json:"a"` @@ -862,15 +501,7 @@ null }{float64ptr(1)}}, }, { - name: "HeadFloat64PtrNotRootOmitEmpty", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "HeadFloat64PtrNotRootOmitEmpty", data: struct { A struct { A *float64 `json:"a,omitempty"` @@ -880,15 +511,7 @@ null }{float64ptr(1)}}, }, { - name: "HeadFloat64PtrNotRootString", - expected: `{"A":{"a":"1"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - } -} -`, + name: "HeadFloat64PtrNotRootString", data: struct { A struct { A *float64 `json:"a,string"` @@ -900,15 +523,7 @@ null // HeadFloat64PtrNilNotRoot { - name: "HeadFloat64PtrNilNotRoot", - expected: `{"A":{"a":null}}`, - indentExpected: ` -{ - "A": { - "a": null - } -} -`, + name: "HeadFloat64PtrNilNotRoot", data: struct { A struct { A *float64 `json:"a"` @@ -916,13 +531,7 @@ null }{}, }, { - name: "HeadFloat64PtrNilNotRootOmitEmpty", - expected: `{"A":{}}`, - indentExpected: ` -{ - "A": {} -} -`, + name: "HeadFloat64PtrNilNotRootOmitEmpty", data: struct { A struct { A *float64 `json:"a,omitempty"` @@ -930,15 +539,7 @@ null }{}, }, { - name: "HeadFloat64PtrNilNotRootString", - expected: `{"A":{"a":null}}`, - indentExpected: ` -{ - "A": { - "a": null - } -} -`, + name: "HeadFloat64PtrNilNotRootString", data: struct { A struct { A *float64 `json:"a,string"` @@ -948,15 +549,7 @@ null // PtrHeadFloat64ZeroNotRoot { - name: "PtrHeadFloat64ZeroNotRoot", - expected: `{"A":{"a":0}}`, - indentExpected: ` -{ - "A": { - "a": 0 - } -} -`, + name: "PtrHeadFloat64ZeroNotRoot", data: struct { A *struct { A float64 `json:"a"` @@ -966,13 +559,7 @@ null })}, }, { - name: "PtrHeadFloat64ZeroNotRootOmitEmpty", - expected: `{"A":{}}`, - indentExpected: ` -{ - "A": {} -} -`, + name: "PtrHeadFloat64ZeroNotRootOmitEmpty", data: struct { A *struct { A float64 `json:"a,omitempty"` @@ -982,15 +569,7 @@ null })}, }, { - name: "PtrHeadFloat64ZeroNotRootString", - expected: `{"A":{"a":"0"}}`, - indentExpected: ` -{ - "A": { - "a": "0" - } -} -`, + name: "PtrHeadFloat64ZeroNotRootString", data: struct { A *struct { A float64 `json:"a,string"` @@ -1002,15 +581,7 @@ null // PtrHeadFloat64NotRoot { - name: "PtrHeadFloat64NotRoot", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "PtrHeadFloat64NotRoot", data: struct { A *struct { A float64 `json:"a"` @@ -1020,15 +591,7 @@ null }{A: 1})}, }, { - name: "PtrHeadFloat64NotRootOmitEmpty", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "PtrHeadFloat64NotRootOmitEmpty", data: struct { A *struct { A float64 `json:"a,omitempty"` @@ -1038,15 +601,7 @@ null }{A: 1})}, }, { - name: "PtrHeadFloat64NotRootString", - expected: `{"A":{"a":"1"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - } -} -`, + name: "PtrHeadFloat64NotRootString", data: struct { A *struct { A float64 `json:"a,string"` @@ -1058,15 +613,7 @@ null // PtrHeadFloat64PtrNotRoot { - name: "PtrHeadFloat64PtrNotRoot", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "PtrHeadFloat64PtrNotRoot", data: struct { A *struct { A *float64 `json:"a"` @@ -1076,15 +623,7 @@ null }{A: float64ptr(1)})}, }, { - name: "PtrHeadFloat64PtrNotRootOmitEmpty", - expected: `{"A":{"a":1}}`, - indentExpected: ` -{ - "A": { - "a": 1 - } -} -`, + name: "PtrHeadFloat64PtrNotRootOmitEmpty", data: struct { A *struct { A *float64 `json:"a,omitempty"` @@ -1094,15 +633,7 @@ null }{A: float64ptr(1)})}, }, { - name: "PtrHeadFloat64PtrNotRootString", - expected: `{"A":{"a":"1"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - } -} -`, + name: "PtrHeadFloat64PtrNotRootString", data: struct { A *struct { A *float64 `json:"a,string"` @@ -1114,15 +645,7 @@ null // PtrHeadFloat64PtrNilNotRoot { - name: "PtrHeadFloat64PtrNilNotRoot", - expected: `{"A":{"a":null}}`, - indentExpected: ` -{ - "A": { - "a": null - } -} -`, + name: "PtrHeadFloat64PtrNilNotRoot", data: struct { A *struct { A *float64 `json:"a"` @@ -1132,13 +655,7 @@ null }{A: nil})}, }, { - name: "PtrHeadFloat64PtrNilNotRootOmitEmpty", - expected: `{"A":{}}`, - indentExpected: ` -{ - "A": {} -} -`, + name: "PtrHeadFloat64PtrNilNotRootOmitEmpty", data: struct { A *struct { A *float64 `json:"a,omitempty"` @@ -1148,15 +665,7 @@ null }{A: nil})}, }, { - name: "PtrHeadFloat64PtrNilNotRootString", - expected: `{"A":{"a":null}}`, - indentExpected: ` -{ - "A": { - "a": null - } -} -`, + name: "PtrHeadFloat64PtrNilNotRootString", data: struct { A *struct { A *float64 `json:"a,string"` @@ -1168,13 +677,7 @@ null // PtrHeadFloat64NilNotRoot { - name: "PtrHeadFloat64NilNotRoot", - expected: `{"A":null}`, - indentExpected: ` -{ - "A": null -} -`, + name: "PtrHeadFloat64NilNotRoot", data: struct { A *struct { A *float64 `json:"a"` @@ -1182,11 +685,7 @@ null }{A: nil}, }, { - name: "PtrHeadFloat64NilNotRootOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadFloat64NilNotRootOmitEmpty", data: struct { A *struct { A *float64 `json:"a,omitempty"` @@ -1194,13 +693,7 @@ null }{A: nil}, }, { - name: "PtrHeadFloat64NilNotRootString", - expected: `{"A":null}`, - indentExpected: ` -{ - "A": null -} -`, + name: "PtrHeadFloat64NilNotRootString", data: struct { A *struct { A *float64 `json:"a,string"` @@ -1210,18 +703,7 @@ null // HeadFloat64ZeroMultiFieldsNotRoot { - name: "HeadFloat64ZeroMultiFieldsNotRoot", - expected: `{"A":{"a":0},"B":{"b":0}}`, - indentExpected: ` -{ - "A": { - "a": 0 - }, - "B": { - "b": 0 - } -} -`, + name: "HeadFloat64ZeroMultiFieldsNotRoot", data: struct { A struct { A float64 `json:"a"` @@ -1232,14 +714,7 @@ null }{}, }, { - name: "HeadFloat64ZeroMultiFieldsNotRootOmitEmpty", - expected: `{"A":{},"B":{}}`, - indentExpected: ` -{ - "A": {}, - "B": {} -} -`, + name: "HeadFloat64ZeroMultiFieldsNotRootOmitEmpty", data: struct { A struct { A float64 `json:"a,omitempty"` @@ -1250,18 +725,7 @@ null }{}, }, { - name: "HeadFloat64ZeroMultiFieldsNotRootString", - expected: `{"A":{"a":"0"},"B":{"b":"0"}}`, - indentExpected: ` -{ - "A": { - "a": "0" - }, - "B": { - "b": "0" - } -} -`, + name: "HeadFloat64ZeroMultiFieldsNotRootString", data: struct { A struct { A float64 `json:"a,string"` @@ -1274,18 +738,7 @@ null // HeadFloat64MultiFieldsNotRoot { - name: "HeadFloat64MultiFieldsNotRoot", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "HeadFloat64MultiFieldsNotRoot", data: struct { A struct { A float64 `json:"a"` @@ -1300,18 +753,7 @@ null }{B: 2}}, }, { - name: "HeadFloat64MultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "HeadFloat64MultiFieldsNotRootOmitEmpty", data: struct { A struct { A float64 `json:"a,omitempty"` @@ -1326,18 +768,7 @@ null }{B: 2}}, }, { - name: "HeadFloat64MultiFieldsNotRootString", - expected: `{"A":{"a":"1"},"B":{"b":"2"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - }, - "B": { - "b": "2" - } -} -`, + name: "HeadFloat64MultiFieldsNotRootString", data: struct { A struct { A float64 `json:"a,string"` @@ -1354,18 +785,7 @@ null // HeadFloat64PtrMultiFieldsNotRoot { - name: "HeadFloat64PtrMultiFieldsNotRoot", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "HeadFloat64PtrMultiFieldsNotRoot", data: struct { A struct { A *float64 `json:"a"` @@ -1380,18 +800,7 @@ null }{B: float64ptr(2)}}, }, { - name: "HeadFloat64PtrMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "HeadFloat64PtrMultiFieldsNotRootOmitEmpty", data: struct { A struct { A *float64 `json:"a,omitempty"` @@ -1406,18 +815,7 @@ null }{B: float64ptr(2)}}, }, { - name: "HeadFloat64PtrMultiFieldsNotRootString", - expected: `{"A":{"a":"1"},"B":{"b":"2"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - }, - "B": { - "b": "2" - } -} -`, + name: "HeadFloat64PtrMultiFieldsNotRootString", data: struct { A struct { A *float64 `json:"a,string"` @@ -1434,18 +832,7 @@ null // HeadFloat64PtrNilMultiFieldsNotRoot { - name: "HeadFloat64PtrNilMultiFieldsNotRoot", - expected: `{"A":{"a":null},"B":{"b":null}}`, - indentExpected: ` -{ - "A": { - "a": null - }, - "B": { - "b": null - } -} -`, + name: "HeadFloat64PtrNilMultiFieldsNotRoot", data: struct { A struct { A *float64 `json:"a"` @@ -1460,14 +847,7 @@ null }{B: nil}}, }, { - name: "HeadFloat64PtrNilMultiFieldsNotRootOmitEmpty", - expected: `{"A":{},"B":{}}`, - indentExpected: ` -{ - "A": {}, - "B": {} -} -`, + name: "HeadFloat64PtrNilMultiFieldsNotRootOmitEmpty", data: struct { A struct { A *float64 `json:"a,omitempty"` @@ -1482,18 +862,7 @@ null }{B: nil}}, }, { - name: "HeadFloat64PtrNilMultiFieldsNotRootString", - expected: `{"A":{"a":null},"B":{"b":null}}`, - indentExpected: ` -{ - "A": { - "a": null - }, - "B": { - "b": null - } -} -`, + name: "HeadFloat64PtrNilMultiFieldsNotRootString", data: struct { A struct { A *float64 `json:"a,string"` @@ -1510,18 +879,7 @@ null // PtrHeadFloat64ZeroMultiFieldsNotRoot { - name: "PtrHeadFloat64ZeroMultiFieldsNotRoot", - expected: `{"A":{"a":0},"B":{"b":0}}`, - indentExpected: ` -{ - "A": { - "a": 0 - }, - "B": { - "b": 0 - } -} -`, + name: "PtrHeadFloat64ZeroMultiFieldsNotRoot", data: &struct { A struct { A float64 `json:"a"` @@ -1532,14 +890,7 @@ null }{}, }, { - name: "PtrHeadFloat64ZeroMultiFieldsNotRootOmitEmpty", - expected: `{"A":{},"B":{}}`, - indentExpected: ` -{ - "A": {}, - "B": {} -} -`, + name: "PtrHeadFloat64ZeroMultiFieldsNotRootOmitEmpty", data: &struct { A struct { A float64 `json:"a,omitempty"` @@ -1550,18 +901,7 @@ null }{}, }, { - name: "PtrHeadFloat64ZeroMultiFieldsNotRootString", - expected: `{"A":{"a":"0"},"B":{"b":"0"}}`, - indentExpected: ` -{ - "A": { - "a": "0" - }, - "B": { - "b": "0" - } -} -`, + name: "PtrHeadFloat64ZeroMultiFieldsNotRootString", data: &struct { A struct { A float64 `json:"a,string"` @@ -1574,18 +914,7 @@ null // PtrHeadFloat64MultiFieldsNotRoot { - name: "PtrHeadFloat64MultiFieldsNotRoot", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "PtrHeadFloat64MultiFieldsNotRoot", data: &struct { A struct { A float64 `json:"a"` @@ -1600,18 +929,7 @@ null }{B: 2}}, }, { - name: "PtrHeadFloat64MultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "PtrHeadFloat64MultiFieldsNotRootOmitEmpty", data: &struct { A struct { A float64 `json:"a,omitempty"` @@ -1626,18 +944,7 @@ null }{B: 2}}, }, { - name: "PtrHeadFloat64MultiFieldsNotRootString", - expected: `{"A":{"a":"1"},"B":{"b":"2"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - }, - "B": { - "b": "2" - } -} -`, + name: "PtrHeadFloat64MultiFieldsNotRootString", data: &struct { A struct { A float64 `json:"a,string"` @@ -1654,18 +961,7 @@ null // PtrHeadFloat64PtrMultiFieldsNotRoot { - name: "PtrHeadFloat64PtrMultiFieldsNotRoot", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "PtrHeadFloat64PtrMultiFieldsNotRoot", data: &struct { A *struct { A *float64 `json:"a"` @@ -1680,18 +976,7 @@ null }{B: float64ptr(2)})}, }, { - name: "PtrHeadFloat64PtrMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1},"B":{"b":2}}`, - indentExpected: ` -{ - "A": { - "a": 1 - }, - "B": { - "b": 2 - } -} -`, + name: "PtrHeadFloat64PtrMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A *float64 `json:"a,omitempty"` @@ -1706,18 +991,7 @@ null }{B: float64ptr(2)})}, }, { - name: "PtrHeadFloat64PtrMultiFieldsNotRootString", - expected: `{"A":{"a":"1"},"B":{"b":"2"}}`, - indentExpected: ` -{ - "A": { - "a": "1" - }, - "B": { - "b": "2" - } -} -`, + name: "PtrHeadFloat64PtrMultiFieldsNotRootString", data: &struct { A *struct { A *float64 `json:"a,string"` @@ -1734,14 +1008,7 @@ null // PtrHeadFloat64PtrNilMultiFieldsNotRoot { - name: "PtrHeadFloat64PtrNilMultiFieldsNotRoot", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadFloat64PtrNilMultiFieldsNotRoot", data: &struct { A *struct { A *float64 `json:"a"` @@ -1752,11 +1019,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadFloat64PtrNilMultiFieldsNotRootOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadFloat64PtrNilMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A *float64 `json:"a,omitempty"` @@ -1767,14 +1030,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadFloat64PtrNilMultiFieldsNotRootString", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadFloat64PtrNilMultiFieldsNotRootString", data: &struct { A *struct { A *float64 `json:"a,string"` @@ -1787,11 +1043,7 @@ null // PtrHeadFloat64NilMultiFieldsNotRoot { - name: "PtrHeadFloat64NilMultiFieldsNotRoot", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadFloat64NilMultiFieldsNotRoot", data: (*struct { A *struct { A *float64 `json:"a"` @@ -1802,11 +1054,7 @@ null })(nil), }, { - name: "PtrHeadFloat64NilMultiFieldsNotRootOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadFloat64NilMultiFieldsNotRootOmitEmpty", data: (*struct { A *struct { A *float64 `json:"a,omitempty"` @@ -1817,11 +1065,7 @@ null })(nil), }, { - name: "PtrHeadFloat64NilMultiFieldsNotRootString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadFloat64NilMultiFieldsNotRootString", data: (*struct { A *struct { A *float64 `json:"a,string"` @@ -1834,20 +1078,7 @@ null // PtrHeadFloat64DoubleMultiFieldsNotRoot { - name: "PtrHeadFloat64DoubleMultiFieldsNotRoot", - expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`, - indentExpected: ` -{ - "A": { - "a": 1, - "b": 2 - }, - "B": { - "a": 3, - "b": 4 - } -} -`, + name: "PtrHeadFloat64DoubleMultiFieldsNotRoot", data: &struct { A *struct { A float64 `json:"a"` @@ -1866,20 +1097,7 @@ null }{A: 3, B: 4})}, }, { - name: "PtrHeadFloat64DoubleMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`, - indentExpected: ` -{ - "A": { - "a": 1, - "b": 2 - }, - "B": { - "a": 3, - "b": 4 - } -} -`, + name: "PtrHeadFloat64DoubleMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A float64 `json:"a,omitempty"` @@ -1898,20 +1116,7 @@ null }{A: 3, B: 4})}, }, { - name: "PtrHeadFloat64DoubleMultiFieldsNotRootString", - expected: `{"A":{"a":"1","b":"2"},"B":{"a":"3","b":"4"}}`, - indentExpected: ` -{ - "A": { - "a": "1", - "b": "2" - }, - "B": { - "a": "3", - "b": "4" - } -} -`, + name: "PtrHeadFloat64DoubleMultiFieldsNotRootString", data: &struct { A *struct { A float64 `json:"a,string"` @@ -1932,14 +1137,7 @@ null // PtrHeadFloat64NilDoubleMultiFieldsNotRoot { - name: "PtrHeadFloat64NilDoubleMultiFieldsNotRoot", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadFloat64NilDoubleMultiFieldsNotRoot", data: &struct { A *struct { A float64 `json:"a"` @@ -1952,11 +1150,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadFloat64NilDoubleMultiFieldsNotRootOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadFloat64NilDoubleMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A float64 `json:"a,omitempty"` @@ -1969,14 +1163,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadFloat64NilDoubleMultiFieldsNotRootString", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadFloat64NilDoubleMultiFieldsNotRootString", data: &struct { A *struct { A float64 `json:"a,string"` @@ -1991,11 +1178,7 @@ null // PtrHeadFloat64NilDoubleMultiFieldsNotRoot { - name: "PtrHeadFloat64NilDoubleMultiFieldsNotRoot", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadFloat64NilDoubleMultiFieldsNotRoot", data: (*struct { A *struct { A float64 `json:"a"` @@ -2008,11 +1191,7 @@ null })(nil), }, { - name: "PtrHeadFloat64NilDoubleMultiFieldsNotRootOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadFloat64NilDoubleMultiFieldsNotRootOmitEmpty", data: (*struct { A *struct { A float64 `json:"a,omitempty"` @@ -2025,11 +1204,7 @@ null })(nil), }, { - name: "PtrHeadFloat64NilDoubleMultiFieldsNotRootString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadFloat64NilDoubleMultiFieldsNotRootString", data: (*struct { A *struct { A float64 `json:"a,string"` @@ -2044,20 +1219,7 @@ null // PtrHeadFloat64PtrDoubleMultiFieldsNotRoot { - name: "PtrHeadFloat64PtrDoubleMultiFieldsNotRoot", - expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`, - indentExpected: ` -{ - "A": { - "a": 1, - "b": 2 - }, - "B": { - "a": 3, - "b": 4 - } -} -`, + name: "PtrHeadFloat64PtrDoubleMultiFieldsNotRoot", data: &struct { A *struct { A *float64 `json:"a"` @@ -2076,20 +1238,7 @@ null }{A: float64ptr(3), B: float64ptr(4)})}, }, { - name: "PtrHeadFloat64PtrDoubleMultiFieldsNotRootOmitEmpty", - expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`, - indentExpected: ` -{ - "A": { - "a": 1, - "b": 2 - }, - "B": { - "a": 3, - "b": 4 - } -} -`, + name: "PtrHeadFloat64PtrDoubleMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A *float64 `json:"a,omitempty"` @@ -2108,20 +1257,7 @@ null }{A: float64ptr(3), B: float64ptr(4)})}, }, { - name: "PtrHeadFloat64PtrDoubleMultiFieldsNotRootString", - expected: `{"A":{"a":"1","b":"2"},"B":{"a":"3","b":"4"}}`, - indentExpected: ` -{ - "A": { - "a": "1", - "b": "2" - }, - "B": { - "a": "3", - "b": "4" - } -} -`, + name: "PtrHeadFloat64PtrDoubleMultiFieldsNotRootString", data: &struct { A *struct { A *float64 `json:"a,string"` @@ -2142,14 +1278,7 @@ null // PtrHeadFloat64PtrNilDoubleMultiFieldsNotRoot { - name: "PtrHeadFloat64PtrNilDoubleMultiFieldsNotRoot", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadFloat64PtrNilDoubleMultiFieldsNotRoot", data: &struct { A *struct { A *float64 `json:"a"` @@ -2162,11 +1291,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadFloat64PtrNilDoubleMultiFieldsNotRootOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "PtrHeadFloat64PtrNilDoubleMultiFieldsNotRootOmitEmpty", data: &struct { A *struct { A *float64 `json:"a,omitempty"` @@ -2179,14 +1304,7 @@ null }{A: nil, B: nil}, }, { - name: "PtrHeadFloat64PtrNilDoubleMultiFieldsNotRootString", - expected: `{"A":null,"B":null}`, - indentExpected: ` -{ - "A": null, - "B": null -} -`, + name: "PtrHeadFloat64PtrNilDoubleMultiFieldsNotRootString", data: &struct { A *struct { A *float64 `json:"a,string"` @@ -2201,11 +1319,7 @@ null // PtrHeadFloat64PtrNilDoubleMultiFieldsNotRoot { - name: "PtrHeadFloat64PtrNilDoubleMultiFieldsNotRoot", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadFloat64PtrNilDoubleMultiFieldsNotRoot", data: (*struct { A *struct { A *float64 `json:"a"` @@ -2218,11 +1332,7 @@ null })(nil), }, { - name: "PtrHeadFloat64PtrNilDoubleMultiFieldsNotRootOmitEmpty", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadFloat64PtrNilDoubleMultiFieldsNotRootOmitEmpty", data: (*struct { A *struct { A *float64 `json:"a,omitempty"` @@ -2235,11 +1345,7 @@ null })(nil), }, { - name: "PtrHeadFloat64PtrNilDoubleMultiFieldsNotRootString", - expected: `null`, - indentExpected: ` -null -`, + name: "PtrHeadFloat64PtrNilDoubleMultiFieldsNotRootString", data: (*struct { A *struct { A *float64 `json:"a,string"` @@ -2254,14 +1360,7 @@ null // AnonymousHeadFloat64 { - name: "AnonymousHeadFloat64", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "AnonymousHeadFloat64", data: struct { structFloat64 B float64 `json:"b"` @@ -2271,14 +1370,7 @@ null }, }, { - name: "AnonymousHeadFloat64OmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "AnonymousHeadFloat64OmitEmpty", data: struct { structFloat64OmitEmpty B float64 `json:"b,omitempty"` @@ -2288,14 +1380,7 @@ null }, }, { - name: "AnonymousHeadFloat64String", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "AnonymousHeadFloat64String", data: struct { structFloat64String B float64 `json:"b,string"` @@ -2307,14 +1392,7 @@ null // PtrAnonymousHeadFloat64 { - name: "PtrAnonymousHeadFloat64", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrAnonymousHeadFloat64", data: struct { *structFloat64 B float64 `json:"b"` @@ -2324,14 +1402,7 @@ null }, }, { - name: "PtrAnonymousHeadFloat64OmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrAnonymousHeadFloat64OmitEmpty", data: struct { *structFloat64OmitEmpty B float64 `json:"b,omitempty"` @@ -2341,14 +1412,7 @@ null }, }, { - name: "PtrAnonymousHeadFloat64String", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "PtrAnonymousHeadFloat64String", data: struct { *structFloat64String B float64 `json:"b,string"` @@ -2360,13 +1424,7 @@ null // NilPtrAnonymousHeadFloat64 { - name: "NilPtrAnonymousHeadFloat64", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "NilPtrAnonymousHeadFloat64", data: struct { *structFloat64 B float64 `json:"b"` @@ -2376,13 +1434,7 @@ null }, }, { - name: "NilPtrAnonymousHeadFloat64OmitEmpty", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "NilPtrAnonymousHeadFloat64OmitEmpty", data: struct { *structFloat64OmitEmpty B float64 `json:"b,omitempty"` @@ -2392,13 +1444,7 @@ null }, }, { - name: "NilPtrAnonymousHeadFloat64String", - expected: `{"b":"2"}`, - indentExpected: ` -{ - "b": "2" -} -`, + name: "NilPtrAnonymousHeadFloat64String", data: struct { *structFloat64String B float64 `json:"b,string"` @@ -2410,14 +1456,7 @@ null // AnonymousHeadFloat64Ptr { - name: "AnonymousHeadFloat64Ptr", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "AnonymousHeadFloat64Ptr", data: struct { structFloat64Ptr B *float64 `json:"b"` @@ -2427,14 +1466,7 @@ null }, }, { - name: "AnonymousHeadFloat64PtrOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "AnonymousHeadFloat64PtrOmitEmpty", data: struct { structFloat64PtrOmitEmpty B *float64 `json:"b,omitempty"` @@ -2444,14 +1476,7 @@ null }, }, { - name: "AnonymousHeadFloat64PtrString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "AnonymousHeadFloat64PtrString", data: struct { structFloat64PtrString B *float64 `json:"b,string"` @@ -2463,14 +1488,7 @@ null // AnonymousHeadFloat64PtrNil { - name: "AnonymousHeadFloat64PtrNil", - expected: `{"a":null,"b":2}`, - indentExpected: ` -{ - "a": null, - "b": 2 -} -`, + name: "AnonymousHeadFloat64PtrNil", data: struct { structFloat64Ptr B *float64 `json:"b"` @@ -2480,13 +1498,7 @@ null }, }, { - name: "AnonymousHeadFloat64PtrNilOmitEmpty", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "AnonymousHeadFloat64PtrNilOmitEmpty", data: struct { structFloat64PtrOmitEmpty B *float64 `json:"b,omitempty"` @@ -2496,14 +1508,7 @@ null }, }, { - name: "AnonymousHeadFloat64PtrNilString", - expected: `{"a":null,"b":"2"}`, - indentExpected: ` -{ - "a": null, - "b": "2" -} -`, + name: "AnonymousHeadFloat64PtrNilString", data: struct { structFloat64PtrString B *float64 `json:"b,string"` @@ -2515,14 +1520,7 @@ null // PtrAnonymousHeadFloat64Ptr { - name: "PtrAnonymousHeadFloat64Ptr", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrAnonymousHeadFloat64Ptr", data: struct { *structFloat64Ptr B *float64 `json:"b"` @@ -2532,14 +1530,7 @@ null }, }, { - name: "PtrAnonymousHeadFloat64PtrOmitEmpty", - expected: `{"a":1,"b":2}`, - indentExpected: ` -{ - "a": 1, - "b": 2 -} -`, + name: "PtrAnonymousHeadFloat64PtrOmitEmpty", data: struct { *structFloat64PtrOmitEmpty B *float64 `json:"b,omitempty"` @@ -2549,14 +1540,7 @@ null }, }, { - name: "PtrAnonymousHeadFloat64PtrString", - expected: `{"a":"1","b":"2"}`, - indentExpected: ` -{ - "a": "1", - "b": "2" -} -`, + name: "PtrAnonymousHeadFloat64PtrString", data: struct { *structFloat64PtrString B *float64 `json:"b,string"` @@ -2568,13 +1552,7 @@ null // NilPtrAnonymousHeadFloat64Ptr { - name: "NilPtrAnonymousHeadFloat64Ptr", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "NilPtrAnonymousHeadFloat64Ptr", data: struct { *structFloat64Ptr B *float64 `json:"b"` @@ -2584,13 +1562,7 @@ null }, }, { - name: "NilPtrAnonymousHeadFloat64PtrOmitEmpty", - expected: `{"b":2}`, - indentExpected: ` -{ - "b": 2 -} -`, + name: "NilPtrAnonymousHeadFloat64PtrOmitEmpty", data: struct { *structFloat64PtrOmitEmpty B *float64 `json:"b,omitempty"` @@ -2600,13 +1572,7 @@ null }, }, { - name: "NilPtrAnonymousHeadFloat64PtrString", - expected: `{"b":"2"}`, - indentExpected: ` -{ - "b": "2" -} -`, + name: "NilPtrAnonymousHeadFloat64PtrString", data: struct { *structFloat64PtrString B *float64 `json:"b,string"` @@ -2618,13 +1584,7 @@ null // AnonymousHeadFloat64Only { - name: "AnonymousHeadFloat64Only", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "AnonymousHeadFloat64Only", data: struct { structFloat64 }{ @@ -2632,13 +1592,7 @@ null }, }, { - name: "AnonymousHeadFloat64OnlyOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "AnonymousHeadFloat64OnlyOmitEmpty", data: struct { structFloat64OmitEmpty }{ @@ -2646,13 +1600,7 @@ null }, }, { - name: "AnonymousHeadFloat64OnlyString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "AnonymousHeadFloat64OnlyString", data: struct { structFloat64String }{ @@ -2662,13 +1610,7 @@ null // PtrAnonymousHeadFloat64Only { - name: "PtrAnonymousHeadFloat64Only", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrAnonymousHeadFloat64Only", data: struct { *structFloat64 }{ @@ -2676,13 +1618,7 @@ null }, }, { - name: "PtrAnonymousHeadFloat64OnlyOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrAnonymousHeadFloat64OnlyOmitEmpty", data: struct { *structFloat64OmitEmpty }{ @@ -2690,13 +1626,7 @@ null }, }, { - name: "PtrAnonymousHeadFloat64OnlyString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "PtrAnonymousHeadFloat64OnlyString", data: struct { *structFloat64String }{ @@ -2706,11 +1636,7 @@ null // NilPtrAnonymousHeadFloat64Only { - name: "NilPtrAnonymousHeadFloat64Only", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadFloat64Only", data: struct { *structFloat64 }{ @@ -2718,11 +1644,7 @@ null }, }, { - name: "NilPtrAnonymousHeadFloat64OnlyOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadFloat64OnlyOmitEmpty", data: struct { *structFloat64OmitEmpty }{ @@ -2730,11 +1652,7 @@ null }, }, { - name: "NilPtrAnonymousHeadFloat64OnlyString", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadFloat64OnlyString", data: struct { *structFloat64String }{ @@ -2744,13 +1662,7 @@ null // AnonymousHeadFloat64PtrOnly { - name: "AnonymousHeadFloat64PtrOnly", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "AnonymousHeadFloat64PtrOnly", data: struct { structFloat64Ptr }{ @@ -2758,13 +1670,7 @@ null }, }, { - name: "AnonymousHeadFloat64PtrOnlyOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "AnonymousHeadFloat64PtrOnlyOmitEmpty", data: struct { structFloat64PtrOmitEmpty }{ @@ -2772,13 +1678,7 @@ null }, }, { - name: "AnonymousHeadFloat64PtrOnlyString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "AnonymousHeadFloat64PtrOnlyString", data: struct { structFloat64PtrString }{ @@ -2788,13 +1688,7 @@ null // AnonymousHeadFloat64PtrNilOnly { - name: "AnonymousHeadFloat64PtrNilOnly", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "AnonymousHeadFloat64PtrNilOnly", data: struct { structFloat64Ptr }{ @@ -2802,11 +1696,7 @@ null }, }, { - name: "AnonymousHeadFloat64PtrNilOnlyOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "AnonymousHeadFloat64PtrNilOnlyOmitEmpty", data: struct { structFloat64PtrOmitEmpty }{ @@ -2814,13 +1704,7 @@ null }, }, { - name: "AnonymousHeadFloat64PtrNilOnlyString", - expected: `{"a":null}`, - indentExpected: ` -{ - "a": null -} -`, + name: "AnonymousHeadFloat64PtrNilOnlyString", data: struct { structFloat64PtrString }{ @@ -2830,13 +1714,7 @@ null // PtrAnonymousHeadFloat64PtrOnly { - name: "PtrAnonymousHeadFloat64PtrOnly", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrAnonymousHeadFloat64PtrOnly", data: struct { *structFloat64Ptr }{ @@ -2844,13 +1722,7 @@ null }, }, { - name: "PtrAnonymousHeadFloat64PtrOnlyOmitEmpty", - expected: `{"a":1}`, - indentExpected: ` -{ - "a": 1 -} -`, + name: "PtrAnonymousHeadFloat64PtrOnlyOmitEmpty", data: struct { *structFloat64PtrOmitEmpty }{ @@ -2858,13 +1730,7 @@ null }, }, { - name: "PtrAnonymousHeadFloat64PtrOnlyString", - expected: `{"a":"1"}`, - indentExpected: ` -{ - "a": "1" -} -`, + name: "PtrAnonymousHeadFloat64PtrOnlyString", data: struct { *structFloat64PtrString }{ @@ -2874,11 +1740,7 @@ null // NilPtrAnonymousHeadFloat64PtrOnly { - name: "NilPtrAnonymousHeadFloat64PtrOnly", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadFloat64PtrOnly", data: struct { *structFloat64Ptr }{ @@ -2886,11 +1748,7 @@ null }, }, { - name: "NilPtrAnonymousHeadFloat64PtrOnlyOmitEmpty", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadFloat64PtrOnlyOmitEmpty", data: struct { *structFloat64PtrOmitEmpty }{ @@ -2898,11 +1756,7 @@ null }, }, { - name: "NilPtrAnonymousHeadFloat64PtrOnlyString", - expected: `{}`, - indentExpected: ` -{} -`, + name: "NilPtrAnonymousHeadFloat64PtrOnlyString", data: struct { *structFloat64PtrString }{ @@ -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()) - } - } } } } From 72765ed5238021dd99cbbd363e72e7bea6c9b45c Mon Sep 17 00:00:00 2001 From: Masaaki Goshima Date: Mon, 15 Feb 2021 11:31:49 +0900 Subject: [PATCH 13/15] Add StructField operation for ptr type --- encode_vm.go | 323 +++++++++++++++++++++ encode_vm_escaped.go | 323 +++++++++++++++++++++ encode_vm_escaped_indent.go | 554 ++++++++++++++++++++++++++++++++++++ encode_vm_indent.go | 554 ++++++++++++++++++++++++++++++++++++ 4 files changed, 1754 insertions(+) diff --git a/encode_vm.go b/encode_vm.go index eb199ad..d66a872 100644 --- a/encode_vm.go +++ b/encode_vm.go @@ -7328,6 +7328,28 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco } b = encodeComma(b) code = code.next + case opStructFieldOmitEmptyIntPtr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = append(b, code.key...) + b = appendInt(b, int64(ptrToInt(p))) + b = encodeComma(b) + } + code = code.next + case opStructFieldStringTagIntPtr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + b = append(b, code.key...) + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = appendInt(b, int64(ptrToInt(p))) + b = append(b, '"') + } + b = encodeComma(b) + code = code.next case opStructFieldIntNPtr: b = append(b, code.key...) ptr := load(ctxptr, code.headIdx) @@ -7379,6 +7401,28 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco } b = encodeComma(b) code = code.next + case opStructFieldOmitEmptyInt8Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = append(b, code.key...) + b = appendInt(b, int64(ptrToInt8(p))) + b = encodeComma(b) + } + code = code.next + case opStructFieldStringTagInt8Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + b = append(b, code.key...) + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = appendInt(b, int64(ptrToInt8(p))) + b = append(b, '"') + } + b = encodeComma(b) + code = code.next case opStructFieldInt16: ptr := load(ctxptr, code.headIdx) b = append(b, code.key...) @@ -7413,6 +7457,28 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco } b = encodeComma(b) code = code.next + case opStructFieldOmitEmptyInt16Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = append(b, code.key...) + b = appendInt(b, int64(ptrToInt16(p))) + b = encodeComma(b) + } + code = code.next + case opStructFieldStringTagInt16Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + b = append(b, code.key...) + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = appendInt(b, int64(ptrToInt16(p))) + b = append(b, '"') + } + b = encodeComma(b) + code = code.next case opStructFieldInt32: ptr := load(ctxptr, code.headIdx) b = append(b, code.key...) @@ -7447,6 +7513,28 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco } b = encodeComma(b) code = code.next + case opStructFieldOmitEmptyInt32Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = append(b, code.key...) + b = appendInt(b, int64(ptrToInt32(p))) + b = encodeComma(b) + } + code = code.next + case opStructFieldStringTagInt32Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + b = append(b, code.key...) + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = appendInt(b, int64(ptrToInt32(p))) + b = append(b, '"') + } + b = encodeComma(b) + code = code.next case opStructFieldInt64: ptr := load(ctxptr, code.headIdx) b = append(b, code.key...) @@ -7481,6 +7569,28 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco } b = encodeComma(b) code = code.next + case opStructFieldOmitEmptyInt64Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = append(b, code.key...) + b = appendInt(b, ptrToInt64(p)) + b = encodeComma(b) + } + code = code.next + case opStructFieldStringTagInt64Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + b = append(b, code.key...) + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = appendInt(b, ptrToInt64(p)) + b = append(b, '"') + } + b = encodeComma(b) + code = code.next case opStructFieldUint: ptr := load(ctxptr, code.headIdx) b = append(b, code.key...) @@ -7515,6 +7625,28 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco } b = encodeComma(b) code = code.next + case opStructFieldOmitEmptyUintPtr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = append(b, code.key...) + b = appendUint(b, uint64(ptrToUint(p))) + b = encodeComma(b) + } + code = code.next + case opStructFieldStringTagUintPtr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + b = append(b, code.key...) + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = appendUint(b, uint64(ptrToUint(p))) + b = append(b, '"') + } + b = encodeComma(b) + code = code.next case opStructFieldUint8: ptr := load(ctxptr, code.headIdx) b = append(b, code.key...) @@ -7549,6 +7681,28 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco } b = encodeComma(b) code = code.next + case opStructFieldOmitEmptyUint8Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = append(b, code.key...) + b = appendUint(b, uint64(ptrToUint8(p))) + b = encodeComma(b) + } + code = code.next + case opStructFieldStringTagUint8Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + b = append(b, code.key...) + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = appendUint(b, uint64(ptrToUint8(p))) + b = append(b, '"') + } + b = encodeComma(b) + code = code.next case opStructFieldUint16: ptr := load(ctxptr, code.headIdx) b = append(b, code.key...) @@ -7583,6 +7737,28 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco } b = encodeComma(b) code = code.next + case opStructFieldOmitEmptyUint16Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = append(b, code.key...) + b = appendUint(b, uint64(ptrToUint16(p))) + b = encodeComma(b) + } + code = code.next + case opStructFieldStringTagUint16Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + b = append(b, code.key...) + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = appendUint(b, uint64(ptrToUint16(p))) + b = append(b, '"') + } + b = encodeComma(b) + code = code.next case opStructFieldUint32: ptr := load(ctxptr, code.headIdx) b = append(b, code.key...) @@ -7617,6 +7793,28 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco } b = encodeComma(b) code = code.next + case opStructFieldOmitEmptyUint32Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = append(b, code.key...) + b = appendUint(b, uint64(ptrToUint32(p))) + b = encodeComma(b) + } + code = code.next + case opStructFieldStringTagUint32Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + b = append(b, code.key...) + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = appendUint(b, uint64(ptrToUint32(p))) + b = append(b, '"') + } + b = encodeComma(b) + code = code.next case opStructFieldUint64: ptr := load(ctxptr, code.headIdx) b = append(b, code.key...) @@ -7651,6 +7849,28 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco } b = encodeComma(b) code = code.next + case opStructFieldOmitEmptyUint64Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = append(b, code.key...) + b = appendUint(b, ptrToUint64(p)) + b = encodeComma(b) + } + code = code.next + case opStructFieldStringTagUint64Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + b = append(b, code.key...) + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = appendUint(b, ptrToUint64(p)) + b = append(b, '"') + } + b = encodeComma(b) + code = code.next case opStructFieldFloat32: ptr := load(ctxptr, code.headIdx) b = append(b, code.key...) @@ -7685,6 +7905,28 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco } b = encodeComma(b) code = code.next + case opStructFieldOmitEmptyFloat32Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = append(b, code.key...) + b = encodeFloat32(b, ptrToFloat32(p)) + b = encodeComma(b) + } + code = code.next + case opStructFieldStringTagFloat32Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + b = append(b, code.key...) + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = encodeFloat32(b, ptrToFloat32(p)) + b = append(b, '"') + } + b = encodeComma(b) + code = code.next case opStructFieldFloat64: ptr := load(ctxptr, code.headIdx) b = append(b, code.key...) @@ -7736,6 +7978,36 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco b = encodeFloat64(b, v) b = encodeComma(b) code = code.next + case opStructFieldOmitEmptyFloat64Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = append(b, code.key...) + v := ptrToFloat64(p) + if math.IsInf(v, 0) || math.IsNaN(v) { + return nil, errUnsupportedFloat(v) + } + b = encodeFloat64(b, v) + b = encodeComma(b) + } + code = code.next + case opStructFieldStringTagFloat64Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + b = append(b, code.key...) + if p == 0 { + b = encodeNull(b) + } else { + v := ptrToFloat64(p) + if math.IsInf(v, 0) || math.IsNaN(v) { + return nil, errUnsupportedFloat(v) + } + b = append(b, '"') + b = encodeFloat64(b, v) + b = append(b, '"') + } + b = encodeComma(b) + code = code.next case opStructFieldString: ptr := load(ctxptr, code.headIdx) b = append(b, code.key...) @@ -7823,6 +8095,26 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco } b = encodeComma(b) code = code.next + case opStructFieldOmitEmptyBoolPtr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = append(b, code.key...) + b = encodeBool(b, ptrToBool(p)) + b = encodeComma(b) + } + code = code.next + case opStructFieldStringTagBoolPtr: + b = append(b, code.key...) + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + b = encodeBool(b, ptrToBool(p)) + } + b = encodeComma(b) + code = code.next case opStructFieldBytes: ptr := load(ctxptr, code.headIdx) b = append(b, code.key...) @@ -7845,6 +8137,37 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco b = encodeByteSlice(b, v) b = encodeComma(b) code = code.next + case opStructFieldBytesPtr: + b = append(b, code.key...) + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + b = encodeByteSlice(b, ptrToBytes(p)) + } + b = encodeComma(b) + code = code.next + case opStructFieldOmitEmptyBytesPtr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = append(b, code.key...) + b = encodeByteSlice(b, ptrToBytes(p)) + b = encodeComma(b) + } + code = code.next + case opStructFieldStringTagBytesPtr: + b = append(b, code.key...) + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + b = encodeByteSlice(b, ptrToBytes(p)) + } + b = encodeComma(b) + code = code.next case opStructFieldMarshalJSON: ptr := load(ctxptr, code.headIdx) b = append(b, code.key...) diff --git a/encode_vm_escaped.go b/encode_vm_escaped.go index 34c9096..bbac701 100644 --- a/encode_vm_escaped.go +++ b/encode_vm_escaped.go @@ -7280,6 +7280,28 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o } b = encodeComma(b) code = code.next + case opStructFieldOmitEmptyIntPtr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = append(b, code.escapedKey...) + b = appendInt(b, int64(ptrToInt(p))) + b = encodeComma(b) + } + code = code.next + case opStructFieldStringTagIntPtr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + b = append(b, code.escapedKey...) + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = appendInt(b, int64(ptrToInt(p))) + b = append(b, '"') + } + b = encodeComma(b) + code = code.next case opStructFieldIntNPtr: b = append(b, code.escapedKey...) ptr := load(ctxptr, code.headIdx) @@ -7331,6 +7353,28 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o } b = encodeComma(b) code = code.next + case opStructFieldOmitEmptyInt8Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = append(b, code.escapedKey...) + b = appendInt(b, int64(ptrToInt8(p))) + b = encodeComma(b) + } + code = code.next + case opStructFieldStringTagInt8Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + b = append(b, code.escapedKey...) + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = appendInt(b, int64(ptrToInt8(p))) + b = append(b, '"') + } + b = encodeComma(b) + code = code.next case opStructFieldInt16: ptr := load(ctxptr, code.headIdx) b = append(b, code.escapedKey...) @@ -7365,6 +7409,28 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o } b = encodeComma(b) code = code.next + case opStructFieldOmitEmptyInt16Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = append(b, code.escapedKey...) + b = appendInt(b, int64(ptrToInt16(p))) + b = encodeComma(b) + } + code = code.next + case opStructFieldStringTagInt16Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + b = append(b, code.escapedKey...) + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = appendInt(b, int64(ptrToInt16(p))) + b = append(b, '"') + } + b = encodeComma(b) + code = code.next case opStructFieldInt32: ptr := load(ctxptr, code.headIdx) b = append(b, code.escapedKey...) @@ -7399,6 +7465,28 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o } b = encodeComma(b) code = code.next + case opStructFieldOmitEmptyInt32Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = append(b, code.escapedKey...) + b = appendInt(b, int64(ptrToInt32(p))) + b = encodeComma(b) + } + code = code.next + case opStructFieldStringTagInt32Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + b = append(b, code.escapedKey...) + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = appendInt(b, int64(ptrToInt32(p))) + b = append(b, '"') + } + b = encodeComma(b) + code = code.next case opStructFieldInt64: ptr := load(ctxptr, code.headIdx) b = append(b, code.escapedKey...) @@ -7433,6 +7521,28 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o } b = encodeComma(b) code = code.next + case opStructFieldOmitEmptyInt64Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = append(b, code.escapedKey...) + b = appendInt(b, ptrToInt64(p)) + b = encodeComma(b) + } + code = code.next + case opStructFieldStringTagInt64Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + b = append(b, code.escapedKey...) + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = appendInt(b, ptrToInt64(p)) + b = append(b, '"') + } + b = encodeComma(b) + code = code.next case opStructFieldUint: ptr := load(ctxptr, code.headIdx) b = append(b, code.escapedKey...) @@ -7467,6 +7577,28 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o } b = encodeComma(b) code = code.next + case opStructFieldOmitEmptyUintPtr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = append(b, code.escapedKey...) + b = appendUint(b, uint64(ptrToUint(p))) + b = encodeComma(b) + } + code = code.next + case opStructFieldStringTagUintPtr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + b = append(b, code.escapedKey...) + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = appendUint(b, uint64(ptrToUint(p))) + b = append(b, '"') + } + b = encodeComma(b) + code = code.next case opStructFieldUint8: ptr := load(ctxptr, code.headIdx) b = append(b, code.escapedKey...) @@ -7501,6 +7633,28 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o } b = encodeComma(b) code = code.next + case opStructFieldOmitEmptyUint8Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = append(b, code.escapedKey...) + b = appendUint(b, uint64(ptrToUint8(p))) + b = encodeComma(b) + } + code = code.next + case opStructFieldStringTagUint8Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + b = append(b, code.escapedKey...) + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = appendUint(b, uint64(ptrToUint8(p))) + b = append(b, '"') + } + b = encodeComma(b) + code = code.next case opStructFieldUint16: ptr := load(ctxptr, code.headIdx) b = append(b, code.escapedKey...) @@ -7535,6 +7689,28 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o } b = encodeComma(b) code = code.next + case opStructFieldOmitEmptyUint16Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = append(b, code.escapedKey...) + b = appendUint(b, uint64(ptrToUint16(p))) + b = encodeComma(b) + } + code = code.next + case opStructFieldStringTagUint16Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + b = append(b, code.escapedKey...) + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = appendUint(b, uint64(ptrToUint16(p))) + b = append(b, '"') + } + b = encodeComma(b) + code = code.next case opStructFieldUint32: ptr := load(ctxptr, code.headIdx) b = append(b, code.escapedKey...) @@ -7569,6 +7745,28 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o } b = encodeComma(b) code = code.next + case opStructFieldOmitEmptyUint32Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = append(b, code.escapedKey...) + b = appendUint(b, uint64(ptrToUint32(p))) + b = encodeComma(b) + } + code = code.next + case opStructFieldStringTagUint32Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + b = append(b, code.escapedKey...) + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = appendUint(b, uint64(ptrToUint32(p))) + b = append(b, '"') + } + b = encodeComma(b) + code = code.next case opStructFieldUint64: ptr := load(ctxptr, code.headIdx) b = append(b, code.escapedKey...) @@ -7603,6 +7801,28 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o } b = encodeComma(b) code = code.next + case opStructFieldOmitEmptyUint64Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = append(b, code.escapedKey...) + b = appendUint(b, ptrToUint64(p)) + b = encodeComma(b) + } + code = code.next + case opStructFieldStringTagUint64Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + b = append(b, code.escapedKey...) + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = appendUint(b, ptrToUint64(p)) + b = append(b, '"') + } + b = encodeComma(b) + code = code.next case opStructFieldFloat32: ptr := load(ctxptr, code.headIdx) b = append(b, code.escapedKey...) @@ -7637,6 +7857,28 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o } b = encodeComma(b) code = code.next + case opStructFieldOmitEmptyFloat32Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = append(b, code.escapedKey...) + b = encodeFloat32(b, ptrToFloat32(p)) + b = encodeComma(b) + } + code = code.next + case opStructFieldStringTagFloat32Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + b = append(b, code.escapedKey...) + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = encodeFloat32(b, ptrToFloat32(p)) + b = append(b, '"') + } + b = encodeComma(b) + code = code.next case opStructFieldFloat64: ptr := load(ctxptr, code.headIdx) b = append(b, code.escapedKey...) @@ -7688,6 +7930,36 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o b = encodeFloat64(b, v) b = encodeComma(b) code = code.next + case opStructFieldOmitEmptyFloat64Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = append(b, code.escapedKey...) + v := ptrToFloat64(p) + if math.IsInf(v, 0) || math.IsNaN(v) { + return nil, errUnsupportedFloat(v) + } + b = encodeFloat64(b, v) + b = encodeComma(b) + } + code = code.next + case opStructFieldStringTagFloat64Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + b = append(b, code.escapedKey...) + if p == 0 { + b = encodeNull(b) + } else { + v := ptrToFloat64(p) + if math.IsInf(v, 0) || math.IsNaN(v) { + return nil, errUnsupportedFloat(v) + } + b = append(b, '"') + b = encodeFloat64(b, v) + b = append(b, '"') + } + b = encodeComma(b) + code = code.next case opStructFieldString: ptr := load(ctxptr, code.headIdx) b = append(b, code.escapedKey...) @@ -7775,6 +8047,26 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o } b = encodeComma(b) code = code.next + case opStructFieldOmitEmptyBoolPtr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = append(b, code.escapedKey...) + b = encodeBool(b, ptrToBool(p)) + b = encodeComma(b) + } + code = code.next + case opStructFieldStringTagBoolPtr: + b = append(b, code.escapedKey...) + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + b = encodeBool(b, ptrToBool(p)) + } + b = encodeComma(b) + code = code.next case opStructFieldBytes: ptr := load(ctxptr, code.headIdx) b = append(b, code.escapedKey...) @@ -7797,6 +8089,37 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o b = encodeByteSlice(b, v) b = encodeComma(b) code = code.next + case opStructFieldBytesPtr: + b = append(b, code.escapedKey...) + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + b = encodeByteSlice(b, ptrToBytes(p)) + } + b = encodeComma(b) + code = code.next + case opStructFieldOmitEmptyBytesPtr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = append(b, code.escapedKey...) + b = encodeByteSlice(b, ptrToBytes(p)) + b = encodeComma(b) + } + code = code.next + case opStructFieldStringTagBytesPtr: + b = append(b, code.escapedKey...) + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + b = encodeByteSlice(b, ptrToBytes(p)) + } + b = encodeComma(b) + code = code.next case opStructFieldMarshalJSON: ptr := load(ctxptr, code.headIdx) b = append(b, code.escapedKey...) diff --git a/encode_vm_escaped_indent.go b/encode_vm_escaped_indent.go index c8804a1..8674b46 100644 --- a/encode_vm_escaped_indent.go +++ b/encode_vm_escaped_indent.go @@ -7174,6 +7174,45 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = append(b, '"') b = encodeIndentComma(b) code = code.next + case opStructFieldIntPtr: + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + b = appendInt(b, int64(ptrToInt(p))) + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldOmitEmptyIntPtr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + b = appendInt(b, int64(ptrToInt(p))) + b = encodeIndentComma(b) + } + code = code.next + case opStructFieldStringTagIntPtr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = appendInt(b, int64(ptrToInt(p))) + b = append(b, '"') + } + b = encodeIndentComma(b) + code = code.next case opStructFieldInt8: b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) @@ -7202,6 +7241,45 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = append(b, '"') b = encodeIndentComma(b) code = code.next + case opStructFieldInt8Ptr: + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + b = appendInt(b, int64(ptrToInt8(p))) + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldOmitEmptyInt8Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + b = appendInt(b, int64(ptrToInt8(p))) + b = encodeIndentComma(b) + } + code = code.next + case opStructFieldStringTagInt8Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = appendInt(b, int64(ptrToInt8(p))) + b = append(b, '"') + } + b = encodeIndentComma(b) + code = code.next case opStructFieldInt16: b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) @@ -7230,6 +7308,45 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = append(b, '"') b = encodeIndentComma(b) code = code.next + case opStructFieldInt16Ptr: + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + b = appendInt(b, int64(ptrToInt16(p))) + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldOmitEmptyInt16Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + b = appendInt(b, int64(ptrToInt16(p))) + b = encodeIndentComma(b) + } + code = code.next + case opStructFieldStringTagInt16Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = appendInt(b, int64(ptrToInt16(p))) + b = append(b, '"') + } + b = encodeIndentComma(b) + code = code.next case opStructFieldInt32: b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) @@ -7258,6 +7375,45 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = append(b, '"') b = encodeIndentComma(b) code = code.next + case opStructFieldInt32Ptr: + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + b = appendInt(b, int64(ptrToInt32(p))) + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldOmitEmptyInt32Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + b = appendInt(b, int64(ptrToInt32(p))) + b = encodeIndentComma(b) + } + code = code.next + case opStructFieldStringTagInt32Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = appendInt(b, int64(ptrToInt32(p))) + b = append(b, '"') + } + b = encodeIndentComma(b) + code = code.next case opStructFieldInt64: b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) @@ -7286,6 +7442,45 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = append(b, '"') b = encodeIndentComma(b) code = code.next + case opStructFieldInt64Ptr: + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + b = appendInt(b, ptrToInt64(p)) + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldOmitEmptyInt64Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + b = appendInt(b, ptrToInt64(p)) + b = encodeIndentComma(b) + } + code = code.next + case opStructFieldStringTagInt64Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = appendInt(b, ptrToInt64(p)) + b = append(b, '"') + } + b = encodeIndentComma(b) + code = code.next case opStructFieldUint: b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) @@ -7314,6 +7509,45 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = append(b, '"') b = encodeIndentComma(b) code = code.next + case opStructFieldUintPtr: + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + b = appendUint(b, uint64(ptrToUint(p))) + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldOmitEmptyUintPtr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + b = appendUint(b, uint64(ptrToUint(p))) + b = encodeIndentComma(b) + } + code = code.next + case opStructFieldStringTagUintPtr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = appendUint(b, uint64(ptrToUint(p))) + b = append(b, '"') + } + b = encodeIndentComma(b) + code = code.next case opStructFieldUint8: b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) @@ -7342,6 +7576,45 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = append(b, '"') b = encodeIndentComma(b) code = code.next + case opStructFieldUint8Ptr: + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + b = appendUint(b, uint64(ptrToUint8(p))) + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldOmitEmptyUint8Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + b = appendUint(b, uint64(ptrToUint8(p))) + b = encodeIndentComma(b) + } + code = code.next + case opStructFieldStringTagUint8Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = appendUint(b, uint64(ptrToUint8(p))) + b = append(b, '"') + } + b = encodeIndentComma(b) + code = code.next case opStructFieldUint16: b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) @@ -7370,6 +7643,45 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = append(b, '"') b = encodeIndentComma(b) code = code.next + case opStructFieldUint16Ptr: + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + b = appendUint(b, uint64(ptrToUint16(p))) + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldOmitEmptyUint16Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + b = appendUint(b, uint64(ptrToUint16(p))) + b = encodeIndentComma(b) + } + code = code.next + case opStructFieldStringTagUint16Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = appendUint(b, uint64(ptrToUint16(p))) + b = append(b, '"') + } + b = encodeIndentComma(b) + code = code.next case opStructFieldUint32: b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) @@ -7398,6 +7710,45 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = append(b, '"') b = encodeIndentComma(b) code = code.next + case opStructFieldUint32Ptr: + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + b = appendUint(b, uint64(ptrToUint32(p))) + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldOmitEmptyUint32Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + b = appendUint(b, uint64(ptrToUint32(p))) + b = encodeIndentComma(b) + } + code = code.next + case opStructFieldStringTagUint32Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = appendUint(b, uint64(ptrToUint32(p))) + b = append(b, '"') + } + b = encodeIndentComma(b) + code = code.next case opStructFieldUint64: b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) @@ -7426,6 +7777,45 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = append(b, '"') b = encodeIndentComma(b) code = code.next + case opStructFieldUint64Ptr: + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + b = appendUint(b, ptrToUint64(p)) + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldOmitEmptyUint64Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + b = appendUint(b, ptrToUint64(p)) + b = encodeIndentComma(b) + } + code = code.next + case opStructFieldStringTagUint64Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = appendUint(b, ptrToUint64(p)) + b = append(b, '"') + } + b = encodeIndentComma(b) + code = code.next case opStructFieldFloat32: b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) @@ -7454,6 +7844,45 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = append(b, '"') b = encodeIndentComma(b) code = code.next + case opStructFieldFloat32Ptr: + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + b = encodeFloat32(b, ptrToFloat32(p)) + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldOmitEmptyFloat32Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + b = encodeFloat32(b, ptrToFloat32(p)) + b = encodeIndentComma(b) + } + code = code.next + case opStructFieldStringTagFloat32Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = encodeFloat32(b, ptrToFloat32(p)) + b = append(b, '"') + } + b = encodeIndentComma(b) + code = code.next case opStructFieldFloat64: b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) @@ -7493,6 +7922,57 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = append(b, '"') b = encodeIndentComma(b) code = code.next + case opStructFieldFloat64Ptr: + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + v := ptrToFloat64(p) + if math.IsInf(v, 0) || math.IsNaN(v) { + return nil, errUnsupportedFloat(v) + } + b = encodeFloat64(b, v) + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldOmitEmptyFloat64Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + v := ptrToFloat64(p) + if math.IsInf(v, 0) || math.IsNaN(v) { + return nil, errUnsupportedFloat(v) + } + b = encodeFloat64(b, v) + b = encodeIndentComma(b) + } + code = code.next + case opStructFieldStringTagFloat64Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + v := ptrToFloat64(p) + if math.IsInf(v, 0) || math.IsNaN(v) { + return nil, errUnsupportedFloat(v) + } + b = encodeFloat64(b, v) + b = append(b, '"') + } + b = encodeIndentComma(b) + code = code.next case opStructFieldString: b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) @@ -7586,6 +8066,43 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = append(b, '"') b = encodeIndentComma(b) code = code.next + case opStructFieldBoolPtr: + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + b = encodeBool(b, ptrToBool(p)) + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldOmitEmptyBoolPtr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + b = encodeBool(b, ptrToBool(p)) + b = encodeIndentComma(b) + } + code = code.next + case opStructFieldStringTagBoolPtr: + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + b = encodeBool(b, ptrToBool(p)) + } + b = encodeIndentComma(b) + code = code.next case opStructFieldBytes: b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) @@ -7613,6 +8130,43 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = encodeByteSlice(b, ptrToBytes(ptr+code.offset)) b = encodeIndentComma(b) code = code.next + case opStructFieldBytesPtr: + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + b = encodeByteSlice(b, ptrToBytes(p)) + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldOmitEmptyBytesPtr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + b = encodeByteSlice(b, ptrToBytes(p)) + b = encodeIndentComma(b) + } + code = code.next + case opStructFieldStringTagBytesPtr: + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + b = encodeByteSlice(b, ptrToBytes(p)) + } + b = encodeIndentComma(b) + code = code.next case opStructFieldMarshalJSON: b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) diff --git a/encode_vm_indent.go b/encode_vm_indent.go index 587e328..231060e 100644 --- a/encode_vm_indent.go +++ b/encode_vm_indent.go @@ -7174,6 +7174,45 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = append(b, '"') b = encodeIndentComma(b) code = code.next + case opStructFieldIntPtr: + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + b = appendInt(b, int64(ptrToInt(p))) + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldOmitEmptyIntPtr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + b = appendInt(b, int64(ptrToInt(p))) + b = encodeIndentComma(b) + } + code = code.next + case opStructFieldStringTagIntPtr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = appendInt(b, int64(ptrToInt(p))) + b = append(b, '"') + } + b = encodeIndentComma(b) + code = code.next case opStructFieldInt8: b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) @@ -7202,6 +7241,45 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = append(b, '"') b = encodeIndentComma(b) code = code.next + case opStructFieldInt8Ptr: + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + b = appendInt(b, int64(ptrToInt8(p))) + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldOmitEmptyInt8Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + b = appendInt(b, int64(ptrToInt8(p))) + b = encodeIndentComma(b) + } + code = code.next + case opStructFieldStringTagInt8Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = appendInt(b, int64(ptrToInt8(p))) + b = append(b, '"') + } + b = encodeIndentComma(b) + code = code.next case opStructFieldInt16: b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) @@ -7230,6 +7308,45 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = append(b, '"') b = encodeIndentComma(b) code = code.next + case opStructFieldInt16Ptr: + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + b = appendInt(b, int64(ptrToInt16(p))) + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldOmitEmptyInt16Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + b = appendInt(b, int64(ptrToInt16(p))) + b = encodeIndentComma(b) + } + code = code.next + case opStructFieldStringTagInt16Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = appendInt(b, int64(ptrToInt16(p))) + b = append(b, '"') + } + b = encodeIndentComma(b) + code = code.next case opStructFieldInt32: b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) @@ -7258,6 +7375,45 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = append(b, '"') b = encodeIndentComma(b) code = code.next + case opStructFieldInt32Ptr: + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + b = appendInt(b, int64(ptrToInt32(p))) + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldOmitEmptyInt32Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + b = appendInt(b, int64(ptrToInt32(p))) + b = encodeIndentComma(b) + } + code = code.next + case opStructFieldStringTagInt32Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = appendInt(b, int64(ptrToInt32(p))) + b = append(b, '"') + } + b = encodeIndentComma(b) + code = code.next case opStructFieldInt64: b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) @@ -7286,6 +7442,45 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = append(b, '"') b = encodeIndentComma(b) code = code.next + case opStructFieldInt64Ptr: + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + b = appendInt(b, ptrToInt64(p)) + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldOmitEmptyInt64Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + b = appendInt(b, ptrToInt64(p)) + b = encodeIndentComma(b) + } + code = code.next + case opStructFieldStringTagInt64Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = appendInt(b, ptrToInt64(p)) + b = append(b, '"') + } + b = encodeIndentComma(b) + code = code.next case opStructFieldUint: b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) @@ -7314,6 +7509,45 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = append(b, '"') b = encodeIndentComma(b) code = code.next + case opStructFieldUintPtr: + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + b = appendUint(b, uint64(ptrToUint(p))) + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldOmitEmptyUintPtr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + b = appendUint(b, uint64(ptrToUint(p))) + b = encodeIndentComma(b) + } + code = code.next + case opStructFieldStringTagUintPtr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = appendUint(b, uint64(ptrToUint(p))) + b = append(b, '"') + } + b = encodeIndentComma(b) + code = code.next case opStructFieldUint8: b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) @@ -7342,6 +7576,45 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = append(b, '"') b = encodeIndentComma(b) code = code.next + case opStructFieldUint8Ptr: + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + b = appendUint(b, uint64(ptrToUint8(p))) + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldOmitEmptyUint8Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + b = appendUint(b, uint64(ptrToUint8(p))) + b = encodeIndentComma(b) + } + code = code.next + case opStructFieldStringTagUint8Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = appendUint(b, uint64(ptrToUint8(p))) + b = append(b, '"') + } + b = encodeIndentComma(b) + code = code.next case opStructFieldUint16: b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) @@ -7370,6 +7643,45 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = append(b, '"') b = encodeIndentComma(b) code = code.next + case opStructFieldUint16Ptr: + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + b = appendUint(b, uint64(ptrToUint16(p))) + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldOmitEmptyUint16Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + b = appendUint(b, uint64(ptrToUint16(p))) + b = encodeIndentComma(b) + } + code = code.next + case opStructFieldStringTagUint16Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = appendUint(b, uint64(ptrToUint16(p))) + b = append(b, '"') + } + b = encodeIndentComma(b) + code = code.next case opStructFieldUint32: b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) @@ -7398,6 +7710,45 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = append(b, '"') b = encodeIndentComma(b) code = code.next + case opStructFieldUint32Ptr: + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + b = appendUint(b, uint64(ptrToUint32(p))) + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldOmitEmptyUint32Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + b = appendUint(b, uint64(ptrToUint32(p))) + b = encodeIndentComma(b) + } + code = code.next + case opStructFieldStringTagUint32Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = appendUint(b, uint64(ptrToUint32(p))) + b = append(b, '"') + } + b = encodeIndentComma(b) + code = code.next case opStructFieldUint64: b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) @@ -7426,6 +7777,45 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = append(b, '"') b = encodeIndentComma(b) code = code.next + case opStructFieldUint64Ptr: + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + b = appendUint(b, ptrToUint64(p)) + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldOmitEmptyUint64Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + b = appendUint(b, ptrToUint64(p)) + b = encodeIndentComma(b) + } + code = code.next + case opStructFieldStringTagUint64Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = appendUint(b, ptrToUint64(p)) + b = append(b, '"') + } + b = encodeIndentComma(b) + code = code.next case opStructFieldFloat32: b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) @@ -7454,6 +7844,45 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = append(b, '"') b = encodeIndentComma(b) code = code.next + case opStructFieldFloat32Ptr: + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + b = encodeFloat32(b, ptrToFloat32(p)) + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldOmitEmptyFloat32Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + b = encodeFloat32(b, ptrToFloat32(p)) + b = encodeIndentComma(b) + } + code = code.next + case opStructFieldStringTagFloat32Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = encodeFloat32(b, ptrToFloat32(p)) + b = append(b, '"') + } + b = encodeIndentComma(b) + code = code.next case opStructFieldFloat64: b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) @@ -7493,6 +7922,57 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = append(b, '"') b = encodeIndentComma(b) code = code.next + case opStructFieldFloat64Ptr: + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + v := ptrToFloat64(p) + if math.IsInf(v, 0) || math.IsNaN(v) { + return nil, errUnsupportedFloat(v) + } + b = encodeFloat64(b, v) + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldOmitEmptyFloat64Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + v := ptrToFloat64(p) + if math.IsInf(v, 0) || math.IsNaN(v) { + return nil, errUnsupportedFloat(v) + } + b = encodeFloat64(b, v) + b = encodeIndentComma(b) + } + code = code.next + case opStructFieldStringTagFloat64Ptr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + v := ptrToFloat64(p) + if math.IsInf(v, 0) || math.IsNaN(v) { + return nil, errUnsupportedFloat(v) + } + b = encodeFloat64(b, v) + b = append(b, '"') + } + b = encodeIndentComma(b) + code = code.next case opStructFieldString: b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) @@ -7586,6 +8066,43 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = append(b, '"') b = encodeIndentComma(b) code = code.next + case opStructFieldBoolPtr: + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + b = encodeBool(b, ptrToBool(p)) + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldOmitEmptyBoolPtr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + b = encodeBool(b, ptrToBool(p)) + b = encodeIndentComma(b) + } + code = code.next + case opStructFieldStringTagBoolPtr: + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + b = encodeBool(b, ptrToBool(p)) + } + b = encodeIndentComma(b) + code = code.next case opStructFieldBytes: b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) @@ -7613,6 +8130,43 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = encodeByteSlice(b, ptrToBytes(ptr+code.offset)) b = encodeIndentComma(b) code = code.next + case opStructFieldBytesPtr: + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + b = encodeByteSlice(b, ptrToBytes(p)) + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldOmitEmptyBytesPtr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + b = encodeByteSlice(b, ptrToBytes(p)) + b = encodeIndentComma(b) + } + code = code.next + case opStructFieldStringTagBytesPtr: + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + b = encodeByteSlice(b, ptrToBytes(p)) + } + b = encodeIndentComma(b) + code = code.next case opStructFieldMarshalJSON: b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) From 565f1e866eb3297c3f92fced9e3214b8cf1774a0 Mon Sep 17 00:00:00 2001 From: Masaaki Goshima Date: Mon, 15 Feb 2021 11:48:09 +0900 Subject: [PATCH 14/15] Add cover_bool_test.go --- cover_bool_test.go | 1786 ++++++++++++++++++++++++++++++++++++++++++ cover_helper_test.go | 1 + 2 files changed, 1787 insertions(+) create mode 100644 cover_bool_test.go diff --git a/cover_bool_test.go b/cover_bool_test.go new file mode 100644 index 0000000..4a901f8 --- /dev/null +++ b/cover_bool_test.go @@ -0,0 +1,1786 @@ +package json_test + +import ( + "bytes" + "testing" + + "github.com/goccy/go-json" +) + +func TestCoverBool(t *testing.T) { + type structBool struct { + A bool `json:"a"` + } + type structBoolOmitEmpty struct { + A bool `json:"a,omitempty"` + } + type structBoolString struct { + A bool `json:"a,string"` + } + + type structBoolPtr struct { + A *bool `json:"a"` + } + type structBoolPtrOmitEmpty struct { + A *bool `json:"a,omitempty"` + } + type structBoolPtrString struct { + A *bool `json:"a,string"` + } + + tests := []struct { + name string + data interface{} + }{ + // HeadBoolZero + { + name: "HeadBoolZero", + data: struct { + A bool `json:"a"` + }{}, + }, + { + name: "HeadBoolZeroOmitEmpty", + data: struct { + A bool `json:"a,omitempty"` + }{}, + }, + { + name: "HeadBoolZeroString", + data: struct { + A bool `json:"a,string"` + }{}, + }, + + // HeadBool + { + name: "HeadBool", + data: struct { + A bool `json:"a"` + }{A: true}, + }, + { + name: "HeadBoolOmitEmpty", + data: struct { + A bool `json:"a,omitempty"` + }{A: true}, + }, + { + name: "HeadBoolString", + data: struct { + A bool `json:"a,string"` + }{A: true}, + }, + + // HeadBoolPtr + { + name: "HeadBoolPtr", + data: struct { + A *bool `json:"a"` + }{A: boolptr(true)}, + }, + { + name: "HeadBoolPtrOmitEmpty", + data: struct { + A *bool `json:"a,omitempty"` + }{A: boolptr(true)}, + }, + { + name: "HeadBoolPtrString", + data: struct { + A *bool `json:"a,string"` + }{A: boolptr(true)}, + }, + + // HeadBoolPtrNil + { + name: "HeadBoolPtrNil", + data: struct { + A *bool `json:"a"` + }{A: nil}, + }, + { + name: "HeadBoolPtrNilOmitEmpty", + data: struct { + A *bool `json:"a,omitempty"` + }{A: nil}, + }, + { + name: "HeadBoolPtrNilString", + data: struct { + A *bool `json:"a,string"` + }{A: nil}, + }, + + // PtrHeadBoolZero + { + name: "PtrHeadBoolZero", + data: &struct { + A bool `json:"a"` + }{}, + }, + { + name: "PtrHeadBoolZeroOmitEmpty", + data: &struct { + A bool `json:"a,omitempty"` + }{}, + }, + { + name: "PtrHeadBoolZeroString", + data: &struct { + A bool `json:"a,string"` + }{}, + }, + + // PtrHeadBool + { + name: "PtrHeadBool", + data: &struct { + A bool `json:"a"` + }{A: true}, + }, + { + name: "PtrHeadBoolOmitEmpty", + data: &struct { + A bool `json:"a,omitempty"` + }{A: true}, + }, + { + name: "PtrHeadBoolString", + data: &struct { + A bool `json:"a,string"` + }{A: true}, + }, + + // PtrHeadBoolPtr + { + name: "PtrHeadBoolPtr", + data: &struct { + A *bool `json:"a"` + }{A: boolptr(true)}, + }, + { + name: "PtrHeadBoolPtrOmitEmpty", + data: &struct { + A *bool `json:"a,omitempty"` + }{A: boolptr(true)}, + }, + { + name: "PtrHeadBoolPtrString", + data: &struct { + A *bool `json:"a,string"` + }{A: boolptr(true)}, + }, + + // PtrHeadBoolPtrNil + { + name: "PtrHeadBoolPtrNil", + data: &struct { + A *bool `json:"a"` + }{A: nil}, + }, + { + name: "PtrHeadBoolPtrNilOmitEmpty", + data: &struct { + A *bool `json:"a,omitempty"` + }{A: nil}, + }, + { + name: "PtrHeadBoolPtrNilString", + data: &struct { + A *bool `json:"a,string"` + }{A: nil}, + }, + + // PtrHeadBoolNil + { + name: "PtrHeadBoolNil", + data: (*struct { + A *bool `json:"a"` + })(nil), + }, + { + name: "PtrHeadBoolNilOmitEmpty", + data: (*struct { + A *bool `json:"a,omitempty"` + })(nil), + }, + { + name: "PtrHeadBoolNilString", + data: (*struct { + A *bool `json:"a,string"` + })(nil), + }, + + // HeadBoolZeroMultiFields + { + name: "HeadBoolZeroMultiFields", + data: struct { + A bool `json:"a"` + B bool `json:"b"` + C bool `json:"c"` + }{}, + }, + { + name: "HeadBoolZeroMultiFieldsOmitEmpty", + data: struct { + A bool `json:"a,omitempty"` + B bool `json:"b,omitempty"` + C bool `json:"c,omitempty"` + }{}, + }, + { + name: "HeadBoolZeroMultiFields", + data: struct { + A bool `json:"a,string"` + B bool `json:"b,string"` + C bool `json:"c,string"` + }{}, + }, + + // HeadBoolMultiFields + { + name: "HeadBoolMultiFields", + data: struct { + A bool `json:"a"` + B bool `json:"b"` + C bool `json:"c"` + }{A: true, B: false, C: true}, + }, + { + name: "HeadBoolMultiFieldsOmitEmpty", + data: struct { + A bool `json:"a,omitempty"` + B bool `json:"b,omitempty"` + C bool `json:"c,omitempty"` + }{A: true, B: false, C: true}, + }, + { + name: "HeadBoolMultiFieldsString", + data: struct { + A bool `json:"a,string"` + B bool `json:"b,string"` + C bool `json:"c,string"` + }{A: true, B: false, C: true}, + }, + + // HeadBoolPtrMultiFields + { + name: "HeadBoolPtrMultiFields", + data: struct { + A *bool `json:"a"` + B *bool `json:"b"` + C *bool `json:"c"` + }{A: boolptr(true), B: boolptr(false), C: boolptr(true)}, + }, + { + name: "HeadBoolPtrMultiFieldsOmitEmpty", + data: struct { + A *bool `json:"a,omitempty"` + B *bool `json:"b,omitempty"` + C *bool `json:"c,omitempty"` + }{A: boolptr(true), B: boolptr(false), C: boolptr(true)}, + }, + { + name: "HeadBoolPtrMultiFieldsString", + data: struct { + A *bool `json:"a,string"` + B *bool `json:"b,string"` + C *bool `json:"c,string"` + }{A: boolptr(true), B: boolptr(false), C: boolptr(true)}, + }, + + // HeadBoolPtrNilMultiFields + { + name: "HeadBoolPtrNilMultiFields", + data: struct { + A *bool `json:"a"` + B *bool `json:"b"` + C *bool `json:"c"` + }{A: nil, B: nil, C: nil}, + }, + { + name: "HeadBoolPtrNilMultiFieldsOmitEmpty", + data: struct { + A *bool `json:"a,omitempty"` + B *bool `json:"b,omitempty"` + C *bool `json:"c,omitempty"` + }{A: nil, B: nil, C: nil}, + }, + { + name: "HeadBoolPtrNilMultiFieldsString", + data: struct { + A *bool `json:"a,string"` + B *bool `json:"b,string"` + C *bool `json:"c,string"` + }{A: nil, B: nil, C: nil}, + }, + + // PtrHeadBoolZeroMultiFields + { + name: "PtrHeadBoolZeroMultiFields", + data: &struct { + A bool `json:"a"` + B bool `json:"b"` + }{}, + }, + { + name: "PtrHeadBoolZeroMultiFieldsOmitEmpty", + data: &struct { + A bool `json:"a,omitempty"` + B bool `json:"b,omitempty"` + }{}, + }, + { + name: "PtrHeadBoolZeroMultiFieldsString", + data: &struct { + A bool `json:"a,string"` + B bool `json:"b,string"` + }{}, + }, + + // PtrHeadBoolMultiFields + { + name: "PtrHeadBoolMultiFields", + data: &struct { + A bool `json:"a"` + B bool `json:"b"` + }{A: true, B: false}, + }, + { + name: "PtrHeadBoolMultiFieldsOmitEmpty", + data: &struct { + A bool `json:"a,omitempty"` + B bool `json:"b,omitempty"` + }{A: true, B: false}, + }, + { + name: "PtrHeadBoolMultiFieldsString", + data: &struct { + A bool `json:"a,string"` + B bool `json:"b,string"` + }{A: true, B: false}, + }, + + // PtrHeadBoolPtrMultiFields + { + name: "PtrHeadBoolPtrMultiFields", + data: &struct { + A *bool `json:"a"` + B *bool `json:"b"` + }{A: boolptr(true), B: boolptr(false)}, + }, + { + name: "PtrHeadBoolPtrMultiFieldsOmitEmpty", + data: &struct { + A *bool `json:"a,omitempty"` + B *bool `json:"b,omitempty"` + }{A: boolptr(true), B: boolptr(false)}, + }, + { + name: "PtrHeadBoolPtrMultiFieldsString", + data: &struct { + A *bool `json:"a,string"` + B *bool `json:"b,string"` + }{A: boolptr(true), B: boolptr(false)}, + }, + + // PtrHeadBoolPtrNilMultiFields + { + name: "PtrHeadBoolPtrNilMultiFields", + data: &struct { + A *bool `json:"a"` + B *bool `json:"b"` + }{A: nil, B: nil}, + }, + { + name: "PtrHeadBoolPtrNilMultiFieldsOmitEmpty", + data: &struct { + A *bool `json:"a,omitempty"` + B *bool `json:"b,omitempty"` + }{A: nil, B: nil}, + }, + { + name: "PtrHeadBoolPtrNilMultiFieldsString", + data: &struct { + A *bool `json:"a,string"` + B *bool `json:"b,string"` + }{A: nil, B: nil}, + }, + + // PtrHeadBoolNilMultiFields + { + name: "PtrHeadBoolNilMultiFields", + data: (*struct { + A *bool `json:"a"` + B *bool `json:"b"` + })(nil), + }, + { + name: "PtrHeadBoolNilMultiFieldsOmitEmpty", + data: (*struct { + A *bool `json:"a,omitempty"` + B *bool `json:"b,omitempty"` + })(nil), + }, + { + name: "PtrHeadBoolNilMultiFieldsString", + data: (*struct { + A *bool `json:"a,string"` + B *bool `json:"b,string"` + })(nil), + }, + + // HeadBoolZeroNotRoot + { + name: "HeadBoolZeroNotRoot", + data: struct { + A struct { + A bool `json:"a"` + } + }{}, + }, + { + name: "HeadBoolZeroNotRootOmitEmpty", + data: struct { + A struct { + A bool `json:"a,omitempty"` + } + }{}, + }, + { + name: "HeadBoolZeroNotRootString", + data: struct { + A struct { + A bool `json:"a,string"` + } + }{}, + }, + + // HeadBoolNotRoot + { + name: "HeadBoolNotRoot", + data: struct { + A struct { + A bool `json:"a"` + } + }{A: struct { + A bool `json:"a"` + }{A: true}}, + }, + { + name: "HeadBoolNotRootOmitEmpty", + data: struct { + A struct { + A bool `json:"a,omitempty"` + } + }{A: struct { + A bool `json:"a,omitempty"` + }{A: true}}, + }, + { + name: "HeadBoolNotRootString", + data: struct { + A struct { + A bool `json:"a,string"` + } + }{A: struct { + A bool `json:"a,string"` + }{A: true}}, + }, + + // HeadBoolPtrNotRoot + { + name: "HeadBoolPtrNotRoot", + data: struct { + A struct { + A *bool `json:"a"` + } + }{A: struct { + A *bool `json:"a"` + }{boolptr(true)}}, + }, + { + name: "HeadBoolPtrNotRootOmitEmpty", + data: struct { + A struct { + A *bool `json:"a,omitempty"` + } + }{A: struct { + A *bool `json:"a,omitempty"` + }{boolptr(true)}}, + }, + { + name: "HeadBoolPtrNotRootString", + data: struct { + A struct { + A *bool `json:"a,string"` + } + }{A: struct { + A *bool `json:"a,string"` + }{boolptr(true)}}, + }, + + // HeadBoolPtrNilNotRoot + { + name: "HeadBoolPtrNilNotRoot", + data: struct { + A struct { + A *bool `json:"a"` + } + }{}, + }, + { + name: "HeadBoolPtrNilNotRootOmitEmpty", + data: struct { + A struct { + A *bool `json:"a,omitempty"` + } + }{}, + }, + { + name: "HeadBoolPtrNilNotRootString", + data: struct { + A struct { + A *bool `json:"a,string"` + } + }{}, + }, + + // PtrHeadBoolZeroNotRoot + { + name: "PtrHeadBoolZeroNotRoot", + data: struct { + A *struct { + A bool `json:"a"` + } + }{A: new(struct { + A bool `json:"a"` + })}, + }, + { + name: "PtrHeadBoolZeroNotRootOmitEmpty", + data: struct { + A *struct { + A bool `json:"a,omitempty"` + } + }{A: new(struct { + A bool `json:"a,omitempty"` + })}, + }, + { + name: "PtrHeadBoolZeroNotRootString", + data: struct { + A *struct { + A bool `json:"a,string"` + } + }{A: new(struct { + A bool `json:"a,string"` + })}, + }, + + // PtrHeadBoolNotRoot + { + name: "PtrHeadBoolNotRoot", + data: struct { + A *struct { + A bool `json:"a"` + } + }{A: &(struct { + A bool `json:"a"` + }{A: true})}, + }, + { + name: "PtrHeadBoolNotRootOmitEmpty", + data: struct { + A *struct { + A bool `json:"a,omitempty"` + } + }{A: &(struct { + A bool `json:"a,omitempty"` + }{A: true})}, + }, + { + name: "PtrHeadBoolNotRootString", + data: struct { + A *struct { + A bool `json:"a,string"` + } + }{A: &(struct { + A bool `json:"a,string"` + }{A: true})}, + }, + + // PtrHeadBoolPtrNotRoot + { + name: "PtrHeadBoolPtrNotRoot", + data: struct { + A *struct { + A *bool `json:"a"` + } + }{A: &(struct { + A *bool `json:"a"` + }{A: boolptr(true)})}, + }, + { + name: "PtrHeadBoolPtrNotRootOmitEmpty", + data: struct { + A *struct { + A *bool `json:"a,omitempty"` + } + }{A: &(struct { + A *bool `json:"a,omitempty"` + }{A: boolptr(true)})}, + }, + { + name: "PtrHeadBoolPtrNotRootString", + data: struct { + A *struct { + A *bool `json:"a,string"` + } + }{A: &(struct { + A *bool `json:"a,string"` + }{A: boolptr(true)})}, + }, + + // PtrHeadBoolPtrNilNotRoot + { + name: "PtrHeadBoolPtrNilNotRoot", + data: struct { + A *struct { + A *bool `json:"a"` + } + }{A: &(struct { + A *bool `json:"a"` + }{A: nil})}, + }, + { + name: "PtrHeadBoolPtrNilNotRootOmitEmpty", + data: struct { + A *struct { + A *bool `json:"a,omitempty"` + } + }{A: &(struct { + A *bool `json:"a,omitempty"` + }{A: nil})}, + }, + { + name: "PtrHeadBoolPtrNilNotRootString", + data: struct { + A *struct { + A *bool `json:"a,string"` + } + }{A: &(struct { + A *bool `json:"a,string"` + }{A: nil})}, + }, + + // PtrHeadBoolNilNotRoot + { + name: "PtrHeadBoolNilNotRoot", + data: struct { + A *struct { + A *bool `json:"a"` + } + }{A: nil}, + }, + { + name: "PtrHeadBoolNilNotRootOmitEmpty", + data: struct { + A *struct { + A *bool `json:"a,omitempty"` + } `json:",omitempty"` + }{A: nil}, + }, + { + name: "PtrHeadBoolNilNotRootString", + data: struct { + A *struct { + A *bool `json:"a,string"` + } `json:",string"` + }{A: nil}, + }, + + // HeadBoolZeroMultiFieldsNotRoot + { + name: "HeadBoolZeroMultiFieldsNotRoot", + data: struct { + A struct { + A bool `json:"a"` + } + B struct { + B bool `json:"b"` + } + }{}, + }, + { + name: "HeadBoolZeroMultiFieldsNotRootOmitEmpty", + data: struct { + A struct { + A bool `json:"a,omitempty"` + } + B struct { + B bool `json:"b,omitempty"` + } + }{}, + }, + { + name: "HeadBoolZeroMultiFieldsNotRootString", + data: struct { + A struct { + A bool `json:"a,string"` + } + B struct { + B bool `json:"b,string"` + } + }{}, + }, + + // HeadBoolMultiFieldsNotRoot + { + name: "HeadBoolMultiFieldsNotRoot", + data: struct { + A struct { + A bool `json:"a"` + } + B struct { + B bool `json:"b"` + } + }{A: struct { + A bool `json:"a"` + }{A: true}, B: struct { + B bool `json:"b"` + }{B: false}}, + }, + { + name: "HeadBoolMultiFieldsNotRootOmitEmpty", + data: struct { + A struct { + A bool `json:"a,omitempty"` + } + B struct { + B bool `json:"b,omitempty"` + } + }{A: struct { + A bool `json:"a,omitempty"` + }{A: true}, B: struct { + B bool `json:"b,omitempty"` + }{B: false}}, + }, + { + name: "HeadBoolMultiFieldsNotRootString", + data: struct { + A struct { + A bool `json:"a,string"` + } + B struct { + B bool `json:"b,string"` + } + }{A: struct { + A bool `json:"a,string"` + }{A: true}, B: struct { + B bool `json:"b,string"` + }{B: false}}, + }, + + // HeadBoolPtrMultiFieldsNotRoot + { + name: "HeadBoolPtrMultiFieldsNotRoot", + data: struct { + A struct { + A *bool `json:"a"` + } + B struct { + B *bool `json:"b"` + } + }{A: struct { + A *bool `json:"a"` + }{A: boolptr(true)}, B: struct { + B *bool `json:"b"` + }{B: boolptr(false)}}, + }, + { + name: "HeadBoolPtrMultiFieldsNotRootOmitEmpty", + data: struct { + A struct { + A *bool `json:"a,omitempty"` + } + B struct { + B *bool `json:"b,omitempty"` + } + }{A: struct { + A *bool `json:"a,omitempty"` + }{A: boolptr(true)}, B: struct { + B *bool `json:"b,omitempty"` + }{B: boolptr(false)}}, + }, + { + name: "HeadBoolPtrMultiFieldsNotRootString", + data: struct { + A struct { + A *bool `json:"a,string"` + } + B struct { + B *bool `json:"b,string"` + } + }{A: struct { + A *bool `json:"a,string"` + }{A: boolptr(true)}, B: struct { + B *bool `json:"b,string"` + }{B: boolptr(false)}}, + }, + + // HeadBoolPtrNilMultiFieldsNotRoot + { + name: "HeadBoolPtrNilMultiFieldsNotRoot", + data: struct { + A struct { + A *bool `json:"a"` + } + B struct { + B *bool `json:"b"` + } + }{A: struct { + A *bool `json:"a"` + }{A: nil}, B: struct { + B *bool `json:"b"` + }{B: nil}}, + }, + { + name: "HeadBoolPtrNilMultiFieldsNotRootOmitEmpty", + data: struct { + A struct { + A *bool `json:"a,omitempty"` + } + B struct { + B *bool `json:"b,omitempty"` + } + }{A: struct { + A *bool `json:"a,omitempty"` + }{A: nil}, B: struct { + B *bool `json:"b,omitempty"` + }{B: nil}}, + }, + { + name: "HeadBoolPtrNilMultiFieldsNotRootString", + data: struct { + A struct { + A *bool `json:"a,string"` + } + B struct { + B *bool `json:"b,string"` + } + }{A: struct { + A *bool `json:"a,string"` + }{A: nil}, B: struct { + B *bool `json:"b,string"` + }{B: nil}}, + }, + + // PtrHeadBoolZeroMultiFieldsNotRoot + { + name: "PtrHeadBoolZeroMultiFieldsNotRoot", + data: &struct { + A struct { + A bool `json:"a"` + } + B struct { + B bool `json:"b"` + } + }{}, + }, + { + name: "PtrHeadBoolZeroMultiFieldsNotRootOmitEmpty", + data: &struct { + A struct { + A bool `json:"a,omitempty"` + } + B struct { + B bool `json:"b,omitempty"` + } + }{}, + }, + { + name: "PtrHeadBoolZeroMultiFieldsNotRootString", + data: &struct { + A struct { + A bool `json:"a,string"` + } + B struct { + B bool `json:"b,string"` + } + }{}, + }, + + // PtrHeadBoolMultiFieldsNotRoot + { + name: "PtrHeadBoolMultiFieldsNotRoot", + data: &struct { + A struct { + A bool `json:"a"` + } + B struct { + B bool `json:"b"` + } + }{A: struct { + A bool `json:"a"` + }{A: true}, B: struct { + B bool `json:"b"` + }{B: false}}, + }, + { + name: "PtrHeadBoolMultiFieldsNotRootOmitEmpty", + data: &struct { + A struct { + A bool `json:"a,omitempty"` + } + B struct { + B bool `json:"b,omitempty"` + } + }{A: struct { + A bool `json:"a,omitempty"` + }{A: true}, B: struct { + B bool `json:"b,omitempty"` + }{B: false}}, + }, + { + name: "PtrHeadBoolMultiFieldsNotRootString", + data: &struct { + A struct { + A bool `json:"a,string"` + } + B struct { + B bool `json:"b,string"` + } + }{A: struct { + A bool `json:"a,string"` + }{A: true}, B: struct { + B bool `json:"b,string"` + }{B: false}}, + }, + + // PtrHeadBoolPtrMultiFieldsNotRoot + { + name: "PtrHeadBoolPtrMultiFieldsNotRoot", + data: &struct { + A *struct { + A *bool `json:"a"` + } + B *struct { + B *bool `json:"b"` + } + }{A: &(struct { + A *bool `json:"a"` + }{A: boolptr(true)}), B: &(struct { + B *bool `json:"b"` + }{B: boolptr(false)})}, + }, + { + name: "PtrHeadBoolPtrMultiFieldsNotRootOmitEmpty", + data: &struct { + A *struct { + A *bool `json:"a,omitempty"` + } + B *struct { + B *bool `json:"b,omitempty"` + } + }{A: &(struct { + A *bool `json:"a,omitempty"` + }{A: boolptr(true)}), B: &(struct { + B *bool `json:"b,omitempty"` + }{B: boolptr(false)})}, + }, + { + name: "PtrHeadBoolPtrMultiFieldsNotRootString", + data: &struct { + A *struct { + A *bool `json:"a,string"` + } + B *struct { + B *bool `json:"b,string"` + } + }{A: &(struct { + A *bool `json:"a,string"` + }{A: boolptr(true)}), B: &(struct { + B *bool `json:"b,string"` + }{B: boolptr(false)})}, + }, + + // PtrHeadBoolPtrNilMultiFieldsNotRoot + { + name: "PtrHeadBoolPtrNilMultiFieldsNotRoot", + data: &struct { + A *struct { + A *bool `json:"a"` + } + B *struct { + B *bool `json:"b"` + } + }{A: nil, B: nil}, + }, + { + name: "PtrHeadBoolPtrNilMultiFieldsNotRootOmitEmpty", + data: &struct { + A *struct { + A *bool `json:"a,omitempty"` + } `json:",omitempty"` + B *struct { + B *bool `json:"b,omitempty"` + } `json:",omitempty"` + }{A: nil, B: nil}, + }, + { + name: "PtrHeadBoolPtrNilMultiFieldsNotRootString", + data: &struct { + A *struct { + A *bool `json:"a,string"` + } `json:",string"` + B *struct { + B *bool `json:"b,string"` + } `json:",string"` + }{A: nil, B: nil}, + }, + + // PtrHeadBoolNilMultiFieldsNotRoot + { + name: "PtrHeadBoolNilMultiFieldsNotRoot", + data: (*struct { + A *struct { + A *bool `json:"a"` + } + B *struct { + B *bool `json:"b"` + } + })(nil), + }, + { + name: "PtrHeadBoolNilMultiFieldsNotRootOmitEmpty", + data: (*struct { + A *struct { + A *bool `json:"a,omitempty"` + } + B *struct { + B *bool `json:"b,omitempty"` + } + })(nil), + }, + { + name: "PtrHeadBoolNilMultiFieldsNotRootString", + data: (*struct { + A *struct { + A *bool `json:"a,string"` + } + B *struct { + B *bool `json:"b,string"` + } + })(nil), + }, + + // PtrHeadBoolDoubleMultiFieldsNotRoot + { + name: "PtrHeadBoolDoubleMultiFieldsNotRoot", + data: &struct { + A *struct { + A bool `json:"a"` + B bool `json:"b"` + } + B *struct { + A bool `json:"a"` + B bool `json:"b"` + } + }{A: &(struct { + A bool `json:"a"` + B bool `json:"b"` + }{A: true, B: false}), B: &(struct { + A bool `json:"a"` + B bool `json:"b"` + }{A: true, B: false})}, + }, + { + name: "PtrHeadBoolDoubleMultiFieldsNotRootOmitEmpty", + data: &struct { + A *struct { + A bool `json:"a,omitempty"` + B bool `json:"b,omitempty"` + } + B *struct { + A bool `json:"a,omitempty"` + B bool `json:"b,omitempty"` + } + }{A: &(struct { + A bool `json:"a,omitempty"` + B bool `json:"b,omitempty"` + }{A: true, B: false}), B: &(struct { + A bool `json:"a,omitempty"` + B bool `json:"b,omitempty"` + }{A: true, B: false})}, + }, + { + name: "PtrHeadBoolDoubleMultiFieldsNotRootString", + data: &struct { + A *struct { + A bool `json:"a,string"` + B bool `json:"b,string"` + } + B *struct { + A bool `json:"a,string"` + B bool `json:"b,string"` + } + }{A: &(struct { + A bool `json:"a,string"` + B bool `json:"b,string"` + }{A: true, B: false}), B: &(struct { + A bool `json:"a,string"` + B bool `json:"b,string"` + }{A: true, B: false})}, + }, + + // PtrHeadBoolNilDoubleMultiFieldsNotRoot + { + name: "PtrHeadBoolNilDoubleMultiFieldsNotRoot", + data: &struct { + A *struct { + A bool `json:"a"` + B bool `json:"b"` + } + B *struct { + A bool `json:"a"` + B bool `json:"b"` + } + }{A: nil, B: nil}, + }, + { + name: "PtrHeadBoolNilDoubleMultiFieldsNotRootOmitEmpty", + data: &struct { + A *struct { + A bool `json:"a,omitempty"` + B bool `json:"b,omitempty"` + } `json:",omitempty"` + B *struct { + A bool `json:"a,omitempty"` + B bool `json:"b,omitempty"` + } `json:",omitempty"` + }{A: nil, B: nil}, + }, + { + name: "PtrHeadBoolNilDoubleMultiFieldsNotRootString", + data: &struct { + A *struct { + A bool `json:"a,string"` + B bool `json:"b,string"` + } + B *struct { + A bool `json:"a,string"` + B bool `json:"b,string"` + } + }{A: nil, B: nil}, + }, + + // PtrHeadBoolNilDoubleMultiFieldsNotRoot + { + name: "PtrHeadBoolNilDoubleMultiFieldsNotRoot", + data: (*struct { + A *struct { + A bool `json:"a"` + B bool `json:"b"` + } + B *struct { + A bool `json:"a"` + B bool `json:"b"` + } + })(nil), + }, + { + name: "PtrHeadBoolNilDoubleMultiFieldsNotRootOmitEmpty", + data: (*struct { + A *struct { + A bool `json:"a,omitempty"` + B bool `json:"b,omitempty"` + } + B *struct { + A bool `json:"a,omitempty"` + B bool `json:"b,omitempty"` + } + })(nil), + }, + { + name: "PtrHeadBoolNilDoubleMultiFieldsNotRootString", + data: (*struct { + A *struct { + A bool `json:"a,string"` + B bool `json:"b,string"` + } + B *struct { + A bool `json:"a,string"` + B bool `json:"b,string"` + } + })(nil), + }, + + // PtrHeadBoolPtrDoubleMultiFieldsNotRoot + { + name: "PtrHeadBoolPtrDoubleMultiFieldsNotRoot", + data: &struct { + A *struct { + A *bool `json:"a"` + B *bool `json:"b"` + } + B *struct { + A *bool `json:"a"` + B *bool `json:"b"` + } + }{A: &(struct { + A *bool `json:"a"` + B *bool `json:"b"` + }{A: boolptr(true), B: boolptr(false)}), B: &(struct { + A *bool `json:"a"` + B *bool `json:"b"` + }{A: boolptr(true), B: boolptr(false)})}, + }, + { + name: "PtrHeadBoolPtrDoubleMultiFieldsNotRootOmitEmpty", + data: &struct { + A *struct { + A *bool `json:"a,omitempty"` + B *bool `json:"b,omitempty"` + } + B *struct { + A *bool `json:"a,omitempty"` + B *bool `json:"b,omitempty"` + } + }{A: &(struct { + A *bool `json:"a,omitempty"` + B *bool `json:"b,omitempty"` + }{A: boolptr(true), B: boolptr(false)}), B: &(struct { + A *bool `json:"a,omitempty"` + B *bool `json:"b,omitempty"` + }{A: boolptr(true), B: boolptr(false)})}, + }, + { + name: "PtrHeadBoolPtrDoubleMultiFieldsNotRootString", + data: &struct { + A *struct { + A *bool `json:"a,string"` + B *bool `json:"b,string"` + } + B *struct { + A *bool `json:"a,string"` + B *bool `json:"b,string"` + } + }{A: &(struct { + A *bool `json:"a,string"` + B *bool `json:"b,string"` + }{A: boolptr(true), B: boolptr(false)}), B: &(struct { + A *bool `json:"a,string"` + B *bool `json:"b,string"` + }{A: boolptr(true), B: boolptr(false)})}, + }, + + // PtrHeadBoolPtrNilDoubleMultiFieldsNotRoot + { + name: "PtrHeadBoolPtrNilDoubleMultiFieldsNotRoot", + data: &struct { + A *struct { + A *bool `json:"a"` + B *bool `json:"b"` + } + B *struct { + A *bool `json:"a"` + B *bool `json:"b"` + } + }{A: nil, B: nil}, + }, + { + name: "PtrHeadBoolPtrNilDoubleMultiFieldsNotRootOmitEmpty", + data: &struct { + A *struct { + A *bool `json:"a,omitempty"` + B *bool `json:"b,omitempty"` + } `json:",omitempty"` + B *struct { + A *bool `json:"a,omitempty"` + B *bool `json:"b,omitempty"` + } `json:",omitempty"` + }{A: nil, B: nil}, + }, + { + name: "PtrHeadBoolPtrNilDoubleMultiFieldsNotRootString", + data: &struct { + A *struct { + A *bool `json:"a,string"` + B *bool `json:"b,string"` + } + B *struct { + A *bool `json:"a,string"` + B *bool `json:"b,string"` + } + }{A: nil, B: nil}, + }, + + // PtrHeadBoolPtrNilDoubleMultiFieldsNotRoot + { + name: "PtrHeadBoolPtrNilDoubleMultiFieldsNotRoot", + data: (*struct { + A *struct { + A *bool `json:"a"` + B *bool `json:"b"` + } + B *struct { + A *bool `json:"a"` + B *bool `json:"b"` + } + })(nil), + }, + { + name: "PtrHeadBoolPtrNilDoubleMultiFieldsNotRootOmitEmpty", + data: (*struct { + A *struct { + A *bool `json:"a,omitempty"` + B *bool `json:"b,omitempty"` + } + B *struct { + A *bool `json:"a,omitempty"` + B *bool `json:"b,omitempty"` + } + })(nil), + }, + { + name: "PtrHeadBoolPtrNilDoubleMultiFieldsNotRootString", + data: (*struct { + A *struct { + A *bool `json:"a,string"` + B *bool `json:"b,string"` + } + B *struct { + A *bool `json:"a,string"` + B *bool `json:"b,string"` + } + })(nil), + }, + + // AnonymousHeadBool + { + name: "AnonymousHeadBool", + data: struct { + structBool + B bool `json:"b"` + }{ + structBool: structBool{A: true}, + B: false, + }, + }, + { + name: "AnonymousHeadBoolOmitEmpty", + data: struct { + structBoolOmitEmpty + B bool `json:"b,omitempty"` + }{ + structBoolOmitEmpty: structBoolOmitEmpty{A: true}, + B: false, + }, + }, + { + name: "AnonymousHeadBoolString", + data: struct { + structBoolString + B bool `json:"b,string"` + }{ + structBoolString: structBoolString{A: true}, + B: false, + }, + }, + + // PtrAnonymousHeadBool + { + name: "PtrAnonymousHeadBool", + data: struct { + *structBool + B bool `json:"b"` + }{ + structBool: &structBool{A: true}, + B: false, + }, + }, + { + name: "PtrAnonymousHeadBoolOmitEmpty", + data: struct { + *structBoolOmitEmpty + B bool `json:"b,omitempty"` + }{ + structBoolOmitEmpty: &structBoolOmitEmpty{A: true}, + B: false, + }, + }, + { + name: "PtrAnonymousHeadBoolString", + data: struct { + *structBoolString + B bool `json:"b,string"` + }{ + structBoolString: &structBoolString{A: true}, + B: false, + }, + }, + + // NilPtrAnonymousHeadBool + { + name: "NilPtrAnonymousHeadBool", + data: struct { + *structBool + B bool `json:"b"` + }{ + structBool: nil, + B: true, + }, + }, + { + name: "NilPtrAnonymousHeadBoolOmitEmpty", + data: struct { + *structBoolOmitEmpty + B bool `json:"b,omitempty"` + }{ + structBoolOmitEmpty: nil, + B: true, + }, + }, + { + name: "NilPtrAnonymousHeadBoolString", + data: struct { + *structBoolString + B bool `json:"b,string"` + }{ + structBoolString: nil, + B: true, + }, + }, + + // AnonymousHeadBoolPtr + { + name: "AnonymousHeadBoolPtr", + data: struct { + structBoolPtr + B *bool `json:"b"` + }{ + structBoolPtr: structBoolPtr{A: boolptr(true)}, + B: boolptr(false), + }, + }, + { + name: "AnonymousHeadBoolPtrOmitEmpty", + data: struct { + structBoolPtrOmitEmpty + B *bool `json:"b,omitempty"` + }{ + structBoolPtrOmitEmpty: structBoolPtrOmitEmpty{A: boolptr(true)}, + B: boolptr(false), + }, + }, + { + name: "AnonymousHeadBoolPtrString", + data: struct { + structBoolPtrString + B *bool `json:"b,string"` + }{ + structBoolPtrString: structBoolPtrString{A: boolptr(true)}, + B: boolptr(false), + }, + }, + + // AnonymousHeadBoolPtrNil + { + name: "AnonymousHeadBoolPtrNil", + data: struct { + structBoolPtr + B *bool `json:"b"` + }{ + structBoolPtr: structBoolPtr{A: nil}, + B: boolptr(true), + }, + }, + { + name: "AnonymousHeadBoolPtrNilOmitEmpty", + data: struct { + structBoolPtrOmitEmpty + B *bool `json:"b,omitempty"` + }{ + structBoolPtrOmitEmpty: structBoolPtrOmitEmpty{A: nil}, + B: boolptr(true), + }, + }, + { + name: "AnonymousHeadBoolPtrNilString", + data: struct { + structBoolPtrString + B *bool `json:"b,string"` + }{ + structBoolPtrString: structBoolPtrString{A: nil}, + B: boolptr(true), + }, + }, + + // PtrAnonymousHeadBoolPtr + { + name: "PtrAnonymousHeadBoolPtr", + data: struct { + *structBoolPtr + B *bool `json:"b"` + }{ + structBoolPtr: &structBoolPtr{A: boolptr(true)}, + B: boolptr(false), + }, + }, + { + name: "PtrAnonymousHeadBoolPtrOmitEmpty", + data: struct { + *structBoolPtrOmitEmpty + B *bool `json:"b,omitempty"` + }{ + structBoolPtrOmitEmpty: &structBoolPtrOmitEmpty{A: boolptr(true)}, + B: boolptr(false), + }, + }, + { + name: "PtrAnonymousHeadBoolPtrString", + data: struct { + *structBoolPtrString + B *bool `json:"b,string"` + }{ + structBoolPtrString: &structBoolPtrString{A: boolptr(true)}, + B: boolptr(false), + }, + }, + + // NilPtrAnonymousHeadBoolPtr + { + name: "NilPtrAnonymousHeadBoolPtr", + data: struct { + *structBoolPtr + B *bool `json:"b"` + }{ + structBoolPtr: nil, + B: boolptr(true), + }, + }, + { + name: "NilPtrAnonymousHeadBoolPtrOmitEmpty", + data: struct { + *structBoolPtrOmitEmpty + B *bool `json:"b,omitempty"` + }{ + structBoolPtrOmitEmpty: nil, + B: boolptr(true), + }, + }, + { + name: "NilPtrAnonymousHeadBoolPtrString", + data: struct { + *structBoolPtrString + B *bool `json:"b,string"` + }{ + structBoolPtrString: nil, + B: boolptr(true), + }, + }, + + // AnonymousHeadBoolOnly + { + name: "AnonymousHeadBoolOnly", + data: struct { + structBool + }{ + structBool: structBool{A: true}, + }, + }, + { + name: "AnonymousHeadBoolOnlyOmitEmpty", + data: struct { + structBoolOmitEmpty + }{ + structBoolOmitEmpty: structBoolOmitEmpty{A: true}, + }, + }, + { + name: "AnonymousHeadBoolOnlyString", + data: struct { + structBoolString + }{ + structBoolString: structBoolString{A: true}, + }, + }, + + // PtrAnonymousHeadBoolOnly + { + name: "PtrAnonymousHeadBoolOnly", + data: struct { + *structBool + }{ + structBool: &structBool{A: true}, + }, + }, + { + name: "PtrAnonymousHeadBoolOnlyOmitEmpty", + data: struct { + *structBoolOmitEmpty + }{ + structBoolOmitEmpty: &structBoolOmitEmpty{A: true}, + }, + }, + { + name: "PtrAnonymousHeadBoolOnlyString", + data: struct { + *structBoolString + }{ + structBoolString: &structBoolString{A: true}, + }, + }, + + // NilPtrAnonymousHeadBoolOnly + { + name: "NilPtrAnonymousHeadBoolOnly", + data: struct { + *structBool + }{ + structBool: nil, + }, + }, + { + name: "NilPtrAnonymousHeadBoolOnlyOmitEmpty", + data: struct { + *structBoolOmitEmpty + }{ + structBoolOmitEmpty: nil, + }, + }, + { + name: "NilPtrAnonymousHeadBoolOnlyString", + data: struct { + *structBoolString + }{ + structBoolString: nil, + }, + }, + + // AnonymousHeadBoolPtrOnly + { + name: "AnonymousHeadBoolPtrOnly", + data: struct { + structBoolPtr + }{ + structBoolPtr: structBoolPtr{A: boolptr(true)}, + }, + }, + { + name: "AnonymousHeadBoolPtrOnlyOmitEmpty", + data: struct { + structBoolPtrOmitEmpty + }{ + structBoolPtrOmitEmpty: structBoolPtrOmitEmpty{A: boolptr(true)}, + }, + }, + { + name: "AnonymousHeadBoolPtrOnlyString", + data: struct { + structBoolPtrString + }{ + structBoolPtrString: structBoolPtrString{A: boolptr(true)}, + }, + }, + + // AnonymousHeadBoolPtrNilOnly + { + name: "AnonymousHeadBoolPtrNilOnly", + data: struct { + structBoolPtr + }{ + structBoolPtr: structBoolPtr{A: nil}, + }, + }, + { + name: "AnonymousHeadBoolPtrNilOnlyOmitEmpty", + data: struct { + structBoolPtrOmitEmpty + }{ + structBoolPtrOmitEmpty: structBoolPtrOmitEmpty{A: nil}, + }, + }, + { + name: "AnonymousHeadBoolPtrNilOnlyString", + data: struct { + structBoolPtrString + }{ + structBoolPtrString: structBoolPtrString{A: nil}, + }, + }, + + // PtrAnonymousHeadBoolPtrOnly + { + name: "PtrAnonymousHeadBoolPtrOnly", + data: struct { + *structBoolPtr + }{ + structBoolPtr: &structBoolPtr{A: boolptr(true)}, + }, + }, + { + name: "PtrAnonymousHeadBoolPtrOnlyOmitEmpty", + data: struct { + *structBoolPtrOmitEmpty + }{ + structBoolPtrOmitEmpty: &structBoolPtrOmitEmpty{A: boolptr(true)}, + }, + }, + { + name: "PtrAnonymousHeadBoolPtrOnlyString", + data: struct { + *structBoolPtrString + }{ + structBoolPtrString: &structBoolPtrString{A: boolptr(true)}, + }, + }, + + // NilPtrAnonymousHeadBoolPtrOnly + { + name: "NilPtrAnonymousHeadBoolPtrOnly", + data: struct { + *structBoolPtr + }{ + structBoolPtr: nil, + }, + }, + { + name: "NilPtrAnonymousHeadBoolPtrOnlyOmitEmpty", + data: struct { + *structBoolPtrOmitEmpty + }{ + structBoolPtrOmitEmpty: nil, + }, + }, + { + name: "NilPtrAnonymousHeadBoolPtrOnlyString", + data: struct { + *structBoolPtrString + }{ + structBoolPtrString: nil, + }, + }, + } + for _, test := range tests { + for _, indent := range []bool{true, false} { + for _, htmlEscape := range []bool{true, false} { + var buf bytes.Buffer + enc := json.NewEncoder(&buf) + enc.SetEscapeHTML(htmlEscape) + if indent { + enc.SetIndent("", " ") + } + if err := enc.Encode(test.data); err != nil { + 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()) + } + } + } + } +} diff --git a/cover_helper_test.go b/cover_helper_test.go index 766a2b1..8094230 100644 --- a/cover_helper_test.go +++ b/cover_helper_test.go @@ -18,6 +18,7 @@ func uint64ptr(v uint64) *uint64 { return &v } func float32ptr(v float32) *float32 { return &v } func float64ptr(v float64) *float64 { return &v } func stringptr(v string) *string { return &v } +func boolptr(v bool) *bool { return &v } func encodeByEncodingJSON(data interface{}, indent, escape bool) string { var buf bytes.Buffer From ddc486cc62ac6858d8cadbd721ecb195968c717e Mon Sep 17 00:00:00 2001 From: Masaaki Goshima Date: Mon, 15 Feb 2021 12:57:16 +0900 Subject: [PATCH 15/15] Add opcode for bool type to the encoder --- encode_vm.go | 535 ++++++++++++++++++++++++------ encode_vm_escaped.go | 553 ++++++++++++++++++++++++------- encode_vm_escaped_indent.go | 625 +++++++++++++++++++++++++++++++----- encode_vm_indent.go | 625 +++++++++++++++++++++++++++++++----- 4 files changed, 1952 insertions(+), 386 deletions(-) diff --git a/encode_vm.go b/encode_vm.go index d66a872..667b220 100644 --- a/encode_vm.go +++ b/encode_vm.go @@ -6449,6 +6449,158 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco b = encodeComma(b) code = code.next case opStructFieldPtrHeadBool: + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + fallthrough + case opStructFieldHeadBool: + ptr := load(ctxptr, code.idx) + if ptr == 0 { + b = encodeNull(b) + b = encodeComma(b) + code = code.end.next + } else { + b = append(b, '{') + b = append(b, code.key...) + b = encodeBool(b, ptrToBool(ptr+code.offset)) + b = encodeComma(b) + code = code.next + } + case opStructFieldPtrHeadOmitEmptyBool: + ptr := load(ctxptr, code.idx) + if ptr != 0 { + store(ctxptr, code.idx, ptrToPtr(ptr)) + } + fallthrough + case opStructFieldHeadOmitEmptyBool: + ptr := load(ctxptr, code.idx) + if ptr == 0 { + b = encodeNull(b) + b = encodeComma(b) + code = code.end.next + } else { + b = append(b, '{') + v := ptrToBool(ptr + code.offset) + if v { + b = append(b, code.key...) + b = encodeBool(b, v) + b = encodeComma(b) + code = code.next + } else { + code = code.nextField + } + } + case opStructFieldPtrHeadStringTagBool: + ptr := load(ctxptr, code.idx) + if ptr != 0 { + store(ctxptr, code.idx, ptrToPtr(ptr)) + } + fallthrough + case opStructFieldHeadStringTagBool: + ptr := load(ctxptr, code.idx) + if ptr == 0 { + b = encodeNull(b) + b = encodeComma(b) + code = code.end.next + } else { + b = append(b, '{') + b = append(b, code.key...) + b = append(b, '"') + b = encodeBool(b, ptrToBool(ptr+code.offset)) + b = append(b, '"') + b = encodeComma(b) + code = code.next + } + case opStructFieldPtrHeadBoolOnly, opStructFieldHeadBoolOnly: + p := load(ctxptr, code.idx) + b = append(b, '{') + b = append(b, code.key...) + b = encodeBool(b, ptrToBool(p)) + b = encodeComma(b) + code = code.next + case opStructFieldPtrHeadOmitEmptyBoolOnly, opStructFieldHeadOmitEmptyBoolOnly: + p := load(ctxptr, code.idx) + b = append(b, '{') + v := ptrToBool(p) + if v { + b = append(b, code.key...) + b = encodeBool(b, v) + b = encodeComma(b) + } + code = code.next + case opStructFieldPtrHeadStringTagBoolOnly, opStructFieldHeadStringTagBoolOnly: + p := load(ctxptr, code.idx) + b = append(b, '{') + b = append(b, code.key...) + b = append(b, '"') + b = encodeBool(b, ptrToBool(p)) + b = append(b, '"') + b = encodeComma(b) + code = code.next + case opStructFieldPtrHeadBoolPtr: + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + fallthrough + case opStructFieldHeadBoolPtr: + p := load(ctxptr, code.idx) + if p == 0 { + b = encodeNull(b) + b = encodeComma(b) + code = code.end.next + break + } else { + b = append(b, '{') + b = append(b, code.key...) + p = ptrToPtr(p) + if p == 0 { + b = encodeNull(b) + } else { + b = encodeBool(b, ptrToBool(p+code.offset)) + } + } + b = encodeComma(b) + code = code.next + case opStructFieldPtrHeadOmitEmptyBoolPtr: + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + fallthrough + case opStructFieldHeadOmitEmptyBoolPtr: + p := load(ctxptr, code.idx) + if p == 0 { + b = encodeNull(b) + b = encodeComma(b) + code = code.end.next + } else { + b = append(b, '{') + p = ptrToPtr(p) + if p != 0 { + b = append(b, code.key...) + b = encodeBool(b, ptrToBool(p)) + b = encodeComma(b) + } + code = code.next + } + case opStructFieldPtrHeadStringTagBoolPtr: + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + fallthrough + case opStructFieldHeadStringTagBoolPtr: + p := load(ctxptr, code.idx) + if p == 0 { + b = encodeNull(b) + b = encodeComma(b) + code = code.end.next + break + } else { + b = append(b, '{') + b = append(b, code.key...) + p = ptrToPtr(p) + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = encodeBool(b, ptrToBool(p+code.offset)) + b = append(b, '"') + } + } + b = encodeComma(b) + code = code.next + case opStructFieldPtrHeadBoolPtrOnly: p := load(ctxptr, code.idx) if p == 0 { b = encodeNull(b) @@ -6458,24 +6610,18 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco } store(ctxptr, code.idx, ptrToPtr(p)) fallthrough - case opStructFieldHeadBool: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - if code.op == opStructFieldPtrHeadBool { - b = encodeNull(b) - b = encodeComma(b) - } else { - b = append(b, '{', '}', ',') - } - code = code.end.next + case opStructFieldHeadBoolPtrOnly: + p := load(ctxptr, code.idx) + b = append(b, '{') + b = append(b, code.key...) + if p == 0 { + b = encodeNull(b) } else { - b = append(b, '{') - b = append(b, code.key...) - b = encodeBool(b, ptrToBool(ptr+code.offset)) - b = encodeComma(b) - code = code.next + b = encodeBool(b, ptrToBool(p+code.offset)) } - case opStructFieldPtrHeadBoolOnly: + b = encodeComma(b) + code = code.next + case opStructFieldPtrHeadOmitEmptyBoolPtrOnly: p := load(ctxptr, code.idx) if p == 0 { b = encodeNull(b) @@ -6483,12 +6629,59 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco code = code.end.next break } + store(ctxptr, code.idx, ptrToPtr(p)) fallthrough - case opStructFieldHeadBoolOnly: - ptr := load(ctxptr, code.idx) + case opStructFieldHeadOmitEmptyBoolPtrOnly: + b = append(b, '{') + p := load(ctxptr, code.idx) + if p != 0 { + b = append(b, code.key...) + b = encodeBool(b, ptrToBool(p+code.offset)) + b = encodeComma(b) + } + code = code.next + case opStructFieldPtrHeadStringTagBoolPtrOnly: + p := load(ctxptr, code.idx) + if p == 0 { + b = encodeNull(b) + b = encodeComma(b) + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadStringTagBoolPtrOnly: + p := load(ctxptr, code.idx) b = append(b, '{') b = append(b, code.key...) - b = encodeBool(b, ptrToBool(ptr+code.offset)) + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = encodeBool(b, ptrToBool(p+code.offset)) + b = append(b, '"') + } + b = encodeComma(b) + code = code.next + case opStructFieldHeadBoolNPtr: + p := load(ctxptr, code.idx) + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '{') + b = append(b, code.key...) + for i := 0; i < code.ptrNum; i++ { + if p == 0 { + break + } + p = ptrToPtr(p) + } + if p == 0 { + b = encodeNull(b) + } else { + b = encodeBool(b, ptrToBool(p+code.offset)) + } + } b = encodeComma(b) code = code.next case opStructFieldPtrAnonymousHeadBool: @@ -6504,6 +6697,194 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco b = encodeComma(b) code = code.next } + case opStructFieldPtrAnonymousHeadOmitEmptyBool: + ptr := load(ctxptr, code.idx) + if ptr != 0 { + store(ctxptr, code.idx, ptrToPtr(ptr)) + } + fallthrough + case opStructFieldAnonymousHeadOmitEmptyBool: + ptr := load(ctxptr, code.idx) + if ptr == 0 { + code = code.end.next + } else { + v := ptrToBool(ptr + code.offset) + if v { + b = append(b, code.key...) + b = encodeBool(b, v) + b = encodeComma(b) + code = code.next + } else { + code = code.nextField + } + } + case opStructFieldPtrAnonymousHeadStringTagBool: + ptr := load(ctxptr, code.idx) + if ptr != 0 { + store(ctxptr, code.idx, ptrToPtr(ptr)) + } + fallthrough + case opStructFieldAnonymousHeadStringTagBool: + ptr := load(ctxptr, code.idx) + if ptr == 0 { + code = code.end.next + } else { + b = append(b, code.key...) + b = append(b, '"') + b = encodeBool(b, ptrToBool(ptr+code.offset)) + b = append(b, '"') + b = encodeComma(b) + code = code.next + } + case opStructFieldPtrAnonymousHeadBoolOnly, opStructFieldAnonymousHeadBoolOnly: + ptr := load(ctxptr, code.idx) + if ptr == 0 { + code = code.end.next + } else { + b = append(b, code.key...) + b = encodeBool(b, ptrToBool(ptr+code.offset)) + b = encodeComma(b) + code = code.next + } + case opStructFieldPtrAnonymousHeadOmitEmptyBoolOnly, opStructFieldAnonymousHeadOmitEmptyBoolOnly: + ptr := load(ctxptr, code.idx) + if ptr == 0 { + code = code.end.next + } else { + v := ptrToBool(ptr + code.offset) + if v { + b = append(b, code.key...) + b = encodeBool(b, v) + b = encodeComma(b) + code = code.next + } else { + code = code.nextField + } + } + case opStructFieldPtrAnonymousHeadStringTagBoolOnly, opStructFieldAnonymousHeadStringTagBoolOnly: + ptr := load(ctxptr, code.idx) + if ptr == 0 { + code = code.end.next + } else { + b = append(b, code.key...) + b = append(b, '"') + b = encodeBool(b, ptrToBool(ptr+code.offset)) + b = append(b, '"') + b = encodeComma(b) + code = code.next + } + case opStructFieldPtrAnonymousHeadBoolPtr: + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + fallthrough + case opStructFieldAnonymousHeadBoolPtr: + p := load(ctxptr, code.idx) + if p == 0 { + code = code.end.next + break + } + b = append(b, code.key...) + p = ptrToPtr(p) + if p == 0 { + b = encodeNull(b) + } else { + b = encodeBool(b, ptrToBool(p+code.offset)) + } + b = encodeComma(b) + code = code.next + case opStructFieldPtrAnonymousHeadOmitEmptyBoolPtr: + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + fallthrough + case opStructFieldAnonymousHeadOmitEmptyBoolPtr: + p := load(ctxptr, code.idx) + if p == 0 { + code = code.end.next + break + } + p = ptrToPtr(p) + if p == 0 { + code = code.nextField + } else { + b = append(b, code.key...) + b = encodeBool(b, ptrToBool(p)) + b = encodeComma(b) + code = code.next + } + case opStructFieldPtrAnonymousHeadStringTagBoolPtr: + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + fallthrough + case opStructFieldAnonymousHeadStringTagBoolPtr: + p := load(ctxptr, code.idx) + if p == 0 { + code = code.end.next + break + } + b = append(b, code.key...) + p = ptrToPtr(p) + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = encodeBool(b, ptrToBool(p+code.offset)) + b = append(b, '"') + } + b = encodeComma(b) + code = code.next + case opStructFieldPtrAnonymousHeadBoolPtrOnly: + p := load(ctxptr, code.idx) + if p == 0 { + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldAnonymousHeadBoolPtrOnly: + p := load(ctxptr, code.idx) + b = append(b, code.key...) + if p == 0 { + b = encodeNull(b) + } else { + b = encodeBool(b, ptrToBool(p+code.offset)) + } + b = encodeComma(b) + code = code.next + case opStructFieldPtrAnonymousHeadOmitEmptyBoolPtrOnly: + p := load(ctxptr, code.idx) + if p == 0 { + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldAnonymousHeadOmitEmptyBoolPtrOnly: + p := load(ctxptr, code.idx) + if p == 0 { + code = code.nextField + } else { + b = append(b, code.key...) + b = encodeBool(b, ptrToBool(p+code.offset)) + b = encodeComma(b) + code = code.next + } + case opStructFieldPtrAnonymousHeadStringTagBoolPtrOnly: + p := load(ctxptr, code.idx) + if p == 0 { + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldAnonymousHeadStringTagBoolPtrOnly: + p := load(ctxptr, code.idx) + b = append(b, code.key...) + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = encodeBool(b, ptrToBool(p+code.offset)) + b = append(b, '"') + } + b = encodeComma(b) + code = code.next case opStructFieldPtrHeadBytes: p := load(ctxptr, code.idx) if p == 0 { @@ -6770,51 +7151,6 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco b = encodeComma(b) code = code.next } - case opStructFieldPtrHeadOmitEmptyBool: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadOmitEmptyBool: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - v := ptrToBool(ptr + code.offset) - if !v { - code = code.nextField - } else { - b = append(b, code.key...) - b = encodeBool(b, v) - b = encodeComma(b) - code = code.next - } - } - case opStructFieldPtrAnonymousHeadOmitEmptyBool: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldAnonymousHeadOmitEmptyBool: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - v := ptrToBool(ptr + code.offset) - if !v { - code = code.nextField - } else { - b = append(b, code.key...) - b = encodeBool(b, v) - b = encodeComma(b) - code = code.next - } - } case opStructFieldPtrHeadOmitEmptyBytes: ptr := load(ctxptr, code.idx) if ptr != 0 { @@ -7054,45 +7390,6 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco code = code.next store(ctxptr, code.idx, ptr+code.offset) } - case opStructFieldPtrHeadStringTagBool: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadStringTagBool: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - b = append(b, code.key...) - b = append(b, '"') - b = encodeBool(b, ptrToBool(ptr+code.offset)) - b = append(b, '"') - b = encodeComma(b) - code = code.next - } - case opStructFieldPtrAnonymousHeadStringTagBool: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldAnonymousHeadStringTagBool: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = append(b, code.key...) - b = append(b, '"') - b = encodeBool(b, ptrToBool(ptr+code.offset)) - b = append(b, '"') - b = encodeComma(b) - code = code.next - } case opStructFieldPtrHeadStringTagBytes: ptr := load(ctxptr, code.idx) if ptr != 0 { @@ -8111,7 +8408,9 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco if p == 0 { b = encodeNull(b) } else { + b = append(b, '"') b = encodeBool(b, ptrToBool(p)) + b = append(b, '"') } b = encodeComma(b) code = code.next @@ -9580,6 +9879,36 @@ func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt Enco } b = appendStructEnd(b) code = code.next + case opStructEndOmitEmptyBoolPtr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = append(b, code.key...) + b = encodeBool(b, ptrToBool(p)) + b = appendStructEnd(b) + } else { + last := len(b) - 1 + if b[last] == ',' { + b[last] = '}' + b = encodeComma(b) + } else { + b = appendStructEnd(b) + } + } + code = code.next + case opStructEndStringTagBoolPtr: + b = append(b, code.key...) + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = encodeBool(b, ptrToBool(p)) + b = append(b, '"') + } + b = appendStructEnd(b) + code = code.next case opStructEndBytes: ptr := load(ctxptr, code.headIdx) b = append(b, code.key...) diff --git a/encode_vm_escaped.go b/encode_vm_escaped.go index bbac701..1188b57 100644 --- a/encode_vm_escaped.go +++ b/encode_vm_escaped.go @@ -6387,6 +6387,158 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o b = encodeComma(b) code = code.next case opStructFieldPtrHeadBool: + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + fallthrough + case opStructFieldHeadBool: + ptr := load(ctxptr, code.idx) + if ptr == 0 { + b = encodeNull(b) + b = encodeComma(b) + code = code.end.next + } else { + b = append(b, '{') + b = append(b, code.escapedKey...) + b = encodeBool(b, ptrToBool(ptr+code.offset)) + b = encodeComma(b) + code = code.next + } + case opStructFieldPtrHeadOmitEmptyBool: + ptr := load(ctxptr, code.idx) + if ptr != 0 { + store(ctxptr, code.idx, ptrToPtr(ptr)) + } + fallthrough + case opStructFieldHeadOmitEmptyBool: + ptr := load(ctxptr, code.idx) + if ptr == 0 { + b = encodeNull(b) + b = encodeComma(b) + code = code.end.next + } else { + b = append(b, '{') + v := ptrToBool(ptr + code.offset) + if v { + b = append(b, code.escapedKey...) + b = encodeBool(b, v) + b = encodeComma(b) + code = code.next + } else { + code = code.nextField + } + } + case opStructFieldPtrHeadStringTagBool: + ptr := load(ctxptr, code.idx) + if ptr != 0 { + store(ctxptr, code.idx, ptrToPtr(ptr)) + } + fallthrough + case opStructFieldHeadStringTagBool: + ptr := load(ctxptr, code.idx) + if ptr == 0 { + b = encodeNull(b) + b = encodeComma(b) + code = code.end.next + } else { + b = append(b, '{') + b = append(b, code.escapedKey...) + b = append(b, '"') + b = encodeBool(b, ptrToBool(ptr+code.offset)) + b = append(b, '"') + b = encodeComma(b) + code = code.next + } + case opStructFieldPtrHeadBoolOnly, opStructFieldHeadBoolOnly: + p := load(ctxptr, code.idx) + b = append(b, '{') + b = append(b, code.escapedKey...) + b = encodeBool(b, ptrToBool(p)) + b = encodeComma(b) + code = code.next + case opStructFieldPtrHeadOmitEmptyBoolOnly, opStructFieldHeadOmitEmptyBoolOnly: + p := load(ctxptr, code.idx) + b = append(b, '{') + v := ptrToBool(p) + if v { + b = append(b, code.escapedKey...) + b = encodeBool(b, v) + b = encodeComma(b) + } + code = code.next + case opStructFieldPtrHeadStringTagBoolOnly, opStructFieldHeadStringTagBoolOnly: + p := load(ctxptr, code.idx) + b = append(b, '{') + b = append(b, code.escapedKey...) + b = append(b, '"') + b = encodeBool(b, ptrToBool(p)) + b = append(b, '"') + b = encodeComma(b) + code = code.next + case opStructFieldPtrHeadBoolPtr: + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + fallthrough + case opStructFieldHeadBoolPtr: + p := load(ctxptr, code.idx) + if p == 0 { + b = encodeNull(b) + b = encodeComma(b) + code = code.end.next + break + } else { + b = append(b, '{') + b = append(b, code.escapedKey...) + p = ptrToPtr(p) + if p == 0 { + b = encodeNull(b) + } else { + b = encodeBool(b, ptrToBool(p+code.offset)) + } + } + b = encodeComma(b) + code = code.next + case opStructFieldPtrHeadOmitEmptyBoolPtr: + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + fallthrough + case opStructFieldHeadOmitEmptyBoolPtr: + p := load(ctxptr, code.idx) + if p == 0 { + b = encodeNull(b) + b = encodeComma(b) + code = code.end.next + } else { + b = append(b, '{') + p = ptrToPtr(p) + if p != 0 { + b = append(b, code.escapedKey...) + b = encodeBool(b, ptrToBool(p)) + b = encodeComma(b) + } + code = code.next + } + case opStructFieldPtrHeadStringTagBoolPtr: + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + fallthrough + case opStructFieldHeadStringTagBoolPtr: + p := load(ctxptr, code.idx) + if p == 0 { + b = encodeNull(b) + b = encodeComma(b) + code = code.end.next + break + } else { + b = append(b, '{') + b = append(b, code.escapedKey...) + p = ptrToPtr(p) + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = encodeBool(b, ptrToBool(p+code.offset)) + b = append(b, '"') + } + } + b = encodeComma(b) + code = code.next + case opStructFieldPtrHeadBoolPtrOnly: p := load(ctxptr, code.idx) if p == 0 { b = encodeNull(b) @@ -6396,24 +6548,18 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o } store(ctxptr, code.idx, ptrToPtr(p)) fallthrough - case opStructFieldHeadBool: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - if code.op == opStructFieldPtrHeadBool { - b = encodeNull(b) - b = encodeComma(b) - } else { - b = append(b, '{', '}', ',') - } - code = code.end.next + case opStructFieldHeadBoolPtrOnly: + p := load(ctxptr, code.idx) + b = append(b, '{') + b = append(b, code.escapedKey...) + if p == 0 { + b = encodeNull(b) } else { - b = append(b, '{') - b = append(b, code.escapedKey...) - b = encodeBool(b, ptrToBool(ptr+code.offset)) - b = encodeComma(b) - code = code.next + b = encodeBool(b, ptrToBool(p+code.offset)) } - case opStructFieldPtrHeadBoolOnly: + b = encodeComma(b) + code = code.next + case opStructFieldPtrHeadOmitEmptyBoolPtrOnly: p := load(ctxptr, code.idx) if p == 0 { b = encodeNull(b) @@ -6421,12 +6567,59 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o code = code.end.next break } + store(ctxptr, code.idx, ptrToPtr(p)) fallthrough - case opStructFieldHeadBoolOnly: - ptr := load(ctxptr, code.idx) + case opStructFieldHeadOmitEmptyBoolPtrOnly: + b = append(b, '{') + p := load(ctxptr, code.idx) + if p != 0 { + b = append(b, code.escapedKey...) + b = encodeBool(b, ptrToBool(p+code.offset)) + b = encodeComma(b) + } + code = code.next + case opStructFieldPtrHeadStringTagBoolPtrOnly: + p := load(ctxptr, code.idx) + if p == 0 { + b = encodeNull(b) + b = encodeComma(b) + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadStringTagBoolPtrOnly: + p := load(ctxptr, code.idx) b = append(b, '{') b = append(b, code.escapedKey...) - b = encodeBool(b, ptrToBool(ptr+code.offset)) + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = encodeBool(b, ptrToBool(p+code.offset)) + b = append(b, '"') + } + b = encodeComma(b) + code = code.next + case opStructFieldHeadBoolNPtr: + p := load(ctxptr, code.idx) + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '{') + b = append(b, code.escapedKey...) + for i := 0; i < code.ptrNum; i++ { + if p == 0 { + break + } + p = ptrToPtr(p) + } + if p == 0 { + b = encodeNull(b) + } else { + b = encodeBool(b, ptrToBool(p+code.offset)) + } + } b = encodeComma(b) code = code.next case opStructFieldPtrAnonymousHeadBool: @@ -6442,6 +6635,194 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o b = encodeComma(b) code = code.next } + case opStructFieldPtrAnonymousHeadOmitEmptyBool: + ptr := load(ctxptr, code.idx) + if ptr != 0 { + store(ctxptr, code.idx, ptrToPtr(ptr)) + } + fallthrough + case opStructFieldAnonymousHeadOmitEmptyBool: + ptr := load(ctxptr, code.idx) + if ptr == 0 { + code = code.end.next + } else { + v := ptrToBool(ptr + code.offset) + if v { + b = append(b, code.escapedKey...) + b = encodeBool(b, v) + b = encodeComma(b) + code = code.next + } else { + code = code.nextField + } + } + case opStructFieldPtrAnonymousHeadStringTagBool: + ptr := load(ctxptr, code.idx) + if ptr != 0 { + store(ctxptr, code.idx, ptrToPtr(ptr)) + } + fallthrough + case opStructFieldAnonymousHeadStringTagBool: + ptr := load(ctxptr, code.idx) + if ptr == 0 { + code = code.end.next + } else { + b = append(b, code.escapedKey...) + b = append(b, '"') + b = encodeBool(b, ptrToBool(ptr+code.offset)) + b = append(b, '"') + b = encodeComma(b) + code = code.next + } + case opStructFieldPtrAnonymousHeadBoolOnly, opStructFieldAnonymousHeadBoolOnly: + ptr := load(ctxptr, code.idx) + if ptr == 0 { + code = code.end.next + } else { + b = append(b, code.escapedKey...) + b = encodeBool(b, ptrToBool(ptr+code.offset)) + b = encodeComma(b) + code = code.next + } + case opStructFieldPtrAnonymousHeadOmitEmptyBoolOnly, opStructFieldAnonymousHeadOmitEmptyBoolOnly: + ptr := load(ctxptr, code.idx) + if ptr == 0 { + code = code.end.next + } else { + v := ptrToBool(ptr + code.offset) + if v { + b = append(b, code.escapedKey...) + b = encodeBool(b, v) + b = encodeComma(b) + code = code.next + } else { + code = code.nextField + } + } + case opStructFieldPtrAnonymousHeadStringTagBoolOnly, opStructFieldAnonymousHeadStringTagBoolOnly: + ptr := load(ctxptr, code.idx) + if ptr == 0 { + code = code.end.next + } else { + b = append(b, code.escapedKey...) + b = append(b, '"') + b = encodeBool(b, ptrToBool(ptr+code.offset)) + b = append(b, '"') + b = encodeComma(b) + code = code.next + } + case opStructFieldPtrAnonymousHeadBoolPtr: + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + fallthrough + case opStructFieldAnonymousHeadBoolPtr: + p := load(ctxptr, code.idx) + if p == 0 { + code = code.end.next + break + } + b = append(b, code.escapedKey...) + p = ptrToPtr(p) + if p == 0 { + b = encodeNull(b) + } else { + b = encodeBool(b, ptrToBool(p+code.offset)) + } + b = encodeComma(b) + code = code.next + case opStructFieldPtrAnonymousHeadOmitEmptyBoolPtr: + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + fallthrough + case opStructFieldAnonymousHeadOmitEmptyBoolPtr: + p := load(ctxptr, code.idx) + if p == 0 { + code = code.end.next + break + } + p = ptrToPtr(p) + if p == 0 { + code = code.nextField + } else { + b = append(b, code.escapedKey...) + b = encodeBool(b, ptrToBool(p)) + b = encodeComma(b) + code = code.next + } + case opStructFieldPtrAnonymousHeadStringTagBoolPtr: + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + fallthrough + case opStructFieldAnonymousHeadStringTagBoolPtr: + p := load(ctxptr, code.idx) + if p == 0 { + code = code.end.next + break + } + b = append(b, code.escapedKey...) + p = ptrToPtr(p) + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = encodeBool(b, ptrToBool(p+code.offset)) + b = append(b, '"') + } + b = encodeComma(b) + code = code.next + case opStructFieldPtrAnonymousHeadBoolPtrOnly: + p := load(ctxptr, code.idx) + if p == 0 { + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldAnonymousHeadBoolPtrOnly: + p := load(ctxptr, code.idx) + b = append(b, code.escapedKey...) + if p == 0 { + b = encodeNull(b) + } else { + b = encodeBool(b, ptrToBool(p+code.offset)) + } + b = encodeComma(b) + code = code.next + case opStructFieldPtrAnonymousHeadOmitEmptyBoolPtrOnly: + p := load(ctxptr, code.idx) + if p == 0 { + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldAnonymousHeadOmitEmptyBoolPtrOnly: + p := load(ctxptr, code.idx) + if p == 0 { + code = code.nextField + } else { + b = append(b, code.escapedKey...) + b = encodeBool(b, ptrToBool(p+code.offset)) + b = encodeComma(b) + code = code.next + } + case opStructFieldPtrAnonymousHeadStringTagBoolPtrOnly: + p := load(ctxptr, code.idx) + if p == 0 { + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldAnonymousHeadStringTagBoolPtrOnly: + p := load(ctxptr, code.idx) + b = append(b, code.escapedKey...) + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = encodeBool(b, ptrToBool(p+code.offset)) + b = append(b, '"') + } + b = encodeComma(b) + code = code.next case opStructFieldPtrHeadBytes: p := load(ctxptr, code.idx) if p == 0 { @@ -6706,51 +7087,6 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o b = encodeComma(b) code = code.next } - case opStructFieldPtrHeadOmitEmptyBool: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadOmitEmptyBool: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - v := ptrToBool(ptr + code.offset) - if !v { - code = code.nextField - } else { - b = append(b, code.escapedKey...) - b = encodeBool(b, v) - b = encodeComma(b) - code = code.next - } - } - case opStructFieldPtrAnonymousHeadOmitEmptyBool: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldAnonymousHeadOmitEmptyBool: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - v := ptrToBool(ptr + code.offset) - if !v { - code = code.nextField - } else { - b = append(b, code.escapedKey...) - b = encodeBool(b, v) - b = encodeComma(b) - code = code.next - } - } case opStructFieldPtrHeadOmitEmptyBytes: ptr := load(ctxptr, code.idx) if ptr != 0 { @@ -6988,63 +7324,6 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o code = code.next store(ctxptr, code.idx, ptr+code.offset) } - case opStructFieldPtrHeadStringTagBool: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadStringTagBool: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - } else { - b = append(b, '{') - b = append(b, code.escapedKey...) - b = append(b, '"') - b = encodeBool(b, ptrToBool(ptr+code.offset)) - b = append(b, '"') - b = encodeComma(b) - code = code.next - } - case opStructFieldPtrHeadStringTagBoolOnly: - p := load(ctxptr, code.idx) - if p == 0 { - b = encodeNull(b) - b = encodeComma(b) - code = code.end.next - break - } - fallthrough - case opStructFieldHeadStringTagBoolOnly: - ptr := load(ctxptr, code.idx) - b = append(b, '{') - b = append(b, code.escapedKey...) - b = append(b, '"') - b = encodeBool(b, ptrToBool(ptr+code.offset)) - b = append(b, '"') - b = encodeComma(b) - code = code.next - case opStructFieldPtrAnonymousHeadStringTagBool: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldAnonymousHeadStringTagBool: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - code = code.end.next - } else { - b = append(b, code.escapedKey...) - b = append(b, '"') - b = encodeBool(b, ptrToBool(ptr+code.offset)) - b = append(b, '"') - b = encodeComma(b) - code = code.next - } case opStructFieldPtrHeadStringTagBytes: ptr := load(ctxptr, code.idx) if ptr != 0 { @@ -8063,7 +8342,9 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o if p == 0 { b = encodeNull(b) } else { + b = append(b, '"') b = encodeBool(b, ptrToBool(p)) + b = append(b, '"') } b = encodeComma(b) code = code.next @@ -9541,6 +9822,36 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o } b = appendStructEnd(b) code = code.next + case opStructEndOmitEmptyBoolPtr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = append(b, code.escapedKey...) + b = encodeBool(b, ptrToBool(p)) + b = appendStructEnd(b) + } else { + last := len(b) - 1 + if b[last] == ',' { + b[last] = '}' + b = encodeComma(b) + } else { + b = appendStructEnd(b) + } + } + code = code.next + case opStructEndStringTagBoolPtr: + b = append(b, code.escapedKey...) + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = encodeBool(b, ptrToBool(p)) + b = append(b, '"') + } + b = appendStructEnd(b) + code = code.next case opStructEndBytes: ptr := load(ctxptr, code.headIdx) b = append(b, code.escapedKey...) diff --git a/encode_vm_escaped_indent.go b/encode_vm_escaped_indent.go index 8674b46..472b3c1 100644 --- a/encode_vm_escaped_indent.go +++ b/encode_vm_escaped_indent.go @@ -6962,12 +6962,10 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode case opStructFieldHeadBool: ptr := load(ctxptr, code.idx) if ptr == 0 { - b = appendIndent(ctx, b, code.indent) b = encodeNull(b) b = encodeIndentComma(b) code = code.end.next } else { - b = appendIndent(ctx, b, code.indent) b = append(b, '{', '\n') b = appendIndent(ctx, b, code.indent+1) b = append(b, code.escapedKey...) @@ -6976,6 +6974,467 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = encodeIndentComma(b) code = code.next } + case opStructFieldPtrHeadOmitEmptyBool: + ptr := load(ctxptr, code.idx) + if ptr != 0 { + store(ctxptr, code.idx, ptrToPtr(ptr)) + } + fallthrough + case opStructFieldHeadOmitEmptyBool: + ptr := load(ctxptr, code.idx) + if ptr == 0 { + b = encodeNull(b) + b = encodeIndentComma(b) + code = code.end.next + } else { + b = append(b, '{', '\n') + v := ptrToBool(ptr + code.offset) + if v { + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.escapedKey...) + b = append(b, ' ') + b = encodeBool(b, v) + b = encodeIndentComma(b) + code = code.next + } else { + code = code.nextField + } + } + case opStructFieldPtrHeadStringTagBool: + ptr := load(ctxptr, code.idx) + if ptr != 0 { + store(ctxptr, code.idx, ptrToPtr(ptr)) + } + fallthrough + case opStructFieldHeadStringTagBool: + ptr := load(ctxptr, code.idx) + if ptr == 0 { + b = encodeNull(b) + b = encodeIndentComma(b) + code = code.end.next + } else { + b = append(b, '{', '\n') + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.escapedKey...) + b = append(b, ' ', '"') + b = encodeBool(b, ptrToBool(ptr+code.offset)) + b = append(b, '"') + b = encodeIndentComma(b) + code = code.next + } + case opStructFieldPtrHeadBoolOnly, opStructFieldHeadBoolOnly: + p := load(ctxptr, code.idx) + b = append(b, '{', '\n') + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.escapedKey...) + b = append(b, ' ') + b = encodeBool(b, ptrToBool(p)) + b = encodeIndentComma(b) + code = code.next + case opStructFieldPtrHeadOmitEmptyBoolOnly, opStructFieldHeadOmitEmptyBoolOnly: + p := load(ctxptr, code.idx) + b = append(b, '{', '\n') + v := ptrToBool(p) + if v { + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.escapedKey...) + b = append(b, ' ') + b = encodeBool(b, v) + b = encodeIndentComma(b) + } + code = code.next + case opStructFieldPtrHeadStringTagBoolOnly, opStructFieldHeadStringTagBoolOnly: + p := load(ctxptr, code.idx) + b = append(b, '{', '\n') + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.escapedKey...) + b = append(b, ' ', '"') + b = encodeBool(b, ptrToBool(p)) + b = append(b, '"') + b = encodeIndentComma(b) + code = code.next + case opStructFieldPtrHeadBoolPtr: + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + fallthrough + case opStructFieldHeadBoolPtr: + p := load(ctxptr, code.idx) + if p == 0 { + b = encodeNull(b) + b = encodeIndentComma(b) + code = code.end.next + break + } else { + b = append(b, '{', '\n') + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.escapedKey...) + b = append(b, ' ') + p = ptrToPtr(p) + if p == 0 { + b = encodeNull(b) + } else { + b = encodeBool(b, ptrToBool(p+code.offset)) + } + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldPtrHeadOmitEmptyBoolPtr: + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + fallthrough + case opStructFieldHeadOmitEmptyBoolPtr: + p := load(ctxptr, code.idx) + if p == 0 { + b = encodeNull(b) + b = encodeIndentComma(b) + code = code.end.next + } else { + b = append(b, '{', '\n') + p = ptrToPtr(p) + if p != 0 { + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.escapedKey...) + b = append(b, ' ') + b = encodeBool(b, ptrToBool(p)) + b = encodeIndentComma(b) + } + code = code.next + } + case opStructFieldPtrHeadStringTagBoolPtr: + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + fallthrough + case opStructFieldHeadStringTagBoolPtr: + p := load(ctxptr, code.idx) + if p == 0 { + b = encodeNull(b) + b = encodeIndentComma(b) + code = code.end.next + break + } else { + b = append(b, '{', '\n') + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.escapedKey...) + b = append(b, ' ') + p = ptrToPtr(p) + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = encodeBool(b, ptrToBool(p+code.offset)) + b = append(b, '"') + } + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldPtrHeadBoolPtrOnly: + p := load(ctxptr, code.idx) + if p == 0 { + b = encodeNull(b) + b = encodeIndentComma(b) + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadBoolPtrOnly: + p := load(ctxptr, code.idx) + b = append(b, '{', '\n') + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.escapedKey...) + b = append(b, ' ') + if p == 0 { + b = encodeNull(b) + } else { + b = encodeBool(b, ptrToBool(p+code.offset)) + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldPtrHeadOmitEmptyBoolPtrOnly: + p := load(ctxptr, code.idx) + if p == 0 { + b = encodeNull(b) + b = encodeIndentComma(b) + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadOmitEmptyBoolPtrOnly: + p := load(ctxptr, code.idx) + b = append(b, '{', '\n') + if p != 0 { + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.escapedKey...) + b = append(b, ' ') + b = encodeBool(b, ptrToBool(p+code.offset)) + b = encodeIndentComma(b) + } + code = code.next + case opStructFieldPtrHeadStringTagBoolPtrOnly: + p := load(ctxptr, code.idx) + if p == 0 { + b = encodeNull(b) + b = encodeIndentComma(b) + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadStringTagBoolPtrOnly: + p := load(ctxptr, code.idx) + b = append(b, '{', '\n') + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.escapedKey...) + b = append(b, ' ') + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = encodeBool(b, ptrToBool(p+code.offset)) + b = append(b, '"') + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldHeadBoolNPtr: + p := load(ctxptr, code.idx) + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '{', '\n') + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.escapedKey...) + b = append(b, ' ') + for i := 0; i < code.ptrNum; i++ { + if p == 0 { + break + } + p = ptrToPtr(p) + } + if p == 0 { + b = encodeNull(b) + } else { + b = encodeBool(b, ptrToBool(p+code.offset)) + } + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldPtrAnonymousHeadBool: + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + fallthrough + case opStructFieldAnonymousHeadBool: + ptr := load(ctxptr, code.idx) + if ptr == 0 { + code = code.end.next + } else { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + b = encodeBool(b, ptrToBool(ptr+code.offset)) + b = encodeIndentComma(b) + code = code.next + } + case opStructFieldPtrAnonymousHeadOmitEmptyBool: + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + fallthrough + case opStructFieldAnonymousHeadOmitEmptyBool: + ptr := load(ctxptr, code.idx) + if ptr == 0 { + code = code.end.next + } else { + v := ptrToBool(ptr + code.offset) + if v { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + b = encodeBool(b, v) + b = encodeIndentComma(b) + code = code.next + } else { + code = code.nextField + } + } + case opStructFieldPtrAnonymousHeadStringTagBool: + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + fallthrough + case opStructFieldAnonymousHeadStringTagBool: + ptr := load(ctxptr, code.idx) + if ptr == 0 { + code = code.end.next + } else { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + b = append(b, '"') + b = encodeBool(b, ptrToBool(ptr+code.offset)) + b = append(b, '"') + b = encodeIndentComma(b) + code = code.next + } + case opStructFieldPtrAnonymousHeadBoolOnly, opStructFieldAnonymousHeadBoolOnly: + ptr := load(ctxptr, code.idx) + if ptr == 0 { + code = code.end.next + } else { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + b = encodeBool(b, ptrToBool(ptr+code.offset)) + b = encodeIndentComma(b) + code = code.next + } + case opStructFieldPtrAnonymousHeadOmitEmptyBoolOnly, opStructFieldAnonymousHeadOmitEmptyBoolOnly: + ptr := load(ctxptr, code.idx) + if ptr == 0 { + code = code.end.next + } else { + v := ptrToBool(ptr + code.offset) + if v { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + b = encodeBool(b, v) + b = encodeIndentComma(b) + code = code.next + } else { + code = code.nextField + } + } + case opStructFieldPtrAnonymousHeadStringTagBoolOnly, opStructFieldAnonymousHeadStringTagBoolOnly: + ptr := load(ctxptr, code.idx) + if ptr == 0 { + code = code.end.next + } else { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + b = append(b, '"') + b = encodeBool(b, ptrToBool(ptr+code.offset)) + b = append(b, '"') + b = encodeIndentComma(b) + code = code.next + } + case opStructFieldPtrAnonymousHeadBoolPtr: + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + fallthrough + case opStructFieldAnonymousHeadBoolPtr: + p := load(ctxptr, code.idx) + if p == 0 { + code = code.end.next + break + } + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + p = ptrToPtr(p) + if p == 0 { + b = encodeNull(b) + } else { + b = encodeBool(b, ptrToBool(p+code.offset)) + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldPtrAnonymousHeadOmitEmptyBoolPtr: + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + fallthrough + case opStructFieldAnonymousHeadOmitEmptyBoolPtr: + p := load(ctxptr, code.idx) + if p == 0 { + code = code.end.next + break + } + p = ptrToPtr(p) + if p == 0 { + code = code.nextField + } else { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + b = encodeBool(b, ptrToBool(p)) + b = encodeIndentComma(b) + code = code.next + } + case opStructFieldPtrAnonymousHeadStringTagBoolPtr: + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + fallthrough + case opStructFieldAnonymousHeadStringTagBoolPtr: + p := load(ctxptr, code.idx) + if p == 0 { + code = code.end.next + break + } + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + p = ptrToPtr(p) + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = encodeBool(b, ptrToBool(p+code.offset)) + b = append(b, '"') + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldPtrAnonymousHeadBoolPtrOnly: + p := load(ctxptr, code.idx) + if p == 0 { + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldAnonymousHeadBoolPtrOnly: + p := load(ctxptr, code.idx) + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + if p == 0 { + b = encodeNull(b) + } else { + b = encodeBool(b, ptrToBool(p+code.offset)) + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldPtrAnonymousHeadOmitEmptyBoolPtrOnly: + p := load(ctxptr, code.idx) + if p == 0 { + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldAnonymousHeadOmitEmptyBoolPtrOnly: + p := load(ctxptr, code.idx) + if p == 0 { + code = code.nextField + } else { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + b = encodeBool(b, ptrToBool(p+code.offset)) + b = encodeIndentComma(b) + code = code.next + } + case opStructFieldPtrAnonymousHeadStringTagBoolPtrOnly: + p := load(ctxptr, code.idx) + if p == 0 { + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldAnonymousHeadStringTagBoolPtrOnly: + p := load(ctxptr, code.idx) + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = encodeBool(b, ptrToBool(p+code.offset)) + b = append(b, '"') + } + b = encodeIndentComma(b) + code = code.next case opStructFieldPtrHeadBytes: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -6996,34 +7455,6 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = encodeIndentComma(b) code = code.next } - case opStructFieldPtrHeadOmitEmptyBool: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadOmitEmptyBool: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = appendIndent(ctx, b, code.indent) - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, '{', '\n') - v := ptrToBool(ptr + code.offset) - if !v { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ') - b = encodeBool(b, v) - b = encodeIndentComma(b) - code = code.next - } - } case opStructFieldPtrHeadOmitEmptyBytes: ptr := load(ctxptr, code.idx) if ptr != 0 { @@ -7073,29 +7504,6 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode code = code.next store(ctxptr, code.idx, p) } - case opStructFieldPtrHeadStringTagBool: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadStringTagBool: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = appendIndent(ctx, b, code.indent) - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.escapedKey...) - b = append(b, ' ', '"') - b = encodeBool(b, ptrToBool(ptr+code.offset)) - b = append(b, '"') - b = encodeIndentComma(b) - code = code.next - } case opStructFieldPtrHeadStringTagBytes: ptr := load(ctxptr, code.idx) if ptr != 0 { @@ -8099,7 +8507,9 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode if p == 0 { b = encodeNull(b) } else { + b = append(b, '"') b = encodeBool(b, ptrToBool(p)) + b = append(b, '"') } b = encodeIndentComma(b) code = code.next @@ -8444,7 +8854,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -8491,7 +8901,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -8539,7 +8949,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -8586,7 +8996,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -8634,7 +9044,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -8681,7 +9091,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -8729,7 +9139,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -8776,7 +9186,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -8824,7 +9234,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -8871,7 +9281,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -8919,7 +9329,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -8966,7 +9376,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -9014,7 +9424,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -9061,7 +9471,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -9109,7 +9519,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -9156,7 +9566,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -9204,7 +9614,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -9251,7 +9661,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -9299,7 +9709,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -9346,7 +9756,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -9394,7 +9804,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -9441,7 +9851,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -9496,7 +9906,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -9555,7 +9965,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -9607,7 +10017,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -9654,7 +10064,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -9700,7 +10110,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -9715,6 +10125,59 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = append(b, '"') b = appendStructEndIndent(ctx, b, code.indent-1) code = code.next + case opStructEndBoolPtr: + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + b = encodeBool(b, ptrToBool(p)) + } + b = appendStructEndIndent(ctx, b, code.indent-1) + code = code.next + case opStructEndOmitEmptyBoolPtr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + b = encodeBool(b, ptrToBool(p)) + b = appendStructEndIndent(ctx, b, code.indent-1) + } else { + last := len(b) - 1 + if b[last-1] == '{' { + b[last] = '}' + } else { + if b[last] == '\n' { + // to remove ',' and '\n' characters + b = b[:len(b)-2] + } + b = append(b, '\n') + b = appendIndent(ctx, b, code.indent-1) + b = append(b, '}') + } + b = encodeIndentComma(b) + } + code = code.next + case opStructEndStringTagBoolPtr: + b = appendIndent(ctx, b, code.indent) + b = append(b, code.escapedKey...) + b = append(b, ' ') + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = encodeBool(b, ptrToBool(p)) + b = append(b, '"') + } + b = appendStructEndIndent(ctx, b, code.indent-1) + code = code.next case opStructEndBytes: b = appendIndent(ctx, b, code.indent) b = append(b, code.escapedKey...) @@ -9742,7 +10205,7 @@ func encodeRunEscapedIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcode b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) diff --git a/encode_vm_indent.go b/encode_vm_indent.go index 231060e..a88918d 100644 --- a/encode_vm_indent.go +++ b/encode_vm_indent.go @@ -6962,12 +6962,10 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op case opStructFieldHeadBool: ptr := load(ctxptr, code.idx) if ptr == 0 { - b = appendIndent(ctx, b, code.indent) b = encodeNull(b) b = encodeIndentComma(b) code = code.end.next } else { - b = appendIndent(ctx, b, code.indent) b = append(b, '{', '\n') b = appendIndent(ctx, b, code.indent+1) b = append(b, code.key...) @@ -6976,6 +6974,467 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = encodeIndentComma(b) code = code.next } + case opStructFieldPtrHeadOmitEmptyBool: + ptr := load(ctxptr, code.idx) + if ptr != 0 { + store(ctxptr, code.idx, ptrToPtr(ptr)) + } + fallthrough + case opStructFieldHeadOmitEmptyBool: + ptr := load(ctxptr, code.idx) + if ptr == 0 { + b = encodeNull(b) + b = encodeIndentComma(b) + code = code.end.next + } else { + b = append(b, '{', '\n') + v := ptrToBool(ptr + code.offset) + if v { + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.key...) + b = append(b, ' ') + b = encodeBool(b, v) + b = encodeIndentComma(b) + code = code.next + } else { + code = code.nextField + } + } + case opStructFieldPtrHeadStringTagBool: + ptr := load(ctxptr, code.idx) + if ptr != 0 { + store(ctxptr, code.idx, ptrToPtr(ptr)) + } + fallthrough + case opStructFieldHeadStringTagBool: + ptr := load(ctxptr, code.idx) + if ptr == 0 { + b = encodeNull(b) + b = encodeIndentComma(b) + code = code.end.next + } else { + b = append(b, '{', '\n') + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.key...) + b = append(b, ' ', '"') + b = encodeBool(b, ptrToBool(ptr+code.offset)) + b = append(b, '"') + b = encodeIndentComma(b) + code = code.next + } + case opStructFieldPtrHeadBoolOnly, opStructFieldHeadBoolOnly: + p := load(ctxptr, code.idx) + b = append(b, '{', '\n') + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.key...) + b = append(b, ' ') + b = encodeBool(b, ptrToBool(p)) + b = encodeIndentComma(b) + code = code.next + case opStructFieldPtrHeadOmitEmptyBoolOnly, opStructFieldHeadOmitEmptyBoolOnly: + p := load(ctxptr, code.idx) + b = append(b, '{', '\n') + v := ptrToBool(p) + if v { + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.key...) + b = append(b, ' ') + b = encodeBool(b, v) + b = encodeIndentComma(b) + } + code = code.next + case opStructFieldPtrHeadStringTagBoolOnly, opStructFieldHeadStringTagBoolOnly: + p := load(ctxptr, code.idx) + b = append(b, '{', '\n') + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.key...) + b = append(b, ' ', '"') + b = encodeBool(b, ptrToBool(p)) + b = append(b, '"') + b = encodeIndentComma(b) + code = code.next + case opStructFieldPtrHeadBoolPtr: + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + fallthrough + case opStructFieldHeadBoolPtr: + p := load(ctxptr, code.idx) + if p == 0 { + b = encodeNull(b) + b = encodeIndentComma(b) + code = code.end.next + break + } else { + b = append(b, '{', '\n') + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.key...) + b = append(b, ' ') + p = ptrToPtr(p) + if p == 0 { + b = encodeNull(b) + } else { + b = encodeBool(b, ptrToBool(p+code.offset)) + } + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldPtrHeadOmitEmptyBoolPtr: + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + fallthrough + case opStructFieldHeadOmitEmptyBoolPtr: + p := load(ctxptr, code.idx) + if p == 0 { + b = encodeNull(b) + b = encodeIndentComma(b) + code = code.end.next + } else { + b = append(b, '{', '\n') + p = ptrToPtr(p) + if p != 0 { + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.key...) + b = append(b, ' ') + b = encodeBool(b, ptrToBool(p)) + b = encodeIndentComma(b) + } + code = code.next + } + case opStructFieldPtrHeadStringTagBoolPtr: + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + fallthrough + case opStructFieldHeadStringTagBoolPtr: + p := load(ctxptr, code.idx) + if p == 0 { + b = encodeNull(b) + b = encodeIndentComma(b) + code = code.end.next + break + } else { + b = append(b, '{', '\n') + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.key...) + b = append(b, ' ') + p = ptrToPtr(p) + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = encodeBool(b, ptrToBool(p+code.offset)) + b = append(b, '"') + } + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldPtrHeadBoolPtrOnly: + p := load(ctxptr, code.idx) + if p == 0 { + b = encodeNull(b) + b = encodeIndentComma(b) + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadBoolPtrOnly: + p := load(ctxptr, code.idx) + b = append(b, '{', '\n') + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.key...) + b = append(b, ' ') + if p == 0 { + b = encodeNull(b) + } else { + b = encodeBool(b, ptrToBool(p+code.offset)) + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldPtrHeadOmitEmptyBoolPtrOnly: + p := load(ctxptr, code.idx) + if p == 0 { + b = encodeNull(b) + b = encodeIndentComma(b) + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadOmitEmptyBoolPtrOnly: + p := load(ctxptr, code.idx) + b = append(b, '{', '\n') + if p != 0 { + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.key...) + b = append(b, ' ') + b = encodeBool(b, ptrToBool(p+code.offset)) + b = encodeIndentComma(b) + } + code = code.next + case opStructFieldPtrHeadStringTagBoolPtrOnly: + p := load(ctxptr, code.idx) + if p == 0 { + b = encodeNull(b) + b = encodeIndentComma(b) + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldHeadStringTagBoolPtrOnly: + p := load(ctxptr, code.idx) + b = append(b, '{', '\n') + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.key...) + b = append(b, ' ') + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = encodeBool(b, ptrToBool(p+code.offset)) + b = append(b, '"') + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldHeadBoolNPtr: + p := load(ctxptr, code.idx) + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '{', '\n') + b = appendIndent(ctx, b, code.indent+1) + b = append(b, code.key...) + b = append(b, ' ') + for i := 0; i < code.ptrNum; i++ { + if p == 0 { + break + } + p = ptrToPtr(p) + } + if p == 0 { + b = encodeNull(b) + } else { + b = encodeBool(b, ptrToBool(p+code.offset)) + } + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldPtrAnonymousHeadBool: + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + fallthrough + case opStructFieldAnonymousHeadBool: + ptr := load(ctxptr, code.idx) + if ptr == 0 { + code = code.end.next + } else { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + b = encodeBool(b, ptrToBool(ptr+code.offset)) + b = encodeIndentComma(b) + code = code.next + } + case opStructFieldPtrAnonymousHeadOmitEmptyBool: + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + fallthrough + case opStructFieldAnonymousHeadOmitEmptyBool: + ptr := load(ctxptr, code.idx) + if ptr == 0 { + code = code.end.next + } else { + v := ptrToBool(ptr + code.offset) + if v { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + b = encodeBool(b, v) + b = encodeIndentComma(b) + code = code.next + } else { + code = code.nextField + } + } + case opStructFieldPtrAnonymousHeadStringTagBool: + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + fallthrough + case opStructFieldAnonymousHeadStringTagBool: + ptr := load(ctxptr, code.idx) + if ptr == 0 { + code = code.end.next + } else { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + b = append(b, '"') + b = encodeBool(b, ptrToBool(ptr+code.offset)) + b = append(b, '"') + b = encodeIndentComma(b) + code = code.next + } + case opStructFieldPtrAnonymousHeadBoolOnly, opStructFieldAnonymousHeadBoolOnly: + ptr := load(ctxptr, code.idx) + if ptr == 0 { + code = code.end.next + } else { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + b = encodeBool(b, ptrToBool(ptr+code.offset)) + b = encodeIndentComma(b) + code = code.next + } + case opStructFieldPtrAnonymousHeadOmitEmptyBoolOnly, opStructFieldAnonymousHeadOmitEmptyBoolOnly: + ptr := load(ctxptr, code.idx) + if ptr == 0 { + code = code.end.next + } else { + v := ptrToBool(ptr + code.offset) + if v { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + b = encodeBool(b, v) + b = encodeIndentComma(b) + code = code.next + } else { + code = code.nextField + } + } + case opStructFieldPtrAnonymousHeadStringTagBoolOnly, opStructFieldAnonymousHeadStringTagBoolOnly: + ptr := load(ctxptr, code.idx) + if ptr == 0 { + code = code.end.next + } else { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + b = append(b, '"') + b = encodeBool(b, ptrToBool(ptr+code.offset)) + b = append(b, '"') + b = encodeIndentComma(b) + code = code.next + } + case opStructFieldPtrAnonymousHeadBoolPtr: + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + fallthrough + case opStructFieldAnonymousHeadBoolPtr: + p := load(ctxptr, code.idx) + if p == 0 { + code = code.end.next + break + } + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + p = ptrToPtr(p) + if p == 0 { + b = encodeNull(b) + } else { + b = encodeBool(b, ptrToBool(p+code.offset)) + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldPtrAnonymousHeadOmitEmptyBoolPtr: + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + fallthrough + case opStructFieldAnonymousHeadOmitEmptyBoolPtr: + p := load(ctxptr, code.idx) + if p == 0 { + code = code.end.next + break + } + p = ptrToPtr(p) + if p == 0 { + code = code.nextField + } else { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + b = encodeBool(b, ptrToBool(p)) + b = encodeIndentComma(b) + code = code.next + } + case opStructFieldPtrAnonymousHeadStringTagBoolPtr: + store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) + fallthrough + case opStructFieldAnonymousHeadStringTagBoolPtr: + p := load(ctxptr, code.idx) + if p == 0 { + code = code.end.next + break + } + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + p = ptrToPtr(p) + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = encodeBool(b, ptrToBool(p+code.offset)) + b = append(b, '"') + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldPtrAnonymousHeadBoolPtrOnly: + p := load(ctxptr, code.idx) + if p == 0 { + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldAnonymousHeadBoolPtrOnly: + p := load(ctxptr, code.idx) + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + if p == 0 { + b = encodeNull(b) + } else { + b = encodeBool(b, ptrToBool(p+code.offset)) + } + b = encodeIndentComma(b) + code = code.next + case opStructFieldPtrAnonymousHeadOmitEmptyBoolPtrOnly: + p := load(ctxptr, code.idx) + if p == 0 { + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldAnonymousHeadOmitEmptyBoolPtrOnly: + p := load(ctxptr, code.idx) + if p == 0 { + code = code.nextField + } else { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + b = encodeBool(b, ptrToBool(p+code.offset)) + b = encodeIndentComma(b) + code = code.next + } + case opStructFieldPtrAnonymousHeadStringTagBoolPtrOnly: + p := load(ctxptr, code.idx) + if p == 0 { + code = code.end.next + break + } + store(ctxptr, code.idx, ptrToPtr(p)) + fallthrough + case opStructFieldAnonymousHeadStringTagBoolPtrOnly: + p := load(ctxptr, code.idx) + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = encodeBool(b, ptrToBool(p+code.offset)) + b = append(b, '"') + } + b = encodeIndentComma(b) + code = code.next case opStructFieldPtrHeadBytes: store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx))) fallthrough @@ -6996,34 +7455,6 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = encodeIndentComma(b) code = code.next } - case opStructFieldPtrHeadOmitEmptyBool: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadOmitEmptyBool: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = appendIndent(ctx, b, code.indent) - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - b = appendIndent(ctx, b, code.indent) - b = append(b, '{', '\n') - v := ptrToBool(ptr + code.offset) - if !v { - code = code.nextField - } else { - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ') - b = encodeBool(b, v) - b = encodeIndentComma(b) - code = code.next - } - } case opStructFieldPtrHeadOmitEmptyBytes: ptr := load(ctxptr, code.idx) if ptr != 0 { @@ -7073,29 +7504,6 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op code = code.next store(ctxptr, code.idx, p) } - case opStructFieldPtrHeadStringTagBool: - ptr := load(ctxptr, code.idx) - if ptr != 0 { - store(ctxptr, code.idx, ptrToPtr(ptr)) - } - fallthrough - case opStructFieldHeadStringTagBool: - ptr := load(ctxptr, code.idx) - if ptr == 0 { - b = appendIndent(ctx, b, code.indent) - b = encodeNull(b) - b = encodeIndentComma(b) - code = code.end.next - } else { - b = append(b, '{', '\n') - b = appendIndent(ctx, b, code.indent+1) - b = append(b, code.key...) - b = append(b, ' ', '"') - b = encodeBool(b, ptrToBool(ptr+code.offset)) - b = append(b, '"') - b = encodeIndentComma(b) - code = code.next - } case opStructFieldPtrHeadStringTagBytes: ptr := load(ctxptr, code.idx) if ptr != 0 { @@ -8099,7 +8507,9 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op if p == 0 { b = encodeNull(b) } else { + b = append(b, '"') b = encodeBool(b, ptrToBool(p)) + b = append(b, '"') } b = encodeIndentComma(b) code = code.next @@ -8443,7 +8853,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -8490,7 +8900,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -8538,7 +8948,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -8585,7 +8995,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -8633,7 +9043,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -8680,7 +9090,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -8728,7 +9138,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -8775,7 +9185,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -8823,7 +9233,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -8870,7 +9280,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -8918,7 +9328,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -8965,7 +9375,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -9013,7 +9423,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -9060,7 +9470,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -9108,7 +9518,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -9155,7 +9565,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -9203,7 +9613,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -9250,7 +9660,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -9298,7 +9708,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -9345,7 +9755,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -9393,7 +9803,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -9440,7 +9850,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -9495,7 +9905,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -9554,7 +9964,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -9606,7 +10016,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -9653,7 +10063,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -9699,7 +10109,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b) @@ -9714,6 +10124,59 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = append(b, '"') b = appendStructEndIndent(ctx, b, code.indent-1) code = code.next + case opStructEndBoolPtr: + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + b = encodeBool(b, ptrToBool(p)) + } + b = appendStructEndIndent(ctx, b, code.indent-1) + code = code.next + case opStructEndOmitEmptyBoolPtr: + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p != 0 { + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + b = encodeBool(b, ptrToBool(p)) + b = appendStructEndIndent(ctx, b, code.indent-1) + } else { + last := len(b) - 1 + if b[last-1] == '{' { + b[last] = '}' + } else { + if b[last] == '\n' { + // to remove ',' and '\n' characters + b = b[:len(b)-2] + } + b = append(b, '\n') + b = appendIndent(ctx, b, code.indent-1) + b = append(b, '}') + } + b = encodeIndentComma(b) + } + code = code.next + case opStructEndStringTagBoolPtr: + b = appendIndent(ctx, b, code.indent) + b = append(b, code.key...) + b = append(b, ' ') + ptr := load(ctxptr, code.headIdx) + p := ptrToPtr(ptr + code.offset) + if p == 0 { + b = encodeNull(b) + } else { + b = append(b, '"') + b = encodeBool(b, ptrToBool(p)) + b = append(b, '"') + } + b = appendStructEndIndent(ctx, b, code.indent-1) + code = code.next case opStructEndBytes: b = appendIndent(ctx, b, code.indent) b = append(b, code.key...) @@ -9741,7 +10204,7 @@ func encodeRunIndent(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, op b = b[:len(b)-2] } b = append(b, '\n') - b = appendIndent(ctx, b, code.indent) + b = appendIndent(ctx, b, code.indent-1) b = append(b, '}') } b = encodeIndentComma(b)