2021-01-16 16:16:26 +03:00
|
|
|
package json_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"strings"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/goccy/go-json"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestCoverUint(t *testing.T) {
|
|
|
|
type structUint struct {
|
|
|
|
A uint `json:"a"`
|
|
|
|
}
|
2021-01-19 08:54:27 +03:00
|
|
|
type structUintOmitEmpty struct {
|
|
|
|
A uint `json:"a,omitempty"`
|
|
|
|
}
|
|
|
|
type structUintString struct {
|
|
|
|
A uint `json:"a,string"`
|
|
|
|
}
|
|
|
|
|
2021-01-16 16:16:26 +03:00
|
|
|
type structUintPtr struct {
|
|
|
|
A *uint `json:"a"`
|
|
|
|
}
|
2021-01-19 08:54:27 +03:00
|
|
|
type structUintPtrOmitEmpty struct {
|
|
|
|
A *uint `json:"a,omitempty"`
|
|
|
|
}
|
|
|
|
type structUintPtrString struct {
|
|
|
|
A *uint `json:"a,string"`
|
|
|
|
}
|
2021-01-16 16:16:26 +03:00
|
|
|
|
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
expected string
|
|
|
|
indentExpected string
|
|
|
|
data interface{}
|
|
|
|
}{
|
2021-01-19 08:54:27 +03:00
|
|
|
// HeadUintZero
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "HeadUintZero",
|
|
|
|
expected: `{"a":0}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 0
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A uint `json:"a"`
|
|
|
|
}{},
|
|
|
|
},
|
2021-01-19 08:54:27 +03:00
|
|
|
{
|
|
|
|
name: "HeadUintZeroOmitEmpty",
|
|
|
|
expected: `{}`,
|
|
|
|
indentExpected: `
|
|
|
|
{}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A uint `json:"a,omitempty"`
|
|
|
|
}{},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "HeadUintZeroString",
|
|
|
|
expected: `{"a":"0"}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": "0"
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A uint `json:"a,string"`
|
|
|
|
}{},
|
|
|
|
},
|
|
|
|
|
|
|
|
// HeadUint
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "HeadUint",
|
|
|
|
expected: `{"a":1}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A uint `json:"a"`
|
|
|
|
}{A: 1},
|
|
|
|
},
|
2021-01-19 08:54:27 +03:00
|
|
|
{
|
|
|
|
name: "HeadUintOmitEmpty",
|
|
|
|
expected: `{"a":1}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A uint `json:"a,omitempty"`
|
|
|
|
}{A: 1},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "HeadUintString",
|
|
|
|
expected: `{"a":"1"}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": "1"
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A uint `json:"a,string"`
|
|
|
|
}{A: 1},
|
|
|
|
},
|
|
|
|
|
|
|
|
// HeadUintPtr
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "HeadUintPtr",
|
|
|
|
expected: `{"a":1}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A *uint `json:"a"`
|
|
|
|
}{A: uptr(1)},
|
|
|
|
},
|
2021-01-19 08:54:27 +03:00
|
|
|
{
|
|
|
|
name: "HeadUintPtrOmitEmpty",
|
|
|
|
expected: `{"a":1}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A *uint `json:"a,omitempty"`
|
|
|
|
}{A: uptr(1)},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "HeadUintPtrString",
|
|
|
|
expected: `{"a":"1"}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": "1"
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A *uint `json:"a,string"`
|
|
|
|
}{A: uptr(1)},
|
|
|
|
},
|
|
|
|
|
|
|
|
// HeadUintPtrNil
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "HeadUintPtrNil",
|
|
|
|
expected: `{"a":null}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": null
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A *uint `json:"a"`
|
|
|
|
}{A: nil},
|
|
|
|
},
|
2021-01-19 08:54:27 +03:00
|
|
|
{
|
|
|
|
name: "HeadUintPtrNilOmitEmpty",
|
|
|
|
expected: `{}`,
|
|
|
|
indentExpected: `
|
|
|
|
{}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A *uint `json:"a,omitempty"`
|
|
|
|
}{A: nil},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "HeadUintPtrNilString",
|
|
|
|
expected: `{"a":null}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": null
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A *uint `json:"a,string"`
|
|
|
|
}{A: nil},
|
|
|
|
},
|
|
|
|
|
|
|
|
// PtrHeadUintZero
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "PtrHeadUintZero",
|
|
|
|
expected: `{"a":0}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 0
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A uint `json:"a"`
|
|
|
|
}{},
|
|
|
|
},
|
2021-01-19 08:54:27 +03:00
|
|
|
{
|
|
|
|
name: "PtrHeadUintZeroOmitEmpty",
|
|
|
|
expected: `{}`,
|
|
|
|
indentExpected: `
|
|
|
|
{}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A uint `json:"a,omitempty"`
|
|
|
|
}{},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadUintZeroString",
|
|
|
|
expected: `{"a":"0"}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": "0"
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A uint `json:"a,string"`
|
|
|
|
}{},
|
|
|
|
},
|
|
|
|
|
|
|
|
// PtrHeadUint
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "PtrHeadUint",
|
|
|
|
expected: `{"a":1}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A uint `json:"a"`
|
|
|
|
}{A: 1},
|
|
|
|
},
|
2021-01-19 08:54:27 +03:00
|
|
|
{
|
|
|
|
name: "PtrHeadUintOmitEmpty",
|
|
|
|
expected: `{"a":1}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A uint `json:"a,omitempty"`
|
|
|
|
}{A: 1},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadUintString",
|
|
|
|
expected: `{"a":"1"}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": "1"
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A uint `json:"a,string"`
|
|
|
|
}{A: 1},
|
|
|
|
},
|
|
|
|
|
|
|
|
// PtrHeadUintPtr
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "PtrHeadUintPtr",
|
|
|
|
expected: `{"a":1}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A *uint `json:"a"`
|
|
|
|
}{A: uptr(1)},
|
|
|
|
},
|
2021-01-19 08:54:27 +03:00
|
|
|
{
|
|
|
|
name: "PtrHeadUintPtrOmitEmpty",
|
|
|
|
expected: `{"a":1}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A *uint `json:"a,omitempty"`
|
|
|
|
}{A: uptr(1)},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadUintPtrString",
|
|
|
|
expected: `{"a":"1"}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": "1"
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A *uint `json:"a,string"`
|
|
|
|
}{A: uptr(1)},
|
|
|
|
},
|
|
|
|
|
|
|
|
// PtrHeadUintPtrNil
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "PtrHeadUintPtrNil",
|
|
|
|
expected: `{"a":null}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": null
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A *uint `json:"a"`
|
|
|
|
}{A: nil},
|
|
|
|
},
|
2021-01-19 08:54:27 +03:00
|
|
|
{
|
|
|
|
name: "PtrHeadUintPtrNilOmitEmpty",
|
|
|
|
expected: `{}`,
|
|
|
|
indentExpected: `
|
|
|
|
{}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A *uint `json:"a,omitempty"`
|
|
|
|
}{A: nil},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadUintPtrNilString",
|
|
|
|
expected: `{"a":null}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": null
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A *uint `json:"a,string"`
|
|
|
|
}{A: nil},
|
|
|
|
},
|
|
|
|
|
|
|
|
// PtrHeadUintNil
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "PtrHeadUintNil",
|
|
|
|
expected: `null`,
|
|
|
|
indentExpected: `
|
|
|
|
null
|
|
|
|
`,
|
|
|
|
data: (*struct {
|
|
|
|
A *uint `json:"a"`
|
|
|
|
})(nil),
|
|
|
|
},
|
2021-01-19 08:54:27 +03:00
|
|
|
{
|
|
|
|
name: "PtrHeadUintNilOmitEmpty",
|
|
|
|
expected: `null`,
|
|
|
|
indentExpected: `
|
|
|
|
null
|
|
|
|
`,
|
|
|
|
data: (*struct {
|
|
|
|
A *uint `json:"a,omitempty"`
|
|
|
|
})(nil),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadUintNilString",
|
|
|
|
expected: `null`,
|
|
|
|
indentExpected: `
|
|
|
|
null
|
|
|
|
`,
|
|
|
|
data: (*struct {
|
|
|
|
A *uint `json:"a,string"`
|
|
|
|
})(nil),
|
|
|
|
},
|
|
|
|
|
|
|
|
// HeadUintZeroMultiFields
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "HeadUintZeroMultiFields",
|
|
|
|
expected: `{"a":0,"b":0}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 0,
|
|
|
|
"b": 0
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A uint `json:"a"`
|
|
|
|
B uint `json:"b"`
|
|
|
|
}{},
|
|
|
|
},
|
2021-01-19 08:54:27 +03:00
|
|
|
{
|
|
|
|
name: "HeadUintZeroMultiFieldsOmitEmpty",
|
|
|
|
expected: `{}`,
|
|
|
|
indentExpected: `
|
|
|
|
{}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A uint `json:"a,omitempty"`
|
|
|
|
B uint `json:"b,omitempty"`
|
|
|
|
}{},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "HeadUintZeroMultiFields",
|
|
|
|
expected: `{"a":"0","b":"0"}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": "0",
|
|
|
|
"b": "0"
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A uint `json:"a,string"`
|
|
|
|
B uint `json:"b,string"`
|
|
|
|
}{},
|
|
|
|
},
|
|
|
|
|
|
|
|
// HeadUintMultiFields
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "HeadUintMultiFields",
|
|
|
|
expected: `{"a":1,"b":2}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1,
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A uint `json:"a"`
|
|
|
|
B uint `json:"b"`
|
|
|
|
}{A: 1, B: 2},
|
|
|
|
},
|
|
|
|
{
|
2021-01-19 08:54:27 +03:00
|
|
|
name: "HeadUintMultiFieldsOmitEmpty",
|
2021-01-16 16:16:26 +03:00
|
|
|
expected: `{"a":1,"b":2}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1,
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
2021-01-19 08:54:27 +03:00
|
|
|
A uint `json:"a,omitempty"`
|
|
|
|
B uint `json:"b,omitempty"`
|
|
|
|
}{A: 1, B: 2},
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
|
|
|
{
|
2021-01-19 08:54:27 +03:00
|
|
|
name: "HeadUintMultiFieldsString",
|
|
|
|
expected: `{"a":"1","b":"2"}`,
|
2021-01-16 16:16:26 +03:00
|
|
|
indentExpected: `
|
|
|
|
{
|
2021-01-19 08:54:27 +03:00
|
|
|
"a": "1",
|
|
|
|
"b": "2"
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
2021-01-19 08:54:27 +03:00
|
|
|
A uint `json:"a,string"`
|
|
|
|
B uint `json:"b,string"`
|
|
|
|
}{A: 1, B: 2},
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
2021-01-19 08:54:27 +03:00
|
|
|
|
|
|
|
// HeadUintPtrMultiFields
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
2021-01-19 08:54:27 +03:00
|
|
|
name: "HeadUintPtrMultiFields",
|
|
|
|
expected: `{"a":1,"b":2}`,
|
2021-01-16 16:16:26 +03:00
|
|
|
indentExpected: `
|
|
|
|
{
|
2021-01-19 08:54:27 +03:00
|
|
|
"a": 1,
|
|
|
|
"b": 2
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
`,
|
2021-01-19 08:54:27 +03:00
|
|
|
data: struct {
|
|
|
|
A *uint `json:"a"`
|
|
|
|
B *uint `json:"b"`
|
|
|
|
}{A: uptr(1), B: uptr(2)},
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
|
|
|
{
|
2021-01-19 08:54:27 +03:00
|
|
|
name: "HeadUintPtrMultiFieldsOmitEmpty",
|
2021-01-16 16:16:26 +03:00
|
|
|
expected: `{"a":1,"b":2}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1,
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
`,
|
2021-01-19 08:54:27 +03:00
|
|
|
data: struct {
|
|
|
|
A *uint `json:"a,omitempty"`
|
|
|
|
B *uint `json:"b,omitempty"`
|
|
|
|
}{A: uptr(1), B: uptr(2)},
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
|
|
|
{
|
2021-01-19 08:54:27 +03:00
|
|
|
name: "HeadUintPtrMultiFieldsString",
|
|
|
|
expected: `{"a":"1","b":"2"}`,
|
2021-01-16 16:16:26 +03:00
|
|
|
indentExpected: `
|
|
|
|
{
|
2021-01-19 08:54:27 +03:00
|
|
|
"a": "1",
|
|
|
|
"b": "2"
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
`,
|
2021-01-19 08:54:27 +03:00
|
|
|
data: struct {
|
|
|
|
A *uint `json:"a,string"`
|
|
|
|
B *uint `json:"b,string"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}{A: uptr(1), B: uptr(2)},
|
|
|
|
},
|
2021-01-19 08:54:27 +03:00
|
|
|
|
|
|
|
// HeadUintPtrNilMultiFields
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
2021-01-19 08:54:27 +03:00
|
|
|
name: "HeadUintPtrNilMultiFields",
|
2021-01-16 16:16:26 +03:00
|
|
|
expected: `{"a":null,"b":null}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": null,
|
|
|
|
"b": null
|
|
|
|
}
|
|
|
|
`,
|
2021-01-19 08:54:27 +03:00
|
|
|
data: struct {
|
2021-01-16 16:16:26 +03:00
|
|
|
A *uint `json:"a"`
|
|
|
|
B *uint `json:"b"`
|
|
|
|
}{A: nil, B: nil},
|
|
|
|
},
|
|
|
|
{
|
2021-01-19 08:54:27 +03:00
|
|
|
name: "HeadUintPtrNilMultiFieldsOmitEmpty",
|
|
|
|
expected: `{}`,
|
2021-01-16 16:16:26 +03:00
|
|
|
indentExpected: `
|
2021-01-19 08:54:27 +03:00
|
|
|
{}
|
2021-01-16 16:16:26 +03:00
|
|
|
`,
|
2021-01-19 08:54:27 +03:00
|
|
|
data: struct {
|
|
|
|
A *uint `json:"a,omitempty"`
|
|
|
|
B *uint `json:"b,omitempty"`
|
|
|
|
}{A: nil, B: nil},
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
|
|
|
{
|
2021-01-19 08:54:27 +03:00
|
|
|
name: "HeadUintPtrNilMultiFieldsString",
|
|
|
|
expected: `{"a":null,"b":null}`,
|
2021-01-16 16:16:26 +03:00
|
|
|
indentExpected: `
|
|
|
|
{
|
2021-01-19 08:54:27 +03:00
|
|
|
"a": null,
|
|
|
|
"b": null
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A *uint `json:"a,string"`
|
|
|
|
B *uint `json:"b,string"`
|
|
|
|
}{A: nil, B: nil},
|
|
|
|
},
|
|
|
|
|
|
|
|
// PtrHeadUintZeroMultiFields
|
|
|
|
{
|
|
|
|
name: "PtrHeadUintZeroMultiFields",
|
|
|
|
expected: `{"a":0,"b":0}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 0,
|
|
|
|
"b": 0
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A uint `json:"a"`
|
|
|
|
B uint `json:"b"`
|
|
|
|
}{},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadUintZeroMultiFieldsOmitEmpty",
|
|
|
|
expected: `{}`,
|
|
|
|
indentExpected: `
|
|
|
|
{}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A uint `json:"a,omitempty"`
|
|
|
|
B uint `json:"b,omitempty"`
|
|
|
|
}{},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadUintZeroMultiFieldsString",
|
|
|
|
expected: `{"a":"0","b":"0"}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": "0",
|
|
|
|
"b": "0"
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A uint `json:"a,string"`
|
|
|
|
B uint `json:"b,string"`
|
|
|
|
}{},
|
|
|
|
},
|
|
|
|
|
|
|
|
// PtrHeadUintMultiFields
|
|
|
|
{
|
|
|
|
name: "PtrHeadUintMultiFields",
|
|
|
|
expected: `{"a":1,"b":2}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1,
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
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
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
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"
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A uint `json:"a,string"`
|
|
|
|
B uint `json:"b,string"`
|
|
|
|
}{A: 1, B: 2},
|
|
|
|
},
|
|
|
|
|
|
|
|
// PtrHeadUintPtrMultiFields
|
|
|
|
{
|
|
|
|
name: "PtrHeadUintPtrMultiFields",
|
|
|
|
expected: `{"a":1,"b":2}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1,
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
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
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
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"
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A *uint `json:"a,string"`
|
|
|
|
B *uint `json:"b,string"`
|
|
|
|
}{A: uptr(1), B: uptr(2)},
|
|
|
|
},
|
|
|
|
|
|
|
|
// PtrHeadUintPtrNilMultiFields
|
|
|
|
{
|
|
|
|
name: "PtrHeadUintPtrNilMultiFields",
|
|
|
|
expected: `{"a":null,"b":null}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": null,
|
|
|
|
"b": null
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A *uint `json:"a"`
|
|
|
|
B *uint `json:"b"`
|
|
|
|
}{A: nil, B: nil},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadUintPtrNilMultiFieldsOmitEmpty",
|
|
|
|
expected: `{}`,
|
|
|
|
indentExpected: `
|
|
|
|
{}
|
|
|
|
`,
|
|
|
|
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
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A *uint `json:"a,string"`
|
|
|
|
B *uint `json:"b,string"`
|
|
|
|
}{A: nil, B: nil},
|
|
|
|
},
|
|
|
|
|
|
|
|
// PtrHeadUintNilMultiFields
|
|
|
|
{
|
|
|
|
name: "PtrHeadUintNilMultiFields",
|
|
|
|
expected: `null`,
|
|
|
|
indentExpected: `
|
|
|
|
null
|
|
|
|
`,
|
|
|
|
data: (*struct {
|
|
|
|
A *uint `json:"a"`
|
|
|
|
B *uint `json:"b"`
|
|
|
|
})(nil),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadUintNilMultiFieldsOmitEmpty",
|
|
|
|
expected: `null`,
|
|
|
|
indentExpected: `
|
|
|
|
null
|
|
|
|
`,
|
|
|
|
data: (*struct {
|
|
|
|
A *uint `json:"a,omitempty"`
|
|
|
|
B *uint `json:"b,omitempty"`
|
|
|
|
})(nil),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadUintNilMultiFieldsString",
|
|
|
|
expected: `null`,
|
|
|
|
indentExpected: `
|
|
|
|
null
|
|
|
|
`,
|
|
|
|
data: (*struct {
|
|
|
|
A *uint `json:"a,string"`
|
|
|
|
B *uint `json:"b,string"`
|
|
|
|
})(nil),
|
|
|
|
},
|
|
|
|
|
|
|
|
// HeadUintZeroNotRoot
|
|
|
|
{
|
|
|
|
name: "HeadUintZeroNotRoot",
|
|
|
|
expected: `{"A":{"a":0}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": 0
|
|
|
|
}
|
|
|
|
}
|
2021-01-16 16:16:26 +03:00
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A struct {
|
|
|
|
A uint `json:"a"`
|
|
|
|
}
|
|
|
|
}{},
|
|
|
|
},
|
2021-01-19 08:54:27 +03:00
|
|
|
{
|
|
|
|
name: "HeadUintZeroNotRootOmitEmpty",
|
|
|
|
expected: `{"A":{}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A struct {
|
|
|
|
A uint `json:"a,omitempty"`
|
|
|
|
}
|
|
|
|
}{},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "HeadUintZeroNotRootString",
|
|
|
|
expected: `{"A":{"a":"0"}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": "0"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A struct {
|
|
|
|
A uint `json:"a,string"`
|
|
|
|
}
|
|
|
|
}{},
|
|
|
|
},
|
|
|
|
|
|
|
|
// HeadUintNotRoot
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "HeadUintNotRoot",
|
|
|
|
expected: `{"A":{"a":1}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A struct {
|
|
|
|
A uint `json:"a"`
|
|
|
|
}
|
|
|
|
}{A: struct {
|
|
|
|
A uint `json:"a"`
|
|
|
|
}{A: 1}},
|
|
|
|
},
|
|
|
|
{
|
2021-01-19 08:54:27 +03:00
|
|
|
name: "HeadUintNotRootOmitEmpty",
|
2021-01-16 16:16:26 +03:00
|
|
|
expected: `{"A":{"a":1}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A struct {
|
2021-01-19 08:54:27 +03:00
|
|
|
A uint `json:"a,omitempty"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
}{A: struct {
|
2021-01-19 08:54:27 +03:00
|
|
|
A uint `json:"a,omitempty"`
|
|
|
|
}{A: 1}},
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
|
|
|
{
|
2021-01-19 08:54:27 +03:00
|
|
|
name: "HeadUintNotRootString",
|
|
|
|
expected: `{"A":{"a":"1"}}`,
|
2021-01-16 16:16:26 +03:00
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
2021-01-19 08:54:27 +03:00
|
|
|
"a": "1"
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A struct {
|
2021-01-19 08:54:27 +03:00
|
|
|
A uint `json:"a,string"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
2021-01-19 08:54:27 +03:00
|
|
|
}{A: struct {
|
|
|
|
A uint `json:"a,string"`
|
|
|
|
}{A: 1}},
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
2021-01-19 08:54:27 +03:00
|
|
|
|
|
|
|
// HeadUintPtrNotRoot
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
2021-01-19 08:54:27 +03:00
|
|
|
name: "HeadUintPtrNotRoot",
|
|
|
|
expected: `{"A":{"a":1}}`,
|
2021-01-16 16:16:26 +03:00
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
2021-01-19 08:54:27 +03:00
|
|
|
"a": 1
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
2021-01-19 08:54:27 +03:00
|
|
|
A struct {
|
|
|
|
A *uint `json:"a"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
2021-01-19 08:54:27 +03:00
|
|
|
}{A: struct {
|
|
|
|
A *uint `json:"a"`
|
|
|
|
}{uptr(1)}},
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
|
|
|
{
|
2021-01-19 08:54:27 +03:00
|
|
|
name: "HeadUintPtrNotRootOmitEmpty",
|
2021-01-16 16:16:26 +03:00
|
|
|
expected: `{"A":{"a":1}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
2021-01-19 08:54:27 +03:00
|
|
|
A struct {
|
|
|
|
A *uint `json:"a,omitempty"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
2021-01-19 08:54:27 +03:00
|
|
|
}{A: struct {
|
|
|
|
A *uint `json:"a,omitempty"`
|
|
|
|
}{uptr(1)}},
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
|
|
|
{
|
2021-01-19 08:54:27 +03:00
|
|
|
name: "HeadUintPtrNotRootString",
|
|
|
|
expected: `{"A":{"a":"1"}}`,
|
2021-01-16 16:16:26 +03:00
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
2021-01-19 08:54:27 +03:00
|
|
|
"a": "1"
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
2021-01-19 08:54:27 +03:00
|
|
|
A struct {
|
|
|
|
A *uint `json:"a,string"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
2021-01-19 08:54:27 +03:00
|
|
|
}{A: struct {
|
|
|
|
A *uint `json:"a,string"`
|
|
|
|
}{uptr(1)}},
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
2021-01-19 08:54:27 +03:00
|
|
|
|
|
|
|
// HeadUintPtrNilNotRoot
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
2021-01-19 08:54:27 +03:00
|
|
|
name: "HeadUintPtrNilNotRoot",
|
2021-01-16 16:16:26 +03:00
|
|
|
expected: `{"A":{"a":null}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
2021-01-19 08:54:27 +03:00
|
|
|
data: struct {
|
|
|
|
A struct {
|
|
|
|
A *uint `json:"a"`
|
|
|
|
}
|
|
|
|
}{},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "HeadUintPtrNilNotRootOmitEmpty",
|
|
|
|
expected: `{"A":{}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A struct {
|
|
|
|
A *uint `json:"a,omitempty"`
|
|
|
|
}
|
|
|
|
}{},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "HeadUintPtrNilNotRootString",
|
|
|
|
expected: `{"A":{"a":null}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A struct {
|
|
|
|
A *uint `json:"a,string"`
|
|
|
|
}
|
|
|
|
}{},
|
|
|
|
},
|
|
|
|
|
|
|
|
// PtrHeadUintZeroNotRoot
|
|
|
|
{
|
|
|
|
name: "PtrHeadUintZeroNotRoot",
|
|
|
|
expected: `{"A":{"a":0}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A *struct {
|
|
|
|
A uint `json:"a"`
|
|
|
|
}
|
|
|
|
}{A: new(struct {
|
|
|
|
A uint `json:"a"`
|
|
|
|
})},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadUintZeroNotRootOmitEmpty",
|
|
|
|
expected: `{"A":{}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A *struct {
|
|
|
|
A uint `json:"a,omitempty"`
|
|
|
|
}
|
|
|
|
}{A: new(struct {
|
|
|
|
A uint `json:"a,omitempty"`
|
|
|
|
})},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadUintZeroNotRootString",
|
|
|
|
expected: `{"A":{"a":"0"}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": "0"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A *struct {
|
|
|
|
A uint `json:"a,string"`
|
|
|
|
}
|
|
|
|
}{A: new(struct {
|
|
|
|
A uint `json:"a,string"`
|
|
|
|
})},
|
|
|
|
},
|
|
|
|
|
|
|
|
// PtrHeadUintNotRoot
|
|
|
|
{
|
|
|
|
name: "PtrHeadUintNotRoot",
|
|
|
|
expected: `{"A":{"a":1}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A *struct {
|
|
|
|
A uint `json:"a"`
|
|
|
|
}
|
|
|
|
}{A: &(struct {
|
|
|
|
A uint `json:"a"`
|
|
|
|
}{A: 1})},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadUintNotRootOmitEmpty",
|
|
|
|
expected: `{"A":{"a":1}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A *struct {
|
|
|
|
A uint `json:"a,omitempty"`
|
|
|
|
}
|
|
|
|
}{A: &(struct {
|
|
|
|
A uint `json:"a,omitempty"`
|
|
|
|
}{A: 1})},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadUintNotRootString",
|
|
|
|
expected: `{"A":{"a":"1"}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": "1"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A *struct {
|
|
|
|
A uint `json:"a,string"`
|
|
|
|
}
|
|
|
|
}{A: &(struct {
|
|
|
|
A uint `json:"a,string"`
|
|
|
|
}{A: 1})},
|
|
|
|
},
|
|
|
|
|
|
|
|
// PtrHeadUintPtrNotRoot
|
|
|
|
{
|
|
|
|
name: "PtrHeadUintPtrNotRoot",
|
|
|
|
expected: `{"A":{"a":1}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A *struct {
|
|
|
|
A *uint `json:"a"`
|
|
|
|
}
|
|
|
|
}{A: &(struct {
|
|
|
|
A *uint `json:"a"`
|
|
|
|
}{A: uptr(1)})},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadUintPtrNotRootOmitEmpty",
|
|
|
|
expected: `{"A":{"a":1}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A *struct {
|
|
|
|
A *uint `json:"a,omitempty"`
|
|
|
|
}
|
|
|
|
}{A: &(struct {
|
|
|
|
A *uint `json:"a,omitempty"`
|
|
|
|
}{A: uptr(1)})},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadUintPtrNotRootString",
|
|
|
|
expected: `{"A":{"a":"1"}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": "1"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A *struct {
|
|
|
|
A *uint `json:"a,string"`
|
|
|
|
}
|
|
|
|
}{A: &(struct {
|
|
|
|
A *uint `json:"a,string"`
|
|
|
|
}{A: uptr(1)})},
|
|
|
|
},
|
|
|
|
|
|
|
|
// PtrHeadUintPtrNilNotRoot
|
|
|
|
{
|
|
|
|
name: "PtrHeadUintPtrNilNotRoot",
|
|
|
|
expected: `{"A":{"a":null}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A *struct {
|
|
|
|
A *uint `json:"a"`
|
|
|
|
}
|
|
|
|
}{A: &(struct {
|
|
|
|
A *uint `json:"a"`
|
|
|
|
}{A: nil})},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadUintPtrNilNotRootOmitEmpty",
|
|
|
|
expected: `{"A":{}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A *struct {
|
|
|
|
A *uint `json:"a,omitempty"`
|
|
|
|
}
|
|
|
|
}{A: &(struct {
|
|
|
|
A *uint `json:"a,omitempty"`
|
|
|
|
}{A: nil})},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadUintPtrNilNotRootString",
|
|
|
|
expected: `{"A":{"a":null}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A *struct {
|
|
|
|
A *uint `json:"a,string"`
|
|
|
|
}
|
|
|
|
}{A: &(struct {
|
|
|
|
A *uint `json:"a,string"`
|
|
|
|
}{A: nil})},
|
|
|
|
},
|
|
|
|
|
|
|
|
// PtrHeadUintNilNotRoot
|
|
|
|
{
|
|
|
|
name: "PtrHeadUintNilNotRoot",
|
|
|
|
expected: `{"A":null}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": null
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A *struct {
|
|
|
|
A *uint `json:"a"`
|
|
|
|
}
|
|
|
|
}{A: nil},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadUintNilNotRootOmitEmpty",
|
|
|
|
expected: `{}`,
|
|
|
|
indentExpected: `
|
|
|
|
{}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A *struct {
|
|
|
|
A *uint `json:"a,omitempty"`
|
|
|
|
} `json:",omitempty"`
|
|
|
|
}{A: nil},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadUintNilNotRootString",
|
|
|
|
expected: `{"A":null}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": null
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A *struct {
|
|
|
|
A *uint `json:"a,string"`
|
|
|
|
} `json:",string"`
|
|
|
|
}{A: nil},
|
|
|
|
},
|
|
|
|
|
|
|
|
// HeadUintZeroMultiFieldsNotRoot
|
|
|
|
{
|
|
|
|
name: "HeadUintZeroMultiFieldsNotRoot",
|
|
|
|
expected: `{"A":{"a":0},"B":{"b":0}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": 0
|
|
|
|
},
|
|
|
|
"B": {
|
|
|
|
"b": 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A struct {
|
|
|
|
A uint `json:"a"`
|
|
|
|
}
|
|
|
|
B struct {
|
|
|
|
B uint `json:"b"`
|
|
|
|
}
|
|
|
|
}{},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "HeadUintZeroMultiFieldsNotRootOmitEmpty",
|
|
|
|
expected: `{"A":{},"B":{}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {},
|
|
|
|
"B": {}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A struct {
|
|
|
|
A uint `json:"a,omitempty"`
|
|
|
|
}
|
|
|
|
B struct {
|
|
|
|
B uint `json:"b,omitempty"`
|
|
|
|
}
|
|
|
|
}{},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "HeadUintZeroMultiFieldsNotRootString",
|
|
|
|
expected: `{"A":{"a":"0"},"B":{"b":"0"}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": "0"
|
|
|
|
},
|
|
|
|
"B": {
|
|
|
|
"b": "0"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A struct {
|
|
|
|
A uint `json:"a,string"`
|
|
|
|
}
|
|
|
|
B struct {
|
|
|
|
B uint `json:"b,string"`
|
|
|
|
}
|
|
|
|
}{},
|
|
|
|
},
|
|
|
|
|
|
|
|
// HeadUintMultiFieldsNotRoot
|
|
|
|
{
|
|
|
|
name: "HeadUintMultiFieldsNotRoot",
|
|
|
|
expected: `{"A":{"a":1},"B":{"b":2}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": 1
|
|
|
|
},
|
|
|
|
"B": {
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A struct {
|
|
|
|
A uint `json:"a"`
|
|
|
|
}
|
|
|
|
B struct {
|
|
|
|
B uint `json:"b"`
|
|
|
|
}
|
|
|
|
}{A: struct {
|
|
|
|
A uint `json:"a"`
|
|
|
|
}{A: 1}, B: struct {
|
|
|
|
B uint `json:"b"`
|
|
|
|
}{B: 2}},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "HeadUintMultiFieldsNotRootOmitEmpty",
|
|
|
|
expected: `{"A":{"a":1},"B":{"b":2}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": 1
|
|
|
|
},
|
|
|
|
"B": {
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A struct {
|
|
|
|
A uint `json:"a,omitempty"`
|
|
|
|
}
|
|
|
|
B struct {
|
|
|
|
B uint `json:"b,omitempty"`
|
|
|
|
}
|
|
|
|
}{A: struct {
|
|
|
|
A uint `json:"a,omitempty"`
|
|
|
|
}{A: 1}, B: struct {
|
|
|
|
B uint `json:"b,omitempty"`
|
|
|
|
}{B: 2}},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "HeadUintMultiFieldsNotRootString",
|
|
|
|
expected: `{"A":{"a":"1"},"B":{"b":"2"}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": "1"
|
|
|
|
},
|
|
|
|
"B": {
|
|
|
|
"b": "2"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A struct {
|
|
|
|
A uint `json:"a,string"`
|
|
|
|
}
|
|
|
|
B struct {
|
|
|
|
B uint `json:"b,string"`
|
|
|
|
}
|
|
|
|
}{A: struct {
|
|
|
|
A uint `json:"a,string"`
|
|
|
|
}{A: 1}, B: struct {
|
|
|
|
B uint `json:"b,string"`
|
|
|
|
}{B: 2}},
|
|
|
|
},
|
|
|
|
|
|
|
|
// HeadUintPtrMultiFieldsNotRoot
|
|
|
|
{
|
|
|
|
name: "HeadUintPtrMultiFieldsNotRoot",
|
|
|
|
expected: `{"A":{"a":1},"B":{"b":2}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": 1
|
|
|
|
},
|
|
|
|
"B": {
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A struct {
|
|
|
|
A *uint `json:"a"`
|
|
|
|
}
|
|
|
|
B struct {
|
|
|
|
B *uint `json:"b"`
|
|
|
|
}
|
|
|
|
}{A: struct {
|
|
|
|
A *uint `json:"a"`
|
|
|
|
}{A: uptr(1)}, B: struct {
|
|
|
|
B *uint `json:"b"`
|
|
|
|
}{B: uptr(2)}},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "HeadUintPtrMultiFieldsNotRootOmitEmpty",
|
|
|
|
expected: `{"A":{"a":1},"B":{"b":2}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": 1
|
|
|
|
},
|
|
|
|
"B": {
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A struct {
|
|
|
|
A *uint `json:"a,omitempty"`
|
|
|
|
}
|
|
|
|
B struct {
|
|
|
|
B *uint `json:"b,omitempty"`
|
|
|
|
}
|
|
|
|
}{A: struct {
|
|
|
|
A *uint `json:"a,omitempty"`
|
|
|
|
}{A: uptr(1)}, B: struct {
|
|
|
|
B *uint `json:"b,omitempty"`
|
|
|
|
}{B: uptr(2)}},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "HeadUintPtrMultiFieldsNotRootString",
|
|
|
|
expected: `{"A":{"a":"1"},"B":{"b":"2"}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": "1"
|
|
|
|
},
|
|
|
|
"B": {
|
|
|
|
"b": "2"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A struct {
|
|
|
|
A *uint `json:"a,string"`
|
|
|
|
}
|
|
|
|
B struct {
|
|
|
|
B *uint `json:"b,string"`
|
|
|
|
}
|
|
|
|
}{A: struct {
|
|
|
|
A *uint `json:"a,string"`
|
|
|
|
}{A: uptr(1)}, B: struct {
|
|
|
|
B *uint `json:"b,string"`
|
|
|
|
}{B: uptr(2)}},
|
|
|
|
},
|
|
|
|
|
|
|
|
// HeadUintPtrNilMultiFieldsNotRoot
|
|
|
|
{
|
|
|
|
name: "HeadUintPtrNilMultiFieldsNotRoot",
|
|
|
|
expected: `{"A":{"a":null},"B":{"b":null}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": null
|
|
|
|
},
|
|
|
|
"B": {
|
|
|
|
"b": null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A struct {
|
|
|
|
A *uint `json:"a"`
|
|
|
|
}
|
|
|
|
B struct {
|
|
|
|
B *uint `json:"b"`
|
|
|
|
}
|
|
|
|
}{A: struct {
|
|
|
|
A *uint `json:"a"`
|
|
|
|
}{A: nil}, B: struct {
|
|
|
|
B *uint `json:"b"`
|
|
|
|
}{B: nil}},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "HeadUintPtrNilMultiFieldsNotRootOmitEmpty",
|
|
|
|
expected: `{"A":{},"B":{}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {},
|
|
|
|
"B": {}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A struct {
|
|
|
|
A *uint `json:"a,omitempty"`
|
|
|
|
}
|
|
|
|
B struct {
|
|
|
|
B *uint `json:"b,omitempty"`
|
|
|
|
}
|
|
|
|
}{A: struct {
|
|
|
|
A *uint `json:"a,omitempty"`
|
|
|
|
}{A: nil}, B: struct {
|
|
|
|
B *uint `json:"b,omitempty"`
|
|
|
|
}{B: nil}},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "HeadUintPtrNilMultiFieldsNotRootString",
|
|
|
|
expected: `{"A":{"a":null},"B":{"b":null}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": null
|
|
|
|
},
|
|
|
|
"B": {
|
|
|
|
"b": null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A struct {
|
|
|
|
A *uint `json:"a,string"`
|
|
|
|
}
|
|
|
|
B struct {
|
|
|
|
B *uint `json:"b,string"`
|
|
|
|
}
|
|
|
|
}{A: struct {
|
|
|
|
A *uint `json:"a,string"`
|
|
|
|
}{A: nil}, B: struct {
|
|
|
|
B *uint `json:"b,string"`
|
|
|
|
}{B: nil}},
|
|
|
|
},
|
|
|
|
|
|
|
|
// PtrHeadUintZeroMultiFieldsNotRoot
|
|
|
|
{
|
|
|
|
name: "PtrHeadUintZeroMultiFieldsNotRoot",
|
|
|
|
expected: `{"A":{"a":0},"B":{"b":0}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": 0
|
|
|
|
},
|
|
|
|
"B": {
|
|
|
|
"b": 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A struct {
|
|
|
|
A uint `json:"a"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
2021-01-19 08:54:27 +03:00
|
|
|
B struct {
|
|
|
|
B uint `json:"b"`
|
|
|
|
}
|
|
|
|
}{},
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
|
|
|
{
|
2021-01-19 08:54:27 +03:00
|
|
|
name: "PtrHeadUintZeroMultiFieldsNotRootOmitEmpty",
|
|
|
|
expected: `{"A":{},"B":{}}`,
|
2021-01-16 16:16:26 +03:00
|
|
|
indentExpected: `
|
|
|
|
{
|
2021-01-19 08:54:27 +03:00
|
|
|
"A": {},
|
|
|
|
"B": {}
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
`,
|
2021-01-19 08:54:27 +03:00
|
|
|
data: &struct {
|
|
|
|
A struct {
|
|
|
|
A uint `json:"a,omitempty"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
2021-01-19 08:54:27 +03:00
|
|
|
B struct {
|
|
|
|
B uint `json:"b,omitempty"`
|
|
|
|
}
|
|
|
|
}{},
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
|
|
|
{
|
2021-01-19 08:54:27 +03:00
|
|
|
name: "PtrHeadUintZeroMultiFieldsNotRootString",
|
|
|
|
expected: `{"A":{"a":"0"},"B":{"b":"0"}}`,
|
2021-01-16 16:16:26 +03:00
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
2021-01-19 08:54:27 +03:00
|
|
|
"a": "0"
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
|
|
|
"B": {
|
2021-01-19 08:54:27 +03:00
|
|
|
"b": "0"
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
2021-01-19 08:54:27 +03:00
|
|
|
data: &struct {
|
2021-01-16 16:16:26 +03:00
|
|
|
A struct {
|
2021-01-19 08:54:27 +03:00
|
|
|
A uint `json:"a,string"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
B struct {
|
2021-01-19 08:54:27 +03:00
|
|
|
B uint `json:"b,string"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
}{},
|
|
|
|
},
|
2021-01-19 08:54:27 +03:00
|
|
|
|
|
|
|
// PtrHeadUintMultiFieldsNotRoot
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
2021-01-19 08:54:27 +03:00
|
|
|
name: "PtrHeadUintMultiFieldsNotRoot",
|
2021-01-16 16:16:26 +03:00
|
|
|
expected: `{"A":{"a":1},"B":{"b":2}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": 1
|
|
|
|
},
|
|
|
|
"B": {
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
2021-01-19 08:54:27 +03:00
|
|
|
data: &struct {
|
2021-01-16 16:16:26 +03:00
|
|
|
A struct {
|
|
|
|
A uint `json:"a"`
|
|
|
|
}
|
|
|
|
B struct {
|
|
|
|
B uint `json:"b"`
|
|
|
|
}
|
|
|
|
}{A: struct {
|
|
|
|
A uint `json:"a"`
|
|
|
|
}{A: 1}, B: struct {
|
|
|
|
B uint `json:"b"`
|
|
|
|
}{B: 2}},
|
|
|
|
},
|
|
|
|
{
|
2021-01-19 08:54:27 +03:00
|
|
|
name: "PtrHeadUintMultiFieldsNotRootOmitEmpty",
|
2021-01-16 16:16:26 +03:00
|
|
|
expected: `{"A":{"a":1},"B":{"b":2}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": 1
|
|
|
|
},
|
|
|
|
"B": {
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
2021-01-19 08:54:27 +03:00
|
|
|
data: &struct {
|
2021-01-16 16:16:26 +03:00
|
|
|
A struct {
|
2021-01-19 08:54:27 +03:00
|
|
|
A uint `json:"a,omitempty"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
B struct {
|
2021-01-19 08:54:27 +03:00
|
|
|
B uint `json:"b,omitempty"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
}{A: struct {
|
2021-01-19 08:54:27 +03:00
|
|
|
A uint `json:"a,omitempty"`
|
|
|
|
}{A: 1}, B: struct {
|
|
|
|
B uint `json:"b,omitempty"`
|
|
|
|
}{B: 2}},
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
|
|
|
{
|
2021-01-19 08:54:27 +03:00
|
|
|
name: "PtrHeadUintMultiFieldsNotRootString",
|
|
|
|
expected: `{"A":{"a":"1"},"B":{"b":"2"}}`,
|
2021-01-16 16:16:26 +03:00
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
2021-01-19 08:54:27 +03:00
|
|
|
"a": "1"
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
|
|
|
"B": {
|
2021-01-19 08:54:27 +03:00
|
|
|
"b": "2"
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
2021-01-19 08:54:27 +03:00
|
|
|
data: &struct {
|
2021-01-16 16:16:26 +03:00
|
|
|
A struct {
|
2021-01-19 08:54:27 +03:00
|
|
|
A uint `json:"a,string"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
B struct {
|
2021-01-19 08:54:27 +03:00
|
|
|
B uint `json:"b,string"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
}{A: struct {
|
2021-01-19 08:54:27 +03:00
|
|
|
A uint `json:"a,string"`
|
|
|
|
}{A: 1}, B: struct {
|
|
|
|
B uint `json:"b,string"`
|
|
|
|
}{B: 2}},
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
2021-01-19 08:54:27 +03:00
|
|
|
|
|
|
|
// PtrHeadUintPtrMultiFieldsNotRoot
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
2021-01-19 08:54:27 +03:00
|
|
|
name: "PtrHeadUintPtrMultiFieldsNotRoot",
|
|
|
|
expected: `{"A":{"a":1},"B":{"b":2}}`,
|
2021-01-16 16:16:26 +03:00
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
2021-01-19 08:54:27 +03:00
|
|
|
"a": 1
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
|
|
|
"B": {
|
2021-01-19 08:54:27 +03:00
|
|
|
"b": 2
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
2021-01-19 08:54:27 +03:00
|
|
|
A *struct {
|
|
|
|
A *uint `json:"a"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
2021-01-19 08:54:27 +03:00
|
|
|
B *struct {
|
|
|
|
B *uint `json:"b"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
2021-01-19 08:54:27 +03:00
|
|
|
}{A: &(struct {
|
|
|
|
A *uint `json:"a"`
|
|
|
|
}{A: uptr(1)}), B: &(struct {
|
|
|
|
B *uint `json:"b"`
|
|
|
|
}{B: uptr(2)})},
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
|
|
|
{
|
2021-01-19 08:54:27 +03:00
|
|
|
name: "PtrHeadUintPtrMultiFieldsNotRootOmitEmpty",
|
2021-01-16 16:16:26 +03:00
|
|
|
expected: `{"A":{"a":1},"B":{"b":2}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": 1
|
|
|
|
},
|
|
|
|
"B": {
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
2021-01-19 08:54:27 +03:00
|
|
|
A *struct {
|
|
|
|
A *uint `json:"a,omitempty"`
|
|
|
|
}
|
|
|
|
B *struct {
|
|
|
|
B *uint `json:"b,omitempty"`
|
|
|
|
}
|
|
|
|
}{A: &(struct {
|
|
|
|
A *uint `json:"a,omitempty"`
|
|
|
|
}{A: uptr(1)}), B: &(struct {
|
|
|
|
B *uint `json:"b,omitempty"`
|
|
|
|
}{B: uptr(2)})},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadUintPtrMultiFieldsNotRootString",
|
|
|
|
expected: `{"A":{"a":"1"},"B":{"b":"2"}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": "1"
|
|
|
|
},
|
|
|
|
"B": {
|
|
|
|
"b": "2"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A *struct {
|
|
|
|
A *uint `json:"a,string"`
|
|
|
|
}
|
|
|
|
B *struct {
|
|
|
|
B *uint `json:"b,string"`
|
|
|
|
}
|
|
|
|
}{A: &(struct {
|
|
|
|
A *uint `json:"a,string"`
|
|
|
|
}{A: uptr(1)}), B: &(struct {
|
|
|
|
B *uint `json:"b,string"`
|
|
|
|
}{B: uptr(2)})},
|
|
|
|
},
|
|
|
|
|
|
|
|
// PtrHeadUintPtrNilMultiFieldsNotRoot
|
|
|
|
{
|
|
|
|
name: "PtrHeadUintPtrNilMultiFieldsNotRoot",
|
|
|
|
expected: `{"A":null,"B":null}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": null,
|
|
|
|
"B": null
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A *struct {
|
|
|
|
A *uint `json:"a"`
|
|
|
|
}
|
|
|
|
B *struct {
|
|
|
|
B *uint `json:"b"`
|
|
|
|
}
|
|
|
|
}{A: nil, B: nil},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadUintPtrNilMultiFieldsNotRootOmitEmpty",
|
|
|
|
expected: `{}`,
|
|
|
|
indentExpected: `
|
|
|
|
{}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A *struct {
|
|
|
|
A *uint `json:"a,omitempty"`
|
|
|
|
} `json:",omitempty"`
|
|
|
|
B *struct {
|
|
|
|
B *uint `json:"b,omitempty"`
|
|
|
|
} `json:",omitempty"`
|
|
|
|
}{A: nil, B: nil},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadUintPtrNilMultiFieldsNotRootString",
|
|
|
|
expected: `{"A":null,"B":null}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": null,
|
|
|
|
"B": null
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A *struct {
|
|
|
|
A *uint `json:"a,string"`
|
|
|
|
} `json:",string"`
|
|
|
|
B *struct {
|
|
|
|
B *uint `json:"b,string"`
|
|
|
|
} `json:",string"`
|
|
|
|
}{A: nil, B: nil},
|
|
|
|
},
|
|
|
|
|
|
|
|
// PtrHeadUintNilMultiFieldsNotRoot
|
|
|
|
{
|
|
|
|
name: "PtrHeadUintNilMultiFieldsNotRoot",
|
|
|
|
expected: `null`,
|
|
|
|
indentExpected: `
|
|
|
|
null
|
|
|
|
`,
|
|
|
|
data: (*struct {
|
|
|
|
A *struct {
|
|
|
|
A *uint `json:"a"`
|
|
|
|
}
|
|
|
|
B *struct {
|
|
|
|
B *uint `json:"b"`
|
|
|
|
}
|
|
|
|
})(nil),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadUintNilMultiFieldsNotRootOmitEmpty",
|
|
|
|
expected: `null`,
|
|
|
|
indentExpected: `
|
|
|
|
null
|
|
|
|
`,
|
|
|
|
data: (*struct {
|
|
|
|
A *struct {
|
|
|
|
A *uint `json:"a,omitempty"`
|
|
|
|
}
|
|
|
|
B *struct {
|
|
|
|
B *uint `json:"b,omitempty"`
|
|
|
|
}
|
|
|
|
})(nil),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadUintNilMultiFieldsNotRootString",
|
|
|
|
expected: `null`,
|
|
|
|
indentExpected: `
|
|
|
|
null
|
|
|
|
`,
|
|
|
|
data: (*struct {
|
|
|
|
A *struct {
|
|
|
|
A *uint `json:"a,string"`
|
|
|
|
}
|
|
|
|
B *struct {
|
|
|
|
B *uint `json:"b,string"`
|
|
|
|
}
|
|
|
|
})(nil),
|
|
|
|
},
|
|
|
|
|
|
|
|
// 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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A *struct {
|
2021-01-16 16:16:26 +03:00
|
|
|
A uint `json:"a"`
|
2021-01-19 08:54:27 +03:00
|
|
|
B uint `json:"b"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
2021-01-19 08:54:27 +03:00
|
|
|
B *struct {
|
|
|
|
A uint `json:"a"`
|
2021-01-16 16:16:26 +03:00
|
|
|
B uint `json:"b"`
|
|
|
|
}
|
2021-01-19 08:54:27 +03:00
|
|
|
}{A: &(struct {
|
2021-01-16 16:16:26 +03:00
|
|
|
A uint `json:"a"`
|
|
|
|
B uint `json:"b"`
|
2021-01-19 08:54:27 +03:00
|
|
|
}{A: 1, B: 2}), B: &(struct {
|
|
|
|
A uint `json:"a"`
|
|
|
|
B uint `json:"b"`
|
|
|
|
}{A: 3, B: 4})},
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
|
|
|
{
|
2021-01-19 08:54:27 +03:00
|
|
|
name: "PtrHeadUintDoubleMultiFieldsNotRootOmitEmpty",
|
|
|
|
expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`,
|
2021-01-16 16:16:26 +03:00
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
2021-01-19 08:54:27 +03:00
|
|
|
"a": 1,
|
|
|
|
"b": 2
|
|
|
|
},
|
|
|
|
"B": {
|
|
|
|
"a": 3,
|
|
|
|
"b": 4
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A *struct {
|
|
|
|
A uint `json:"a,omitempty"`
|
|
|
|
B uint `json:"b,omitempty"`
|
|
|
|
}
|
|
|
|
B *struct {
|
|
|
|
A uint `json:"a,omitempty"`
|
|
|
|
B uint `json:"b,omitempty"`
|
|
|
|
}
|
|
|
|
}{A: &(struct {
|
|
|
|
A uint `json:"a,omitempty"`
|
|
|
|
B uint `json:"b,omitempty"`
|
|
|
|
}{A: 1, B: 2}), B: &(struct {
|
|
|
|
A uint `json:"a,omitempty"`
|
|
|
|
B uint `json:"b,omitempty"`
|
|
|
|
}{A: 3, B: 4})},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadUintDoubleMultiFieldsNotRootString",
|
|
|
|
expected: `{"A":{"a":"1","b":"2"},"B":{"a":"3","b":"4"}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": "1",
|
|
|
|
"b": "2"
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
|
|
|
"B": {
|
2021-01-19 08:54:27 +03:00
|
|
|
"a": "3",
|
|
|
|
"b": "4"
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A *struct {
|
2021-01-19 08:54:27 +03:00
|
|
|
A uint `json:"a,string"`
|
|
|
|
B uint `json:"b,string"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
B *struct {
|
2021-01-19 08:54:27 +03:00
|
|
|
A uint `json:"a,string"`
|
|
|
|
B uint `json:"b,string"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
}{A: &(struct {
|
2021-01-19 08:54:27 +03:00
|
|
|
A uint `json:"a,string"`
|
|
|
|
B uint `json:"b,string"`
|
|
|
|
}{A: 1, B: 2}), B: &(struct {
|
|
|
|
A uint `json:"a,string"`
|
|
|
|
B uint `json:"b,string"`
|
|
|
|
}{A: 3, B: 4})},
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
2021-01-19 08:54:27 +03:00
|
|
|
|
|
|
|
// PtrHeadUintNilDoubleMultiFieldsNotRoot
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
2021-01-19 08:54:27 +03:00
|
|
|
name: "PtrHeadUintNilDoubleMultiFieldsNotRoot",
|
2021-01-16 16:16:26 +03:00
|
|
|
expected: `{"A":null,"B":null}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": null,
|
|
|
|
"B": null
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A *struct {
|
2021-01-19 08:54:27 +03:00
|
|
|
A uint `json:"a"`
|
|
|
|
B uint `json:"b"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
B *struct {
|
2021-01-19 08:54:27 +03:00
|
|
|
A uint `json:"a"`
|
|
|
|
B uint `json:"b"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
}{A: nil, B: nil},
|
|
|
|
},
|
|
|
|
{
|
2021-01-19 08:54:27 +03:00
|
|
|
name: "PtrHeadUintNilDoubleMultiFieldsNotRootOmitEmpty",
|
|
|
|
expected: `{}`,
|
2021-01-16 16:16:26 +03:00
|
|
|
indentExpected: `
|
2021-01-19 08:54:27 +03:00
|
|
|
{}
|
2021-01-16 16:16:26 +03:00
|
|
|
`,
|
2021-01-19 08:54:27 +03:00
|
|
|
data: &struct {
|
2021-01-16 16:16:26 +03:00
|
|
|
A *struct {
|
2021-01-19 08:54:27 +03:00
|
|
|
A uint `json:"a,omitempty"`
|
|
|
|
B uint `json:"b,omitempty"`
|
|
|
|
} `json:",omitempty"`
|
2021-01-16 16:16:26 +03:00
|
|
|
B *struct {
|
2021-01-19 08:54:27 +03:00
|
|
|
A uint `json:"a,omitempty"`
|
|
|
|
B uint `json:"b,omitempty"`
|
|
|
|
} `json:",omitempty"`
|
|
|
|
}{A: nil, B: nil},
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
|
|
|
{
|
2021-01-19 08:54:27 +03:00
|
|
|
name: "PtrHeadUintNilDoubleMultiFieldsNotRootString",
|
|
|
|
expected: `{"A":null,"B":null}`,
|
2021-01-16 16:16:26 +03:00
|
|
|
indentExpected: `
|
|
|
|
{
|
2021-01-19 08:54:27 +03:00
|
|
|
"A": null,
|
|
|
|
"B": null
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A *struct {
|
2021-01-19 08:54:27 +03:00
|
|
|
A uint `json:"a,string"`
|
|
|
|
B uint `json:"b,string"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
B *struct {
|
2021-01-19 08:54:27 +03:00
|
|
|
A uint `json:"a,string"`
|
|
|
|
B uint `json:"b,string"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
2021-01-19 08:54:27 +03:00
|
|
|
}{A: nil, B: nil},
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
2021-01-19 08:54:27 +03:00
|
|
|
|
|
|
|
// PtrHeadUintNilDoubleMultiFieldsNotRoot
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "PtrHeadUintNilDoubleMultiFieldsNotRoot",
|
2021-01-19 08:54:27 +03:00
|
|
|
expected: `null`,
|
2021-01-16 16:16:26 +03:00
|
|
|
indentExpected: `
|
2021-01-19 08:54:27 +03:00
|
|
|
null
|
2021-01-16 16:16:26 +03:00
|
|
|
`,
|
2021-01-19 08:54:27 +03:00
|
|
|
data: (*struct {
|
2021-01-16 16:16:26 +03:00
|
|
|
A *struct {
|
|
|
|
A uint `json:"a"`
|
|
|
|
B uint `json:"b"`
|
|
|
|
}
|
|
|
|
B *struct {
|
|
|
|
A uint `json:"a"`
|
|
|
|
B uint `json:"b"`
|
|
|
|
}
|
2021-01-19 08:54:27 +03:00
|
|
|
})(nil),
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
|
|
|
{
|
2021-01-19 08:54:27 +03:00
|
|
|
name: "PtrHeadUintNilDoubleMultiFieldsNotRootOmitEmpty",
|
2021-01-16 16:16:26 +03:00
|
|
|
expected: `null`,
|
|
|
|
indentExpected: `
|
|
|
|
null
|
|
|
|
`,
|
|
|
|
data: (*struct {
|
|
|
|
A *struct {
|
2021-01-19 08:54:27 +03:00
|
|
|
A uint `json:"a,omitempty"`
|
|
|
|
B uint `json:"b,omitempty"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
B *struct {
|
2021-01-19 08:54:27 +03:00
|
|
|
A uint `json:"a,omitempty"`
|
|
|
|
B uint `json:"b,omitempty"`
|
|
|
|
}
|
|
|
|
})(nil),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadUintNilDoubleMultiFieldsNotRootString",
|
|
|
|
expected: `null`,
|
|
|
|
indentExpected: `
|
|
|
|
null
|
|
|
|
`,
|
|
|
|
data: (*struct {
|
|
|
|
A *struct {
|
|
|
|
A uint `json:"a,string"`
|
|
|
|
B uint `json:"b,string"`
|
|
|
|
}
|
|
|
|
B *struct {
|
|
|
|
A uint `json:"a,string"`
|
|
|
|
B uint `json:"b,string"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
})(nil),
|
|
|
|
},
|
2021-01-19 08:54:27 +03:00
|
|
|
|
|
|
|
// PtrHeadUintPtrDoubleMultiFieldsNotRoot
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "PtrHeadUintPtrDoubleMultiFieldsNotRoot",
|
|
|
|
expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": 1,
|
|
|
|
"b": 2
|
|
|
|
},
|
|
|
|
"B": {
|
|
|
|
"a": 3,
|
|
|
|
"b": 4
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A *struct {
|
|
|
|
A *uint `json:"a"`
|
|
|
|
B *uint `json:"b"`
|
|
|
|
}
|
|
|
|
B *struct {
|
|
|
|
A *uint `json:"a"`
|
|
|
|
B *uint `json:"b"`
|
|
|
|
}
|
|
|
|
}{A: &(struct {
|
|
|
|
A *uint `json:"a"`
|
|
|
|
B *uint `json:"b"`
|
|
|
|
}{A: uptr(1), B: uptr(2)}), B: &(struct {
|
|
|
|
A *uint `json:"a"`
|
|
|
|
B *uint `json:"b"`
|
|
|
|
}{A: uptr(3), B: uptr(4)})},
|
|
|
|
},
|
2021-01-19 08:54:27 +03:00
|
|
|
{
|
|
|
|
name: "PtrHeadUintPtrDoubleMultiFieldsNotRootOmitEmpty",
|
|
|
|
expected: `{"A":{"a":1,"b":2},"B":{"a":3,"b":4}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": 1,
|
|
|
|
"b": 2
|
|
|
|
},
|
|
|
|
"B": {
|
|
|
|
"a": 3,
|
|
|
|
"b": 4
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A *struct {
|
|
|
|
A *uint `json:"a,omitempty"`
|
|
|
|
B *uint `json:"b,omitempty"`
|
|
|
|
}
|
|
|
|
B *struct {
|
|
|
|
A *uint `json:"a,omitempty"`
|
|
|
|
B *uint `json:"b,omitempty"`
|
|
|
|
}
|
|
|
|
}{A: &(struct {
|
|
|
|
A *uint `json:"a,omitempty"`
|
|
|
|
B *uint `json:"b,omitempty"`
|
|
|
|
}{A: uptr(1), B: uptr(2)}), B: &(struct {
|
|
|
|
A *uint `json:"a,omitempty"`
|
|
|
|
B *uint `json:"b,omitempty"`
|
|
|
|
}{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"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A *struct {
|
|
|
|
A *uint `json:"a,string"`
|
|
|
|
B *uint `json:"b,string"`
|
|
|
|
}
|
|
|
|
B *struct {
|
|
|
|
A *uint `json:"a,string"`
|
|
|
|
B *uint `json:"b,string"`
|
|
|
|
}
|
|
|
|
}{A: &(struct {
|
|
|
|
A *uint `json:"a,string"`
|
|
|
|
B *uint `json:"b,string"`
|
|
|
|
}{A: uptr(1), B: uptr(2)}), B: &(struct {
|
|
|
|
A *uint `json:"a,string"`
|
|
|
|
B *uint `json:"b,string"`
|
|
|
|
}{A: uptr(3), B: uptr(4)})},
|
|
|
|
},
|
|
|
|
|
|
|
|
// PtrHeadUintPtrNilDoubleMultiFieldsNotRoot
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "PtrHeadUintPtrNilDoubleMultiFieldsNotRoot",
|
|
|
|
expected: `{"A":null,"B":null}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": null,
|
|
|
|
"B": null
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A *struct {
|
|
|
|
A *uint `json:"a"`
|
|
|
|
B *uint `json:"b"`
|
|
|
|
}
|
|
|
|
B *struct {
|
|
|
|
A *uint `json:"a"`
|
|
|
|
B *uint `json:"b"`
|
|
|
|
}
|
|
|
|
}{A: nil, B: nil},
|
|
|
|
},
|
2021-01-19 08:54:27 +03:00
|
|
|
{
|
|
|
|
name: "PtrHeadUintPtrNilDoubleMultiFieldsNotRootOmitEmpty",
|
|
|
|
expected: `{}`,
|
|
|
|
indentExpected: `
|
|
|
|
{}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A *struct {
|
|
|
|
A *uint `json:"a,omitempty"`
|
|
|
|
B *uint `json:"b,omitempty"`
|
|
|
|
} `json:",omitempty"`
|
|
|
|
B *struct {
|
|
|
|
A *uint `json:"a,omitempty"`
|
|
|
|
B *uint `json:"b,omitempty"`
|
|
|
|
} `json:",omitempty"`
|
|
|
|
}{A: nil, B: nil},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadUintPtrNilDoubleMultiFieldsNotRootString",
|
|
|
|
expected: `{"A":null,"B":null}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": null,
|
|
|
|
"B": null
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A *struct {
|
|
|
|
A *uint `json:"a,string"`
|
|
|
|
B *uint `json:"b,string"`
|
|
|
|
}
|
|
|
|
B *struct {
|
|
|
|
A *uint `json:"a,string"`
|
|
|
|
B *uint `json:"b,string"`
|
|
|
|
}
|
|
|
|
}{A: nil, B: nil},
|
|
|
|
},
|
|
|
|
|
|
|
|
// PtrHeadUintPtrNilDoubleMultiFieldsNotRoot
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "PtrHeadUintPtrNilDoubleMultiFieldsNotRoot",
|
|
|
|
expected: `null`,
|
|
|
|
indentExpected: `
|
|
|
|
null
|
|
|
|
`,
|
|
|
|
data: (*struct {
|
|
|
|
A *struct {
|
|
|
|
A *uint `json:"a"`
|
|
|
|
B *uint `json:"b"`
|
|
|
|
}
|
|
|
|
B *struct {
|
|
|
|
A *uint `json:"a"`
|
|
|
|
B *uint `json:"b"`
|
|
|
|
}
|
|
|
|
})(nil),
|
|
|
|
},
|
|
|
|
{
|
2021-01-19 08:54:27 +03:00
|
|
|
name: "PtrHeadUintPtrNilDoubleMultiFieldsNotRootOmitEmpty",
|
|
|
|
expected: `null`,
|
|
|
|
indentExpected: `
|
|
|
|
null
|
|
|
|
`,
|
|
|
|
data: (*struct {
|
|
|
|
A *struct {
|
|
|
|
A *uint `json:"a,omitempty"`
|
|
|
|
B *uint `json:"b,omitempty"`
|
|
|
|
}
|
|
|
|
B *struct {
|
|
|
|
A *uint `json:"a,omitempty"`
|
|
|
|
B *uint `json:"b,omitempty"`
|
|
|
|
}
|
|
|
|
})(nil),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadUintPtrNilDoubleMultiFieldsNotRootString",
|
|
|
|
expected: `null`,
|
|
|
|
indentExpected: `
|
|
|
|
null
|
|
|
|
`,
|
|
|
|
data: (*struct {
|
|
|
|
A *struct {
|
|
|
|
A *uint `json:"a,string"`
|
|
|
|
B *uint `json:"b,string"`
|
|
|
|
}
|
|
|
|
B *struct {
|
|
|
|
A *uint `json:"a,string"`
|
|
|
|
B *uint `json:"b,string"`
|
|
|
|
}
|
|
|
|
})(nil),
|
|
|
|
},
|
|
|
|
|
|
|
|
// AnonymousHeadUint
|
|
|
|
{
|
|
|
|
name: "AnonymousHeadUint",
|
|
|
|
expected: `{"a":1,"b":2}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1,
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
structUint
|
|
|
|
B uint `json:"b"`
|
|
|
|
}{
|
|
|
|
structUint: structUint{A: 1},
|
|
|
|
B: 2,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "AnonymousHeadUintOmitEmpty",
|
|
|
|
expected: `{"a":1,"b":2}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1,
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
structUintOmitEmpty
|
|
|
|
B uint `json:"b,omitempty"`
|
|
|
|
}{
|
|
|
|
structUintOmitEmpty: structUintOmitEmpty{A: 1},
|
|
|
|
B: 2,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "AnonymousHeadUintString",
|
|
|
|
expected: `{"a":"1","b":"2"}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": "1",
|
|
|
|
"b": "2"
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
structUintString
|
|
|
|
B uint `json:"b,string"`
|
|
|
|
}{
|
|
|
|
structUintString: structUintString{A: 1},
|
|
|
|
B: 2,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// PtrAnonymousHeadUint
|
|
|
|
{
|
|
|
|
name: "PtrAnonymousHeadUint",
|
|
|
|
expected: `{"a":1,"b":2}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1,
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
*structUint
|
|
|
|
B uint `json:"b"`
|
|
|
|
}{
|
|
|
|
structUint: &structUint{A: 1},
|
|
|
|
B: 2,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrAnonymousHeadUintOmitEmpty",
|
|
|
|
expected: `{"a":1,"b":2}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1,
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
*structUintOmitEmpty
|
|
|
|
B uint `json:"b,omitempty"`
|
|
|
|
}{
|
|
|
|
structUintOmitEmpty: &structUintOmitEmpty{A: 1},
|
|
|
|
B: 2,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrAnonymousHeadUintString",
|
|
|
|
expected: `{"a":"1","b":"2"}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": "1",
|
|
|
|
"b": "2"
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
*structUintString
|
|
|
|
B uint `json:"b,string"`
|
|
|
|
}{
|
|
|
|
structUintString: &structUintString{A: 1},
|
|
|
|
B: 2,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// NilPtrAnonymousHeadUint
|
|
|
|
{
|
|
|
|
name: "NilPtrAnonymousHeadUint",
|
|
|
|
expected: `{"b":2}`,
|
2021-01-16 16:16:26 +03:00
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
2021-01-19 08:54:27 +03:00
|
|
|
*structUint
|
2021-01-16 16:16:26 +03:00
|
|
|
B uint `json:"b"`
|
|
|
|
}{
|
2021-01-19 08:54:27 +03:00
|
|
|
structUint: nil,
|
2021-01-16 16:16:26 +03:00
|
|
|
B: 2,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2021-01-19 08:54:27 +03:00
|
|
|
name: "NilPtrAnonymousHeadUintOmitEmpty",
|
|
|
|
expected: `{"b":2}`,
|
2021-01-16 16:16:26 +03:00
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
2021-01-19 08:54:27 +03:00
|
|
|
*structUintOmitEmpty
|
|
|
|
B uint `json:"b,omitempty"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}{
|
2021-01-19 08:54:27 +03:00
|
|
|
structUintOmitEmpty: nil,
|
|
|
|
B: 2,
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2021-01-19 08:54:27 +03:00
|
|
|
name: "NilPtrAnonymousHeadUintString",
|
|
|
|
expected: `{"b":"2"}`,
|
2021-01-16 16:16:26 +03:00
|
|
|
indentExpected: `
|
|
|
|
{
|
2021-01-19 08:54:27 +03:00
|
|
|
"b": "2"
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
2021-01-19 08:54:27 +03:00
|
|
|
*structUintString
|
|
|
|
B uint `json:"b,string"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}{
|
2021-01-19 08:54:27 +03:00
|
|
|
structUintString: nil,
|
|
|
|
B: 2,
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
|
|
|
},
|
2021-01-19 08:54:27 +03:00
|
|
|
|
|
|
|
// AnonymousHeadUintPtr
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "AnonymousHeadUintPtr",
|
|
|
|
expected: `{"a":1,"b":2}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1,
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
structUintPtr
|
|
|
|
B *uint `json:"b"`
|
|
|
|
}{
|
|
|
|
structUintPtr: structUintPtr{A: uptr(1)},
|
|
|
|
B: uptr(2),
|
|
|
|
},
|
|
|
|
},
|
2021-01-19 08:54:27 +03:00
|
|
|
{
|
|
|
|
name: "AnonymousHeadUintPtrOmitEmpty",
|
|
|
|
expected: `{"a":1,"b":2}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1,
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
structUintPtrOmitEmpty
|
|
|
|
B *uint `json:"b,omitempty"`
|
|
|
|
}{
|
|
|
|
structUintPtrOmitEmpty: structUintPtrOmitEmpty{A: uptr(1)},
|
|
|
|
B: uptr(2),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "AnonymousHeadUintPtrString",
|
|
|
|
expected: `{"a":"1","b":"2"}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": "1",
|
|
|
|
"b": "2"
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
structUintPtrString
|
|
|
|
B *uint `json:"b,string"`
|
|
|
|
}{
|
|
|
|
structUintPtrString: structUintPtrString{A: uptr(1)},
|
|
|
|
B: uptr(2),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// AnonymousHeadUintPtrNil
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "AnonymousHeadUintPtrNil",
|
|
|
|
expected: `{"a":null,"b":2}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": null,
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
structUintPtr
|
|
|
|
B *uint `json:"b"`
|
|
|
|
}{
|
|
|
|
structUintPtr: structUintPtr{A: nil},
|
|
|
|
B: uptr(2),
|
|
|
|
},
|
|
|
|
},
|
2021-01-19 08:54:27 +03:00
|
|
|
{
|
|
|
|
name: "AnonymousHeadUintPtrNilOmitEmpty",
|
|
|
|
expected: `{"b":2}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
structUintPtrOmitEmpty
|
|
|
|
B *uint `json:"b,omitempty"`
|
|
|
|
}{
|
|
|
|
structUintPtrOmitEmpty: structUintPtrOmitEmpty{A: nil},
|
|
|
|
B: uptr(2),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "AnonymousHeadUintPtrNilString",
|
|
|
|
expected: `{"a":null,"b":"2"}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": null,
|
|
|
|
"b": "2"
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
structUintPtrString
|
|
|
|
B *uint `json:"b,string"`
|
|
|
|
}{
|
|
|
|
structUintPtrString: structUintPtrString{A: nil},
|
|
|
|
B: uptr(2),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// PtrAnonymousHeadUintPtr
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "PtrAnonymousHeadUintPtr",
|
|
|
|
expected: `{"a":1,"b":2}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1,
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
*structUintPtr
|
|
|
|
B *uint `json:"b"`
|
|
|
|
}{
|
|
|
|
structUintPtr: &structUintPtr{A: uptr(1)},
|
|
|
|
B: uptr(2),
|
|
|
|
},
|
|
|
|
},
|
2021-01-19 08:54:27 +03:00
|
|
|
{
|
|
|
|
name: "PtrAnonymousHeadUintPtrOmitEmpty",
|
|
|
|
expected: `{"a":1,"b":2}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1,
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
*structUintPtrOmitEmpty
|
|
|
|
B *uint `json:"b,omitempty"`
|
|
|
|
}{
|
|
|
|
structUintPtrOmitEmpty: &structUintPtrOmitEmpty{A: uptr(1)},
|
|
|
|
B: uptr(2),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrAnonymousHeadUintPtrString",
|
|
|
|
expected: `{"a":"1","b":"2"}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": "1",
|
|
|
|
"b": "2"
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
*structUintPtrString
|
|
|
|
B *uint `json:"b,string"`
|
|
|
|
}{
|
|
|
|
structUintPtrString: &structUintPtrString{A: uptr(1)},
|
|
|
|
B: uptr(2),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// NilPtrAnonymousHeadUintPtr
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "NilPtrAnonymousHeadUintPtr",
|
|
|
|
expected: `{"b":2}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
*structUintPtr
|
|
|
|
B *uint `json:"b"`
|
|
|
|
}{
|
|
|
|
structUintPtr: nil,
|
|
|
|
B: uptr(2),
|
|
|
|
},
|
|
|
|
},
|
2021-01-19 08:54:27 +03:00
|
|
|
{
|
|
|
|
name: "NilPtrAnonymousHeadUintPtrOmitEmpty",
|
|
|
|
expected: `{"b":2}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
*structUintPtrOmitEmpty
|
|
|
|
B *uint `json:"b,omitempty"`
|
|
|
|
}{
|
|
|
|
structUintPtrOmitEmpty: nil,
|
|
|
|
B: uptr(2),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "NilPtrAnonymousHeadUintPtrString",
|
|
|
|
expected: `{"b":"2"}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"b": "2"
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
*structUintPtrString
|
|
|
|
B *uint `json:"b,string"`
|
|
|
|
}{
|
|
|
|
structUintPtrString: nil,
|
|
|
|
B: uptr(2),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// AnonymousHeadUintOnly
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "AnonymousHeadUintOnly",
|
|
|
|
expected: `{"a":1}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
structUint
|
|
|
|
}{
|
|
|
|
structUint: structUint{A: 1},
|
|
|
|
},
|
|
|
|
},
|
2021-01-19 08:54:27 +03:00
|
|
|
{
|
|
|
|
name: "AnonymousHeadUintOnlyOmitEmpty",
|
|
|
|
expected: `{"a":1}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
structUintOmitEmpty
|
|
|
|
}{
|
|
|
|
structUintOmitEmpty: structUintOmitEmpty{A: 1},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "AnonymousHeadUintOnlyString",
|
|
|
|
expected: `{"a":"1"}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": "1"
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
structUintString
|
|
|
|
}{
|
|
|
|
structUintString: structUintString{A: 1},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// PtrAnonymousHeadUintOnly
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "PtrAnonymousHeadUintOnly",
|
|
|
|
expected: `{"a":1}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
*structUint
|
|
|
|
}{
|
|
|
|
structUint: &structUint{A: 1},
|
|
|
|
},
|
|
|
|
},
|
2021-01-19 08:54:27 +03:00
|
|
|
{
|
|
|
|
name: "PtrAnonymousHeadUintOnlyOmitEmpty",
|
|
|
|
expected: `{"a":1}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
*structUintOmitEmpty
|
|
|
|
}{
|
|
|
|
structUintOmitEmpty: &structUintOmitEmpty{A: 1},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrAnonymousHeadUintOnlyString",
|
|
|
|
expected: `{"a":"1"}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": "1"
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
*structUintString
|
|
|
|
}{
|
|
|
|
structUintString: &structUintString{A: 1},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// NilPtrAnonymousHeadUintOnly
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "NilPtrAnonymousHeadUintOnly",
|
|
|
|
expected: `{}`,
|
|
|
|
indentExpected: `
|
|
|
|
{}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
*structUint
|
|
|
|
}{
|
|
|
|
structUint: nil,
|
|
|
|
},
|
|
|
|
},
|
2021-01-19 08:54:27 +03:00
|
|
|
{
|
|
|
|
name: "NilPtrAnonymousHeadUintOnlyOmitEmpty",
|
|
|
|
expected: `{}`,
|
|
|
|
indentExpected: `
|
|
|
|
{}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
*structUintOmitEmpty
|
|
|
|
}{
|
|
|
|
structUintOmitEmpty: nil,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "NilPtrAnonymousHeadUintOnlyString",
|
|
|
|
expected: `{}`,
|
|
|
|
indentExpected: `
|
|
|
|
{}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
*structUintString
|
|
|
|
}{
|
|
|
|
structUintString: nil,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// AnonymousHeadUintPtrOnly
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "AnonymousHeadUintPtrOnly",
|
|
|
|
expected: `{"a":1}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
structUintPtr
|
|
|
|
}{
|
|
|
|
structUintPtr: structUintPtr{A: uptr(1)},
|
|
|
|
},
|
|
|
|
},
|
2021-01-19 08:54:27 +03:00
|
|
|
{
|
|
|
|
name: "AnonymousHeadUintPtrOnlyOmitEmpty",
|
|
|
|
expected: `{"a":1}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
structUintPtrOmitEmpty
|
|
|
|
}{
|
|
|
|
structUintPtrOmitEmpty: structUintPtrOmitEmpty{A: uptr(1)},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "AnonymousHeadUintPtrOnlyString",
|
|
|
|
expected: `{"a":"1"}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": "1"
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
structUintPtrString
|
|
|
|
}{
|
|
|
|
structUintPtrString: structUintPtrString{A: uptr(1)},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// AnonymousHeadUintPtrNilOnly
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "AnonymousHeadUintPtrNilOnly",
|
|
|
|
expected: `{"a":null}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": null
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
structUintPtr
|
|
|
|
}{
|
|
|
|
structUintPtr: structUintPtr{A: nil},
|
|
|
|
},
|
|
|
|
},
|
2021-01-19 08:54:27 +03:00
|
|
|
{
|
|
|
|
name: "AnonymousHeadUintPtrNilOnlyOmitEmpty",
|
|
|
|
expected: `{}`,
|
|
|
|
indentExpected: `
|
|
|
|
{}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
structUintPtrOmitEmpty
|
|
|
|
}{
|
|
|
|
structUintPtrOmitEmpty: structUintPtrOmitEmpty{A: nil},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "AnonymousHeadUintPtrNilOnlyString",
|
|
|
|
expected: `{"a":null}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": null
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
structUintPtrString
|
|
|
|
}{
|
|
|
|
structUintPtrString: structUintPtrString{A: nil},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// PtrAnonymousHeadUintPtrOnly
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "PtrAnonymousHeadUintPtrOnly",
|
|
|
|
expected: `{"a":1}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
*structUintPtr
|
|
|
|
}{
|
|
|
|
structUintPtr: &structUintPtr{A: uptr(1)},
|
|
|
|
},
|
|
|
|
},
|
2021-01-19 08:54:27 +03:00
|
|
|
{
|
|
|
|
name: "PtrAnonymousHeadUintPtrOnlyOmitEmpty",
|
|
|
|
expected: `{"a":1}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
*structUintPtrOmitEmpty
|
|
|
|
}{
|
|
|
|
structUintPtrOmitEmpty: &structUintPtrOmitEmpty{A: uptr(1)},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrAnonymousHeadUintPtrOnlyString",
|
|
|
|
expected: `{"a":"1"}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": "1"
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
*structUintPtrString
|
|
|
|
}{
|
|
|
|
structUintPtrString: &structUintPtrString{A: uptr(1)},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// NilPtrAnonymousHeadUintPtrOnly
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "NilPtrAnonymousHeadUintPtrOnly",
|
|
|
|
expected: `{}`,
|
|
|
|
indentExpected: `
|
|
|
|
{}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
*structUintPtr
|
|
|
|
}{
|
|
|
|
structUintPtr: nil,
|
|
|
|
},
|
|
|
|
},
|
2021-01-19 08:54:27 +03:00
|
|
|
{
|
|
|
|
name: "NilPtrAnonymousHeadUintPtrOnlyOmitEmpty",
|
|
|
|
expected: `{}`,
|
|
|
|
indentExpected: `
|
|
|
|
{}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
*structUintPtrOmitEmpty
|
|
|
|
}{
|
|
|
|
structUintPtrOmitEmpty: nil,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "NilPtrAnonymousHeadUintPtrOnlyString",
|
|
|
|
expected: `{}`,
|
|
|
|
indentExpected: `
|
|
|
|
{}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
*structUintPtrString
|
|
|
|
}{
|
|
|
|
structUintPtrString: nil,
|
|
|
|
},
|
|
|
|
},
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
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): %s: %s", test.name, htmlEscape, test.expected, err)
|
|
|
|
}
|
2021-01-19 08:54:27 +03:00
|
|
|
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())
|
|
|
|
}
|
2021-01-16 16:16:26 +03:00
|
|
|
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())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|