2021-01-16 16:16:26 +03:00
|
|
|
package json_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"strings"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/goccy/go-json"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestCoverInt8(t *testing.T) {
|
|
|
|
type structInt8 struct {
|
|
|
|
A int8 `json:"a"`
|
|
|
|
}
|
2021-01-16 20:53:54 +03:00
|
|
|
type structInt8OmitEmpty struct {
|
|
|
|
A int8 `json:"a,omitempty"`
|
|
|
|
}
|
|
|
|
type structInt8String struct {
|
|
|
|
A int8 `json:"a,string"`
|
|
|
|
}
|
|
|
|
|
2021-01-16 16:16:26 +03:00
|
|
|
type structInt8Ptr struct {
|
|
|
|
A *int8 `json:"a"`
|
|
|
|
}
|
2021-01-16 20:53:54 +03:00
|
|
|
type structInt8PtrOmitEmpty struct {
|
|
|
|
A *int8 `json:"a,omitempty"`
|
|
|
|
}
|
|
|
|
type structInt8PtrString struct {
|
|
|
|
A *int8 `json:"a,string"`
|
|
|
|
}
|
2021-01-16 16:16:26 +03:00
|
|
|
|
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
expected string
|
|
|
|
indentExpected string
|
|
|
|
data interface{}
|
|
|
|
}{
|
2021-01-16 20:53:54 +03:00
|
|
|
// HeadInt8Zero
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "HeadInt8Zero",
|
|
|
|
expected: `{"a":0}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 0
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A int8 `json:"a"`
|
|
|
|
}{},
|
|
|
|
},
|
2021-01-16 20:53:54 +03:00
|
|
|
{
|
|
|
|
name: "HeadInt8ZeroOmitEmpty",
|
|
|
|
expected: `{}`,
|
|
|
|
indentExpected: `
|
|
|
|
{}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A int8 `json:"a,omitempty"`
|
|
|
|
}{},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "HeadInt8ZeroString",
|
|
|
|
expected: `{"a":"0"}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": "0"
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A int8 `json:"a,string"`
|
|
|
|
}{},
|
|
|
|
},
|
|
|
|
|
|
|
|
// HeadInt8
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "HeadInt8",
|
|
|
|
expected: `{"a":1}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A int8 `json:"a"`
|
|
|
|
}{A: 1},
|
|
|
|
},
|
2021-01-16 20:53:54 +03:00
|
|
|
{
|
|
|
|
name: "HeadInt8OmitEmpty",
|
|
|
|
expected: `{"a":1}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A int8 `json:"a,omitempty"`
|
|
|
|
}{A: 1},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "HeadInt8String",
|
|
|
|
expected: `{"a":"1"}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": "1"
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A int8 `json:"a,string"`
|
|
|
|
}{A: 1},
|
|
|
|
},
|
|
|
|
|
|
|
|
// HeadInt8Ptr
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "HeadInt8Ptr",
|
|
|
|
expected: `{"a":1}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A *int8 `json:"a"`
|
|
|
|
}{A: int8ptr(1)},
|
|
|
|
},
|
2021-01-16 20:53:54 +03:00
|
|
|
{
|
|
|
|
name: "HeadInt8PtrOmitEmpty",
|
|
|
|
expected: `{"a":1}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A *int8 `json:"a,omitempty"`
|
|
|
|
}{A: int8ptr(1)},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "HeadInt8PtrString",
|
|
|
|
expected: `{"a":"1"}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": "1"
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A *int8 `json:"a,string"`
|
|
|
|
}{A: int8ptr(1)},
|
|
|
|
},
|
|
|
|
|
|
|
|
// HeadInt8PtrNil
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "HeadInt8PtrNil",
|
|
|
|
expected: `{"a":null}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": null
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A *int8 `json:"a"`
|
|
|
|
}{A: nil},
|
|
|
|
},
|
2021-01-16 20:53:54 +03:00
|
|
|
{
|
|
|
|
name: "HeadInt8PtrNilOmitEmpty",
|
|
|
|
expected: `{}`,
|
|
|
|
indentExpected: `
|
|
|
|
{}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A *int8 `json:"a,omitempty"`
|
|
|
|
}{A: nil},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "HeadInt8PtrNilString",
|
|
|
|
expected: `{"a":null}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": null
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A *int8 `json:"a,string"`
|
|
|
|
}{A: nil},
|
|
|
|
},
|
|
|
|
|
|
|
|
// PtrHeadInt8Zero
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "PtrHeadInt8Zero",
|
|
|
|
expected: `{"a":0}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 0
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A int8 `json:"a"`
|
|
|
|
}{},
|
|
|
|
},
|
2021-01-16 20:53:54 +03:00
|
|
|
{
|
|
|
|
name: "PtrHeadInt8ZeroOmitEmpty",
|
|
|
|
expected: `{}`,
|
|
|
|
indentExpected: `
|
|
|
|
{}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A int8 `json:"a,omitempty"`
|
|
|
|
}{},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadInt8ZeroString",
|
|
|
|
expected: `{"a":"0"}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": "0"
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A int8 `json:"a,string"`
|
|
|
|
}{},
|
|
|
|
},
|
|
|
|
|
|
|
|
// PtrHeadInt8
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "PtrHeadInt8",
|
|
|
|
expected: `{"a":1}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A int8 `json:"a"`
|
|
|
|
}{A: 1},
|
|
|
|
},
|
2021-01-16 20:53:54 +03:00
|
|
|
{
|
|
|
|
name: "PtrHeadInt8OmitEmpty",
|
|
|
|
expected: `{"a":1}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A int8 `json:"a,omitempty"`
|
|
|
|
}{A: 1},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadInt8String",
|
|
|
|
expected: `{"a":"1"}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": "1"
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A int8 `json:"a,string"`
|
|
|
|
}{A: 1},
|
|
|
|
},
|
|
|
|
|
|
|
|
// PtrHeadInt8Ptr
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "PtrHeadInt8Ptr",
|
|
|
|
expected: `{"a":1}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A *int8 `json:"a"`
|
|
|
|
}{A: int8ptr(1)},
|
|
|
|
},
|
2021-01-16 20:53:54 +03:00
|
|
|
{
|
|
|
|
name: "PtrHeadInt8PtrOmitEmpty",
|
|
|
|
expected: `{"a":1}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A *int8 `json:"a,omitempty"`
|
|
|
|
}{A: int8ptr(1)},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadInt8PtrString",
|
|
|
|
expected: `{"a":"1"}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": "1"
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A *int8 `json:"a,string"`
|
|
|
|
}{A: int8ptr(1)},
|
|
|
|
},
|
|
|
|
|
|
|
|
// PtrHeadInt8PtrNil
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "PtrHeadInt8PtrNil",
|
|
|
|
expected: `{"a":null}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": null
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A *int8 `json:"a"`
|
|
|
|
}{A: nil},
|
|
|
|
},
|
2021-01-16 20:53:54 +03:00
|
|
|
{
|
|
|
|
name: "PtrHeadInt8PtrNilOmitEmpty",
|
|
|
|
expected: `{}`,
|
|
|
|
indentExpected: `
|
|
|
|
{}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A *int8 `json:"a,omitempty"`
|
|
|
|
}{A: nil},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadInt8PtrNilString",
|
|
|
|
expected: `{"a":null}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": null
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A *int8 `json:"a,string"`
|
|
|
|
}{A: nil},
|
|
|
|
},
|
|
|
|
|
|
|
|
// PtrHeadInt8Nil
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "PtrHeadInt8Nil",
|
|
|
|
expected: `null`,
|
|
|
|
indentExpected: `
|
|
|
|
null
|
|
|
|
`,
|
|
|
|
data: (*struct {
|
|
|
|
A *int8 `json:"a"`
|
|
|
|
})(nil),
|
|
|
|
},
|
2021-01-16 20:53:54 +03:00
|
|
|
{
|
|
|
|
name: "PtrHeadInt8NilOmitEmpty",
|
|
|
|
expected: `null`,
|
|
|
|
indentExpected: `
|
|
|
|
null
|
|
|
|
`,
|
|
|
|
data: (*struct {
|
|
|
|
A *int8 `json:"a,omitempty"`
|
|
|
|
})(nil),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadInt8NilString",
|
|
|
|
expected: `null`,
|
|
|
|
indentExpected: `
|
|
|
|
null
|
|
|
|
`,
|
|
|
|
data: (*struct {
|
|
|
|
A *int8 `json:"a,string"`
|
|
|
|
})(nil),
|
|
|
|
},
|
|
|
|
|
|
|
|
// HeadInt8ZeroMultiFields
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "HeadInt8ZeroMultiFields",
|
|
|
|
expected: `{"a":0,"b":0}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 0,
|
|
|
|
"b": 0
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A int8 `json:"a"`
|
|
|
|
B int8 `json:"b"`
|
|
|
|
}{},
|
|
|
|
},
|
2021-01-16 20:53:54 +03:00
|
|
|
{
|
|
|
|
name: "HeadInt8ZeroMultiFieldsOmitEmpty",
|
|
|
|
expected: `{}`,
|
|
|
|
indentExpected: `
|
|
|
|
{}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A int8 `json:"a,omitempty"`
|
|
|
|
B int8 `json:"b,omitempty"`
|
|
|
|
}{},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "HeadInt8ZeroMultiFields",
|
|
|
|
expected: `{"a":"0","b":"0"}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": "0",
|
|
|
|
"b": "0"
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A int8 `json:"a,string"`
|
|
|
|
B int8 `json:"b,string"`
|
|
|
|
}{},
|
|
|
|
},
|
|
|
|
|
|
|
|
// HeadInt8MultiFields
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "HeadInt8MultiFields",
|
|
|
|
expected: `{"a":1,"b":2}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1,
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A int8 `json:"a"`
|
|
|
|
B int8 `json:"b"`
|
|
|
|
}{A: 1, B: 2},
|
|
|
|
},
|
|
|
|
{
|
2021-01-16 20:53:54 +03:00
|
|
|
name: "HeadInt8MultiFieldsOmitEmpty",
|
2021-01-16 16:16:26 +03:00
|
|
|
expected: `{"a":1,"b":2}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1,
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
2021-01-16 20:53:54 +03:00
|
|
|
A int8 `json:"a,omitempty"`
|
|
|
|
B int8 `json:"b,omitempty"`
|
|
|
|
}{A: 1, B: 2},
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
|
|
|
{
|
2021-01-16 20:53:54 +03:00
|
|
|
name: "HeadInt8MultiFieldsString",
|
|
|
|
expected: `{"a":"1","b":"2"}`,
|
2021-01-16 16:16:26 +03:00
|
|
|
indentExpected: `
|
|
|
|
{
|
2021-01-16 20:53:54 +03:00
|
|
|
"a": "1",
|
|
|
|
"b": "2"
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
2021-01-16 20:53:54 +03:00
|
|
|
A int8 `json:"a,string"`
|
|
|
|
B int8 `json:"b,string"`
|
|
|
|
}{A: 1, B: 2},
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
2021-01-16 20:53:54 +03:00
|
|
|
|
|
|
|
// HeadInt8PtrMultiFields
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
2021-01-16 20:53:54 +03:00
|
|
|
name: "HeadInt8PtrMultiFields",
|
|
|
|
expected: `{"a":1,"b":2}`,
|
2021-01-16 16:16:26 +03:00
|
|
|
indentExpected: `
|
|
|
|
{
|
2021-01-16 20:53:54 +03:00
|
|
|
"a": 1,
|
|
|
|
"b": 2
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
`,
|
2021-01-16 20:53:54 +03:00
|
|
|
data: struct {
|
|
|
|
A *int8 `json:"a"`
|
|
|
|
B *int8 `json:"b"`
|
|
|
|
}{A: int8ptr(1), B: int8ptr(2)},
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
|
|
|
{
|
2021-01-16 20:53:54 +03:00
|
|
|
name: "HeadInt8PtrMultiFieldsOmitEmpty",
|
2021-01-16 16:16:26 +03:00
|
|
|
expected: `{"a":1,"b":2}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1,
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
`,
|
2021-01-16 20:53:54 +03:00
|
|
|
data: struct {
|
|
|
|
A *int8 `json:"a,omitempty"`
|
|
|
|
B *int8 `json:"b,omitempty"`
|
|
|
|
}{A: int8ptr(1), B: int8ptr(2)},
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
|
|
|
{
|
2021-01-16 20:53:54 +03:00
|
|
|
name: "HeadInt8PtrMultiFieldsString",
|
|
|
|
expected: `{"a":"1","b":"2"}`,
|
2021-01-16 16:16:26 +03:00
|
|
|
indentExpected: `
|
|
|
|
{
|
2021-01-16 20:53:54 +03:00
|
|
|
"a": "1",
|
|
|
|
"b": "2"
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
`,
|
2021-01-16 20:53:54 +03:00
|
|
|
data: struct {
|
|
|
|
A *int8 `json:"a,string"`
|
|
|
|
B *int8 `json:"b,string"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}{A: int8ptr(1), B: int8ptr(2)},
|
|
|
|
},
|
2021-01-16 20:53:54 +03:00
|
|
|
|
|
|
|
// HeadInt8PtrNilMultiFields
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
2021-01-16 20:53:54 +03:00
|
|
|
name: "HeadInt8PtrNilMultiFields",
|
2021-01-16 16:16:26 +03:00
|
|
|
expected: `{"a":null,"b":null}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": null,
|
|
|
|
"b": null
|
|
|
|
}
|
|
|
|
`,
|
2021-01-16 20:53:54 +03:00
|
|
|
data: struct {
|
2021-01-16 16:16:26 +03:00
|
|
|
A *int8 `json:"a"`
|
|
|
|
B *int8 `json:"b"`
|
|
|
|
}{A: nil, B: nil},
|
|
|
|
},
|
|
|
|
{
|
2021-01-16 20:53:54 +03:00
|
|
|
name: "HeadInt8PtrNilMultiFieldsOmitEmpty",
|
|
|
|
expected: `{}`,
|
2021-01-16 16:16:26 +03:00
|
|
|
indentExpected: `
|
2021-01-16 20:53:54 +03:00
|
|
|
{}
|
2021-01-16 16:16:26 +03:00
|
|
|
`,
|
2021-01-16 20:53:54 +03:00
|
|
|
data: struct {
|
|
|
|
A *int8 `json:"a,omitempty"`
|
|
|
|
B *int8 `json:"b,omitempty"`
|
|
|
|
}{A: nil, B: nil},
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
|
|
|
{
|
2021-01-16 20:53:54 +03:00
|
|
|
name: "HeadInt8PtrNilMultiFieldsString",
|
|
|
|
expected: `{"a":null,"b":null}`,
|
2021-01-16 16:16:26 +03:00
|
|
|
indentExpected: `
|
|
|
|
{
|
2021-01-16 20:53:54 +03:00
|
|
|
"a": null,
|
|
|
|
"b": null
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A *int8 `json:"a,string"`
|
|
|
|
B *int8 `json:"b,string"`
|
|
|
|
}{A: nil, B: nil},
|
|
|
|
},
|
|
|
|
|
|
|
|
// PtrHeadInt8ZeroMultiFields
|
|
|
|
{
|
|
|
|
name: "PtrHeadInt8ZeroMultiFields",
|
|
|
|
expected: `{"a":0,"b":0}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 0,
|
|
|
|
"b": 0
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A int8 `json:"a"`
|
|
|
|
B int8 `json:"b"`
|
|
|
|
}{},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadInt8ZeroMultiFieldsOmitEmpty",
|
|
|
|
expected: `{}`,
|
|
|
|
indentExpected: `
|
|
|
|
{}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A int8 `json:"a,omitempty"`
|
|
|
|
B int8 `json:"b,omitempty"`
|
|
|
|
}{},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadInt8ZeroMultiFieldsString",
|
|
|
|
expected: `{"a":"0","b":"0"}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": "0",
|
|
|
|
"b": "0"
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A int8 `json:"a,string"`
|
|
|
|
B int8 `json:"b,string"`
|
|
|
|
}{},
|
|
|
|
},
|
|
|
|
|
|
|
|
// PtrHeadInt8MultiFields
|
|
|
|
{
|
|
|
|
name: "PtrHeadInt8MultiFields",
|
|
|
|
expected: `{"a":1,"b":2}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1,
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
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
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
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"
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A int8 `json:"a,string"`
|
|
|
|
B int8 `json:"b,string"`
|
|
|
|
}{A: 1, B: 2},
|
|
|
|
},
|
|
|
|
|
|
|
|
// PtrHeadInt8PtrMultiFields
|
|
|
|
{
|
|
|
|
name: "PtrHeadInt8PtrMultiFields",
|
|
|
|
expected: `{"a":1,"b":2}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1,
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
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
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
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"
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A *int8 `json:"a,string"`
|
|
|
|
B *int8 `json:"b,string"`
|
|
|
|
}{A: int8ptr(1), B: int8ptr(2)},
|
|
|
|
},
|
|
|
|
|
|
|
|
// PtrHeadInt8PtrNilMultiFields
|
|
|
|
{
|
|
|
|
name: "PtrHeadInt8PtrNilMultiFields",
|
|
|
|
expected: `{"a":null,"b":null}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": null,
|
|
|
|
"b": null
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A *int8 `json:"a"`
|
|
|
|
B *int8 `json:"b"`
|
|
|
|
}{A: nil, B: nil},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadInt8PtrNilMultiFieldsOmitEmpty",
|
|
|
|
expected: `{}`,
|
|
|
|
indentExpected: `
|
|
|
|
{}
|
|
|
|
`,
|
|
|
|
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
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A *int8 `json:"a,string"`
|
|
|
|
B *int8 `json:"b,string"`
|
|
|
|
}{A: nil, B: nil},
|
|
|
|
},
|
|
|
|
|
|
|
|
// PtrHeadInt8NilMultiFields
|
|
|
|
{
|
|
|
|
name: "PtrHeadInt8NilMultiFields",
|
|
|
|
expected: `null`,
|
|
|
|
indentExpected: `
|
|
|
|
null
|
|
|
|
`,
|
|
|
|
data: (*struct {
|
|
|
|
A *int8 `json:"a"`
|
|
|
|
B *int8 `json:"b"`
|
|
|
|
})(nil),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadInt8NilMultiFieldsOmitEmpty",
|
|
|
|
expected: `null`,
|
|
|
|
indentExpected: `
|
|
|
|
null
|
|
|
|
`,
|
|
|
|
data: (*struct {
|
|
|
|
A *int8 `json:"a,omitempty"`
|
|
|
|
B *int8 `json:"b,omitempty"`
|
|
|
|
})(nil),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadInt8NilMultiFieldsString",
|
|
|
|
expected: `null`,
|
|
|
|
indentExpected: `
|
|
|
|
null
|
|
|
|
`,
|
|
|
|
data: (*struct {
|
|
|
|
A *int8 `json:"a,string"`
|
|
|
|
B *int8 `json:"b,string"`
|
|
|
|
})(nil),
|
|
|
|
},
|
|
|
|
|
|
|
|
// HeadInt8ZeroNotRoot
|
|
|
|
{
|
|
|
|
name: "HeadInt8ZeroNotRoot",
|
|
|
|
expected: `{"A":{"a":0}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": 0
|
|
|
|
}
|
|
|
|
}
|
2021-01-16 16:16:26 +03:00
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A struct {
|
|
|
|
A int8 `json:"a"`
|
|
|
|
}
|
|
|
|
}{},
|
|
|
|
},
|
2021-01-16 20:53:54 +03:00
|
|
|
{
|
|
|
|
name: "HeadInt8ZeroNotRootOmitEmpty",
|
|
|
|
expected: `{"A":{}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A struct {
|
|
|
|
A int8 `json:"a,omitempty"`
|
|
|
|
}
|
|
|
|
}{},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "HeadInt8ZeroNotRootString",
|
|
|
|
expected: `{"A":{"a":"0"}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": "0"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A struct {
|
|
|
|
A int8 `json:"a,string"`
|
|
|
|
}
|
|
|
|
}{},
|
|
|
|
},
|
|
|
|
|
|
|
|
// HeadInt8NotRoot
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "HeadInt8NotRoot",
|
|
|
|
expected: `{"A":{"a":1}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A struct {
|
|
|
|
A int8 `json:"a"`
|
|
|
|
}
|
|
|
|
}{A: struct {
|
|
|
|
A int8 `json:"a"`
|
|
|
|
}{A: 1}},
|
|
|
|
},
|
|
|
|
{
|
2021-01-16 20:53:54 +03:00
|
|
|
name: "HeadInt8NotRootOmitEmpty",
|
2021-01-16 16:16:26 +03:00
|
|
|
expected: `{"A":{"a":1}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A struct {
|
2021-01-16 20:53:54 +03:00
|
|
|
A int8 `json:"a,omitempty"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
}{A: struct {
|
2021-01-16 20:53:54 +03:00
|
|
|
A int8 `json:"a,omitempty"`
|
|
|
|
}{A: 1}},
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
|
|
|
{
|
2021-01-16 20:53:54 +03:00
|
|
|
name: "HeadInt8NotRootString",
|
|
|
|
expected: `{"A":{"a":"1"}}`,
|
2021-01-16 16:16:26 +03:00
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
2021-01-16 20:53:54 +03:00
|
|
|
"a": "1"
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A struct {
|
2021-01-16 20:53:54 +03:00
|
|
|
A int8 `json:"a,string"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
2021-01-16 20:53:54 +03:00
|
|
|
}{A: struct {
|
|
|
|
A int8 `json:"a,string"`
|
|
|
|
}{A: 1}},
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
2021-01-16 20:53:54 +03:00
|
|
|
|
|
|
|
// HeadInt8PtrNotRoot
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
2021-01-16 20:53:54 +03:00
|
|
|
name: "HeadInt8PtrNotRoot",
|
|
|
|
expected: `{"A":{"a":1}}`,
|
2021-01-16 16:16:26 +03:00
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
2021-01-16 20:53:54 +03:00
|
|
|
"a": 1
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
2021-01-16 20:53:54 +03:00
|
|
|
A struct {
|
|
|
|
A *int8 `json:"a"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
2021-01-16 20:53:54 +03:00
|
|
|
}{A: struct {
|
|
|
|
A *int8 `json:"a"`
|
|
|
|
}{int8ptr(1)}},
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
|
|
|
{
|
2021-01-16 20:53:54 +03:00
|
|
|
name: "HeadInt8PtrNotRootOmitEmpty",
|
2021-01-16 16:16:26 +03:00
|
|
|
expected: `{"A":{"a":1}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
2021-01-16 20:53:54 +03:00
|
|
|
A struct {
|
|
|
|
A *int8 `json:"a,omitempty"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
2021-01-16 20:53:54 +03:00
|
|
|
}{A: struct {
|
|
|
|
A *int8 `json:"a,omitempty"`
|
|
|
|
}{int8ptr(1)}},
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
|
|
|
{
|
2021-01-16 20:53:54 +03:00
|
|
|
name: "HeadInt8PtrNotRootString",
|
|
|
|
expected: `{"A":{"a":"1"}}`,
|
2021-01-16 16:16:26 +03:00
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
2021-01-16 20:53:54 +03:00
|
|
|
"a": "1"
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
2021-01-16 20:53:54 +03:00
|
|
|
A struct {
|
|
|
|
A *int8 `json:"a,string"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
2021-01-16 20:53:54 +03:00
|
|
|
}{A: struct {
|
|
|
|
A *int8 `json:"a,string"`
|
|
|
|
}{int8ptr(1)}},
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
2021-01-16 20:53:54 +03:00
|
|
|
|
|
|
|
// HeadInt8PtrNilNotRoot
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
2021-01-16 20:53:54 +03:00
|
|
|
name: "HeadInt8PtrNilNotRoot",
|
2021-01-16 16:16:26 +03:00
|
|
|
expected: `{"A":{"a":null}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
2021-01-16 20:53:54 +03:00
|
|
|
"a": null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A struct {
|
|
|
|
A *int8 `json:"a"`
|
|
|
|
}
|
|
|
|
}{},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "HeadInt8PtrNilNotRootOmitEmpty",
|
|
|
|
expected: `{"A":{}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A struct {
|
|
|
|
A *int8 `json:"a,omitempty"`
|
|
|
|
}
|
|
|
|
}{},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "HeadInt8PtrNilNotRootString",
|
|
|
|
expected: `{"A":{"a":null}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A struct {
|
|
|
|
A *int8 `json:"a,string"`
|
|
|
|
}
|
|
|
|
}{},
|
|
|
|
},
|
|
|
|
|
|
|
|
// PtrHeadInt8ZeroNotRoot
|
|
|
|
{
|
|
|
|
name: "PtrHeadInt8ZeroNotRoot",
|
|
|
|
expected: `{"A":{"a":0}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A *struct {
|
|
|
|
A int8 `json:"a"`
|
|
|
|
}
|
|
|
|
}{A: new(struct {
|
|
|
|
A int8 `json:"a"`
|
|
|
|
})},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadInt8ZeroNotRootOmitEmpty",
|
|
|
|
expected: `{"A":{}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A *struct {
|
|
|
|
A int8 `json:"a,omitempty"`
|
|
|
|
}
|
|
|
|
}{A: new(struct {
|
|
|
|
A int8 `json:"a,omitempty"`
|
|
|
|
})},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadInt8ZeroNotRootString",
|
|
|
|
expected: `{"A":{"a":"0"}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": "0"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A *struct {
|
|
|
|
A int8 `json:"a,string"`
|
|
|
|
}
|
|
|
|
}{A: new(struct {
|
|
|
|
A int8 `json:"a,string"`
|
|
|
|
})},
|
|
|
|
},
|
|
|
|
|
|
|
|
// PtrHeadInt8NotRoot
|
|
|
|
{
|
|
|
|
name: "PtrHeadInt8NotRoot",
|
|
|
|
expected: `{"A":{"a":1}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A *struct {
|
|
|
|
A int8 `json:"a"`
|
|
|
|
}
|
|
|
|
}{A: &(struct {
|
|
|
|
A int8 `json:"a"`
|
|
|
|
}{A: 1})},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadInt8NotRootOmitEmpty",
|
|
|
|
expected: `{"A":{"a":1}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A *struct {
|
|
|
|
A int8 `json:"a,omitempty"`
|
|
|
|
}
|
|
|
|
}{A: &(struct {
|
|
|
|
A int8 `json:"a,omitempty"`
|
|
|
|
}{A: 1})},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadInt8NotRootString",
|
|
|
|
expected: `{"A":{"a":"1"}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": "1"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A *struct {
|
|
|
|
A int8 `json:"a,string"`
|
|
|
|
}
|
|
|
|
}{A: &(struct {
|
|
|
|
A int8 `json:"a,string"`
|
|
|
|
}{A: 1})},
|
|
|
|
},
|
|
|
|
|
|
|
|
// PtrHeadInt8PtrNotRoot
|
|
|
|
{
|
|
|
|
name: "PtrHeadInt8PtrNotRoot",
|
|
|
|
expected: `{"A":{"a":1}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A *struct {
|
|
|
|
A *int8 `json:"a"`
|
|
|
|
}
|
|
|
|
}{A: &(struct {
|
|
|
|
A *int8 `json:"a"`
|
|
|
|
}{A: int8ptr(1)})},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadInt8PtrNotRootOmitEmpty",
|
|
|
|
expected: `{"A":{"a":1}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A *struct {
|
|
|
|
A *int8 `json:"a,omitempty"`
|
|
|
|
}
|
|
|
|
}{A: &(struct {
|
|
|
|
A *int8 `json:"a,omitempty"`
|
|
|
|
}{A: int8ptr(1)})},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadInt8PtrNotRootString",
|
|
|
|
expected: `{"A":{"a":"1"}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": "1"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A *struct {
|
|
|
|
A *int8 `json:"a,string"`
|
|
|
|
}
|
|
|
|
}{A: &(struct {
|
|
|
|
A *int8 `json:"a,string"`
|
|
|
|
}{A: int8ptr(1)})},
|
|
|
|
},
|
|
|
|
|
|
|
|
// PtrHeadInt8PtrNilNotRoot
|
|
|
|
{
|
|
|
|
name: "PtrHeadInt8PtrNilNotRoot",
|
|
|
|
expected: `{"A":{"a":null}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A *struct {
|
|
|
|
A *int8 `json:"a"`
|
|
|
|
}
|
|
|
|
}{A: &(struct {
|
|
|
|
A *int8 `json:"a"`
|
|
|
|
}{A: nil})},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadInt8PtrNilNotRootOmitEmpty",
|
|
|
|
expected: `{"A":{}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A *struct {
|
|
|
|
A *int8 `json:"a,omitempty"`
|
|
|
|
}
|
|
|
|
}{A: &(struct {
|
|
|
|
A *int8 `json:"a,omitempty"`
|
|
|
|
}{A: nil})},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadInt8PtrNilNotRootString",
|
|
|
|
expected: `{"A":{"a":null}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A *struct {
|
|
|
|
A *int8 `json:"a,string"`
|
|
|
|
}
|
|
|
|
}{A: &(struct {
|
|
|
|
A *int8 `json:"a,string"`
|
|
|
|
}{A: nil})},
|
|
|
|
},
|
|
|
|
|
|
|
|
// PtrHeadInt8NilNotRoot
|
|
|
|
{
|
|
|
|
name: "PtrHeadInt8NilNotRoot",
|
|
|
|
expected: `{"A":null}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": null
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A *struct {
|
|
|
|
A *int8 `json:"a"`
|
|
|
|
}
|
|
|
|
}{A: nil},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadInt8NilNotRootOmitEmpty",
|
|
|
|
expected: `{}`,
|
|
|
|
indentExpected: `
|
|
|
|
{}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A *struct {
|
|
|
|
A *int8 `json:"a,omitempty"`
|
|
|
|
} `json:",omitempty"`
|
|
|
|
}{A: nil},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadInt8NilNotRootString",
|
|
|
|
expected: `{"A":null}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": null
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A *struct {
|
|
|
|
A *int8 `json:"a,string"`
|
|
|
|
} `json:",string"`
|
|
|
|
}{A: nil},
|
|
|
|
},
|
|
|
|
|
|
|
|
// HeadInt8ZeroMultiFieldsNotRoot
|
|
|
|
{
|
|
|
|
name: "HeadInt8ZeroMultiFieldsNotRoot",
|
|
|
|
expected: `{"A":{"a":0},"B":{"b":0}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": 0
|
|
|
|
},
|
|
|
|
"B": {
|
|
|
|
"b": 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A struct {
|
|
|
|
A int8 `json:"a"`
|
|
|
|
}
|
|
|
|
B struct {
|
|
|
|
B int8 `json:"b"`
|
|
|
|
}
|
|
|
|
}{},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "HeadInt8ZeroMultiFieldsNotRootOmitEmpty",
|
|
|
|
expected: `{"A":{},"B":{}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {},
|
|
|
|
"B": {}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A struct {
|
|
|
|
A int8 `json:"a,omitempty"`
|
|
|
|
}
|
|
|
|
B struct {
|
|
|
|
B int8 `json:"b,omitempty"`
|
|
|
|
}
|
|
|
|
}{},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "HeadInt8ZeroMultiFieldsNotRootString",
|
|
|
|
expected: `{"A":{"a":"0"},"B":{"b":"0"}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": "0"
|
|
|
|
},
|
|
|
|
"B": {
|
|
|
|
"b": "0"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A struct {
|
|
|
|
A int8 `json:"a,string"`
|
|
|
|
}
|
|
|
|
B struct {
|
|
|
|
B int8 `json:"b,string"`
|
|
|
|
}
|
|
|
|
}{},
|
|
|
|
},
|
|
|
|
|
|
|
|
// HeadInt8MultiFieldsNotRoot
|
|
|
|
{
|
|
|
|
name: "HeadInt8MultiFieldsNotRoot",
|
|
|
|
expected: `{"A":{"a":1},"B":{"b":2}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": 1
|
|
|
|
},
|
|
|
|
"B": {
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A struct {
|
|
|
|
A int8 `json:"a"`
|
|
|
|
}
|
|
|
|
B struct {
|
|
|
|
B int8 `json:"b"`
|
|
|
|
}
|
|
|
|
}{A: struct {
|
|
|
|
A int8 `json:"a"`
|
|
|
|
}{A: 1}, B: struct {
|
|
|
|
B int8 `json:"b"`
|
|
|
|
}{B: 2}},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "HeadInt8MultiFieldsNotRootOmitEmpty",
|
|
|
|
expected: `{"A":{"a":1},"B":{"b":2}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": 1
|
|
|
|
},
|
|
|
|
"B": {
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A struct {
|
|
|
|
A int8 `json:"a,omitempty"`
|
|
|
|
}
|
|
|
|
B struct {
|
|
|
|
B int8 `json:"b,omitempty"`
|
|
|
|
}
|
|
|
|
}{A: struct {
|
|
|
|
A int8 `json:"a,omitempty"`
|
|
|
|
}{A: 1}, B: struct {
|
|
|
|
B int8 `json:"b,omitempty"`
|
|
|
|
}{B: 2}},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "HeadInt8MultiFieldsNotRootString",
|
|
|
|
expected: `{"A":{"a":"1"},"B":{"b":"2"}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": "1"
|
|
|
|
},
|
|
|
|
"B": {
|
|
|
|
"b": "2"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A struct {
|
|
|
|
A int8 `json:"a,string"`
|
|
|
|
}
|
|
|
|
B struct {
|
|
|
|
B int8 `json:"b,string"`
|
|
|
|
}
|
|
|
|
}{A: struct {
|
|
|
|
A int8 `json:"a,string"`
|
|
|
|
}{A: 1}, B: struct {
|
|
|
|
B int8 `json:"b,string"`
|
|
|
|
}{B: 2}},
|
|
|
|
},
|
|
|
|
|
|
|
|
// HeadInt8PtrMultiFieldsNotRoot
|
|
|
|
{
|
|
|
|
name: "HeadInt8PtrMultiFieldsNotRoot",
|
|
|
|
expected: `{"A":{"a":1},"B":{"b":2}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": 1
|
|
|
|
},
|
|
|
|
"B": {
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A struct {
|
|
|
|
A *int8 `json:"a"`
|
|
|
|
}
|
|
|
|
B struct {
|
|
|
|
B *int8 `json:"b"`
|
|
|
|
}
|
|
|
|
}{A: struct {
|
|
|
|
A *int8 `json:"a"`
|
|
|
|
}{A: int8ptr(1)}, B: struct {
|
|
|
|
B *int8 `json:"b"`
|
|
|
|
}{B: int8ptr(2)}},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "HeadInt8PtrMultiFieldsNotRootOmitEmpty",
|
|
|
|
expected: `{"A":{"a":1},"B":{"b":2}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": 1
|
|
|
|
},
|
|
|
|
"B": {
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A struct {
|
|
|
|
A *int8 `json:"a,omitempty"`
|
|
|
|
}
|
|
|
|
B struct {
|
|
|
|
B *int8 `json:"b,omitempty"`
|
|
|
|
}
|
|
|
|
}{A: struct {
|
|
|
|
A *int8 `json:"a,omitempty"`
|
|
|
|
}{A: int8ptr(1)}, B: struct {
|
|
|
|
B *int8 `json:"b,omitempty"`
|
|
|
|
}{B: int8ptr(2)}},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "HeadInt8PtrMultiFieldsNotRootString",
|
|
|
|
expected: `{"A":{"a":"1"},"B":{"b":"2"}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": "1"
|
|
|
|
},
|
|
|
|
"B": {
|
|
|
|
"b": "2"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A struct {
|
|
|
|
A *int8 `json:"a,string"`
|
|
|
|
}
|
|
|
|
B struct {
|
|
|
|
B *int8 `json:"b,string"`
|
|
|
|
}
|
|
|
|
}{A: struct {
|
|
|
|
A *int8 `json:"a,string"`
|
|
|
|
}{A: int8ptr(1)}, B: struct {
|
|
|
|
B *int8 `json:"b,string"`
|
|
|
|
}{B: int8ptr(2)}},
|
|
|
|
},
|
|
|
|
|
|
|
|
// HeadInt8PtrNilMultiFieldsNotRoot
|
|
|
|
{
|
|
|
|
name: "HeadInt8PtrNilMultiFieldsNotRoot",
|
|
|
|
expected: `{"A":{"a":null},"B":{"b":null}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": null
|
|
|
|
},
|
|
|
|
"B": {
|
|
|
|
"b": null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A struct {
|
|
|
|
A *int8 `json:"a"`
|
|
|
|
}
|
|
|
|
B struct {
|
|
|
|
B *int8 `json:"b"`
|
|
|
|
}
|
|
|
|
}{A: struct {
|
|
|
|
A *int8 `json:"a"`
|
|
|
|
}{A: nil}, B: struct {
|
|
|
|
B *int8 `json:"b"`
|
|
|
|
}{B: nil}},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "HeadInt8PtrNilMultiFieldsNotRootOmitEmpty",
|
|
|
|
expected: `{"A":{},"B":{}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {},
|
|
|
|
"B": {}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A struct {
|
|
|
|
A *int8 `json:"a,omitempty"`
|
|
|
|
}
|
|
|
|
B struct {
|
|
|
|
B *int8 `json:"b,omitempty"`
|
|
|
|
}
|
|
|
|
}{A: struct {
|
|
|
|
A *int8 `json:"a,omitempty"`
|
|
|
|
}{A: nil}, B: struct {
|
|
|
|
B *int8 `json:"b,omitempty"`
|
|
|
|
}{B: nil}},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "HeadInt8PtrNilMultiFieldsNotRootString",
|
|
|
|
expected: `{"A":{"a":null},"B":{"b":null}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": null
|
|
|
|
},
|
|
|
|
"B": {
|
|
|
|
"b": null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
A struct {
|
|
|
|
A *int8 `json:"a,string"`
|
|
|
|
}
|
|
|
|
B struct {
|
|
|
|
B *int8 `json:"b,string"`
|
|
|
|
}
|
|
|
|
}{A: struct {
|
|
|
|
A *int8 `json:"a,string"`
|
|
|
|
}{A: nil}, B: struct {
|
|
|
|
B *int8 `json:"b,string"`
|
|
|
|
}{B: nil}},
|
|
|
|
},
|
|
|
|
|
|
|
|
// PtrHeadInt8ZeroMultiFieldsNotRoot
|
|
|
|
{
|
|
|
|
name: "PtrHeadInt8ZeroMultiFieldsNotRoot",
|
|
|
|
expected: `{"A":{"a":0},"B":{"b":0}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": 0
|
|
|
|
},
|
|
|
|
"B": {
|
|
|
|
"b": 0
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
2021-01-16 20:53:54 +03:00
|
|
|
data: &struct {
|
|
|
|
A struct {
|
|
|
|
A int8 `json:"a"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
2021-01-16 20:53:54 +03:00
|
|
|
B struct {
|
|
|
|
B int8 `json:"b"`
|
|
|
|
}
|
|
|
|
}{},
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
|
|
|
{
|
2021-01-16 20:53:54 +03:00
|
|
|
name: "PtrHeadInt8ZeroMultiFieldsNotRootOmitEmpty",
|
|
|
|
expected: `{"A":{},"B":{}}`,
|
2021-01-16 16:16:26 +03:00
|
|
|
indentExpected: `
|
|
|
|
{
|
2021-01-16 20:53:54 +03:00
|
|
|
"A": {},
|
|
|
|
"B": {}
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
`,
|
2021-01-16 20:53:54 +03:00
|
|
|
data: &struct {
|
|
|
|
A struct {
|
|
|
|
A int8 `json:"a,omitempty"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
2021-01-16 20:53:54 +03:00
|
|
|
B struct {
|
|
|
|
B int8 `json:"b,omitempty"`
|
|
|
|
}
|
|
|
|
}{},
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
|
|
|
{
|
2021-01-16 20:53:54 +03:00
|
|
|
name: "PtrHeadInt8ZeroMultiFieldsNotRootString",
|
|
|
|
expected: `{"A":{"a":"0"},"B":{"b":"0"}}`,
|
2021-01-16 16:16:26 +03:00
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
2021-01-16 20:53:54 +03:00
|
|
|
"a": "0"
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
|
|
|
"B": {
|
2021-01-16 20:53:54 +03:00
|
|
|
"b": "0"
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
2021-01-16 20:53:54 +03:00
|
|
|
data: &struct {
|
2021-01-16 16:16:26 +03:00
|
|
|
A struct {
|
2021-01-16 20:53:54 +03:00
|
|
|
A int8 `json:"a,string"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
B struct {
|
2021-01-16 20:53:54 +03:00
|
|
|
B int8 `json:"b,string"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
}{},
|
|
|
|
},
|
2021-01-16 20:53:54 +03:00
|
|
|
|
|
|
|
// PtrHeadInt8MultiFieldsNotRoot
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
2021-01-16 20:53:54 +03:00
|
|
|
name: "PtrHeadInt8MultiFieldsNotRoot",
|
2021-01-16 16:16:26 +03:00
|
|
|
expected: `{"A":{"a":1},"B":{"b":2}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": 1
|
|
|
|
},
|
|
|
|
"B": {
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
2021-01-16 20:53:54 +03:00
|
|
|
data: &struct {
|
2021-01-16 16:16:26 +03:00
|
|
|
A struct {
|
|
|
|
A int8 `json:"a"`
|
|
|
|
}
|
|
|
|
B struct {
|
|
|
|
B int8 `json:"b"`
|
|
|
|
}
|
|
|
|
}{A: struct {
|
|
|
|
A int8 `json:"a"`
|
|
|
|
}{A: 1}, B: struct {
|
|
|
|
B int8 `json:"b"`
|
|
|
|
}{B: 2}},
|
|
|
|
},
|
|
|
|
{
|
2021-01-16 20:53:54 +03:00
|
|
|
name: "PtrHeadInt8MultiFieldsNotRootOmitEmpty",
|
2021-01-16 16:16:26 +03:00
|
|
|
expected: `{"A":{"a":1},"B":{"b":2}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": 1
|
|
|
|
},
|
|
|
|
"B": {
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
2021-01-16 20:53:54 +03:00
|
|
|
data: &struct {
|
2021-01-16 16:16:26 +03:00
|
|
|
A struct {
|
2021-01-16 20:53:54 +03:00
|
|
|
A int8 `json:"a,omitempty"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
B struct {
|
2021-01-16 20:53:54 +03:00
|
|
|
B int8 `json:"b,omitempty"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
}{A: struct {
|
2021-01-16 20:53:54 +03:00
|
|
|
A int8 `json:"a,omitempty"`
|
|
|
|
}{A: 1}, B: struct {
|
|
|
|
B int8 `json:"b,omitempty"`
|
|
|
|
}{B: 2}},
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
|
|
|
{
|
2021-01-16 20:53:54 +03:00
|
|
|
name: "PtrHeadInt8MultiFieldsNotRootString",
|
|
|
|
expected: `{"A":{"a":"1"},"B":{"b":"2"}}`,
|
2021-01-16 16:16:26 +03:00
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
2021-01-16 20:53:54 +03:00
|
|
|
"a": "1"
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
|
|
|
"B": {
|
2021-01-16 20:53:54 +03:00
|
|
|
"b": "2"
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
2021-01-16 20:53:54 +03:00
|
|
|
data: &struct {
|
2021-01-16 16:16:26 +03:00
|
|
|
A struct {
|
2021-01-16 20:53:54 +03:00
|
|
|
A int8 `json:"a,string"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
B struct {
|
2021-01-16 20:53:54 +03:00
|
|
|
B int8 `json:"b,string"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
}{A: struct {
|
2021-01-16 20:53:54 +03:00
|
|
|
A int8 `json:"a,string"`
|
|
|
|
}{A: 1}, B: struct {
|
|
|
|
B int8 `json:"b,string"`
|
|
|
|
}{B: 2}},
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
2021-01-16 20:53:54 +03:00
|
|
|
|
|
|
|
// PtrHeadInt8PtrMultiFieldsNotRoot
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
2021-01-16 20:53:54 +03:00
|
|
|
name: "PtrHeadInt8PtrMultiFieldsNotRoot",
|
|
|
|
expected: `{"A":{"a":1},"B":{"b":2}}`,
|
2021-01-16 16:16:26 +03:00
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
2021-01-16 20:53:54 +03:00
|
|
|
"a": 1
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
|
|
|
"B": {
|
2021-01-16 20:53:54 +03:00
|
|
|
"b": 2
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
2021-01-16 20:53:54 +03:00
|
|
|
A *struct {
|
|
|
|
A *int8 `json:"a"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
2021-01-16 20:53:54 +03:00
|
|
|
B *struct {
|
|
|
|
B *int8 `json:"b"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
2021-01-16 20:53:54 +03:00
|
|
|
}{A: &(struct {
|
|
|
|
A *int8 `json:"a"`
|
|
|
|
}{A: int8ptr(1)}), B: &(struct {
|
|
|
|
B *int8 `json:"b"`
|
|
|
|
}{B: int8ptr(2)})},
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
|
|
|
{
|
2021-01-16 20:53:54 +03:00
|
|
|
name: "PtrHeadInt8PtrMultiFieldsNotRootOmitEmpty",
|
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-16 20:53:54 +03:00
|
|
|
A *struct {
|
|
|
|
A *int8 `json:"a,omitempty"`
|
|
|
|
}
|
|
|
|
B *struct {
|
|
|
|
B *int8 `json:"b,omitempty"`
|
|
|
|
}
|
|
|
|
}{A: &(struct {
|
|
|
|
A *int8 `json:"a,omitempty"`
|
|
|
|
}{A: int8ptr(1)}), B: &(struct {
|
|
|
|
B *int8 `json:"b,omitempty"`
|
|
|
|
}{B: int8ptr(2)})},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadInt8PtrMultiFieldsNotRootString",
|
|
|
|
expected: `{"A":{"a":"1"},"B":{"b":"2"}}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
|
|
|
"a": "1"
|
|
|
|
},
|
|
|
|
"B": {
|
|
|
|
"b": "2"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A *struct {
|
|
|
|
A *int8 `json:"a,string"`
|
|
|
|
}
|
|
|
|
B *struct {
|
|
|
|
B *int8 `json:"b,string"`
|
|
|
|
}
|
|
|
|
}{A: &(struct {
|
|
|
|
A *int8 `json:"a,string"`
|
|
|
|
}{A: int8ptr(1)}), B: &(struct {
|
|
|
|
B *int8 `json:"b,string"`
|
|
|
|
}{B: int8ptr(2)})},
|
|
|
|
},
|
|
|
|
|
|
|
|
// PtrHeadInt8PtrNilMultiFieldsNotRoot
|
|
|
|
{
|
|
|
|
name: "PtrHeadInt8PtrNilMultiFieldsNotRoot",
|
|
|
|
expected: `{"A":null,"B":null}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": null,
|
|
|
|
"B": null
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A *struct {
|
|
|
|
A *int8 `json:"a"`
|
|
|
|
}
|
|
|
|
B *struct {
|
|
|
|
B *int8 `json:"b"`
|
|
|
|
}
|
|
|
|
}{A: nil, B: nil},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadInt8PtrNilMultiFieldsNotRootOmitEmpty",
|
|
|
|
expected: `{}`,
|
|
|
|
indentExpected: `
|
|
|
|
{}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A *struct {
|
|
|
|
A *int8 `json:"a,omitempty"`
|
|
|
|
} `json:",omitempty"`
|
|
|
|
B *struct {
|
|
|
|
B *int8 `json:"b,omitempty"`
|
|
|
|
} `json:",omitempty"`
|
|
|
|
}{A: nil, B: nil},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadInt8PtrNilMultiFieldsNotRootString",
|
|
|
|
expected: `{"A":null,"B":null}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": null,
|
|
|
|
"B": null
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A *struct {
|
|
|
|
A *int8 `json:"a,string"`
|
|
|
|
} `json:",string"`
|
|
|
|
B *struct {
|
|
|
|
B *int8 `json:"b,string"`
|
|
|
|
} `json:",string"`
|
|
|
|
}{A: nil, B: nil},
|
|
|
|
},
|
|
|
|
|
|
|
|
// PtrHeadInt8NilMultiFieldsNotRoot
|
|
|
|
{
|
|
|
|
name: "PtrHeadInt8NilMultiFieldsNotRoot",
|
|
|
|
expected: `null`,
|
|
|
|
indentExpected: `
|
|
|
|
null
|
|
|
|
`,
|
|
|
|
data: (*struct {
|
|
|
|
A *struct {
|
|
|
|
A *int8 `json:"a"`
|
|
|
|
}
|
|
|
|
B *struct {
|
|
|
|
B *int8 `json:"b"`
|
|
|
|
}
|
|
|
|
})(nil),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadInt8NilMultiFieldsNotRootOmitEmpty",
|
|
|
|
expected: `null`,
|
|
|
|
indentExpected: `
|
|
|
|
null
|
|
|
|
`,
|
|
|
|
data: (*struct {
|
|
|
|
A *struct {
|
|
|
|
A *int8 `json:"a,omitempty"`
|
|
|
|
}
|
|
|
|
B *struct {
|
|
|
|
B *int8 `json:"b,omitempty"`
|
|
|
|
}
|
|
|
|
})(nil),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadInt8NilMultiFieldsNotRootString",
|
|
|
|
expected: `null`,
|
|
|
|
indentExpected: `
|
|
|
|
null
|
|
|
|
`,
|
|
|
|
data: (*struct {
|
|
|
|
A *struct {
|
|
|
|
A *int8 `json:"a,string"`
|
|
|
|
}
|
|
|
|
B *struct {
|
|
|
|
B *int8 `json:"b,string"`
|
|
|
|
}
|
|
|
|
})(nil),
|
|
|
|
},
|
|
|
|
|
|
|
|
// 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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A *struct {
|
2021-01-16 16:16:26 +03:00
|
|
|
A int8 `json:"a"`
|
2021-01-16 20:53:54 +03:00
|
|
|
B int8 `json:"b"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
2021-01-16 20:53:54 +03:00
|
|
|
B *struct {
|
|
|
|
A int8 `json:"a"`
|
2021-01-16 16:16:26 +03:00
|
|
|
B int8 `json:"b"`
|
|
|
|
}
|
2021-01-16 20:53:54 +03:00
|
|
|
}{A: &(struct {
|
2021-01-16 16:16:26 +03:00
|
|
|
A int8 `json:"a"`
|
|
|
|
B int8 `json:"b"`
|
2021-01-16 20:53:54 +03:00
|
|
|
}{A: 1, B: 2}), B: &(struct {
|
|
|
|
A int8 `json:"a"`
|
|
|
|
B int8 `json:"b"`
|
|
|
|
}{A: 3, B: 4})},
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
|
|
|
{
|
2021-01-16 20:53:54 +03:00
|
|
|
name: "PtrHeadInt8DoubleMultiFieldsNotRootOmitEmpty",
|
|
|
|
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 int8 `json:"a,omitempty"`
|
|
|
|
B int8 `json:"b,omitempty"`
|
|
|
|
}
|
|
|
|
B *struct {
|
|
|
|
A int8 `json:"a,omitempty"`
|
|
|
|
B int8 `json:"b,omitempty"`
|
|
|
|
}
|
|
|
|
}{A: &(struct {
|
|
|
|
A int8 `json:"a,omitempty"`
|
|
|
|
B int8 `json:"b,omitempty"`
|
|
|
|
}{A: 1, B: 2}), B: &(struct {
|
|
|
|
A int8 `json:"a,omitempty"`
|
|
|
|
B int8 `json:"b,omitempty"`
|
|
|
|
}{A: 3, B: 4})},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadInt8DoubleMultiFieldsNotRootString",
|
|
|
|
expected: `{"A":{"a":"1","b":"2"},"B":{"a":"3","b":"4"}}`,
|
2021-01-16 16:16:26 +03:00
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": {
|
2021-01-16 20:53:54 +03:00
|
|
|
"a": "1",
|
|
|
|
"b": "2"
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
|
|
|
"B": {
|
2021-01-16 20:53:54 +03:00
|
|
|
"a": "3",
|
|
|
|
"b": "4"
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A *struct {
|
2021-01-16 20:53:54 +03:00
|
|
|
A int8 `json:"a,string"`
|
|
|
|
B int8 `json:"b,string"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
B *struct {
|
2021-01-16 20:53:54 +03:00
|
|
|
A int8 `json:"a,string"`
|
|
|
|
B int8 `json:"b,string"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
}{A: &(struct {
|
2021-01-16 20:53:54 +03:00
|
|
|
A int8 `json:"a,string"`
|
|
|
|
B int8 `json:"b,string"`
|
|
|
|
}{A: 1, B: 2}), B: &(struct {
|
|
|
|
A int8 `json:"a,string"`
|
|
|
|
B int8 `json:"b,string"`
|
|
|
|
}{A: 3, B: 4})},
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
2021-01-16 20:53:54 +03:00
|
|
|
|
|
|
|
// PtrHeadInt8NilDoubleMultiFieldsNotRoot
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
2021-01-16 20:53:54 +03:00
|
|
|
name: "PtrHeadInt8NilDoubleMultiFieldsNotRoot",
|
2021-01-16 16:16:26 +03:00
|
|
|
expected: `{"A":null,"B":null}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": null,
|
|
|
|
"B": null
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A *struct {
|
2021-01-16 20:53:54 +03:00
|
|
|
A int8 `json:"a"`
|
|
|
|
B int8 `json:"b"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
B *struct {
|
2021-01-16 20:53:54 +03:00
|
|
|
A int8 `json:"a"`
|
|
|
|
B int8 `json:"b"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
}{A: nil, B: nil},
|
|
|
|
},
|
|
|
|
{
|
2021-01-16 20:53:54 +03:00
|
|
|
name: "PtrHeadInt8NilDoubleMultiFieldsNotRootOmitEmpty",
|
|
|
|
expected: `{}`,
|
2021-01-16 16:16:26 +03:00
|
|
|
indentExpected: `
|
2021-01-16 20:53:54 +03:00
|
|
|
{}
|
2021-01-16 16:16:26 +03:00
|
|
|
`,
|
2021-01-16 20:53:54 +03:00
|
|
|
data: &struct {
|
2021-01-16 16:16:26 +03:00
|
|
|
A *struct {
|
2021-01-16 20:53:54 +03:00
|
|
|
A int8 `json:"a,omitempty"`
|
|
|
|
B int8 `json:"b,omitempty"`
|
|
|
|
} `json:",omitempty"`
|
2021-01-16 16:16:26 +03:00
|
|
|
B *struct {
|
2021-01-16 20:53:54 +03:00
|
|
|
A int8 `json:"a,omitempty"`
|
|
|
|
B int8 `json:"b,omitempty"`
|
|
|
|
} `json:",omitempty"`
|
|
|
|
}{A: nil, B: nil},
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
|
|
|
{
|
2021-01-16 20:53:54 +03:00
|
|
|
name: "PtrHeadInt8NilDoubleMultiFieldsNotRootString",
|
|
|
|
expected: `{"A":null,"B":null}`,
|
2021-01-16 16:16:26 +03:00
|
|
|
indentExpected: `
|
|
|
|
{
|
2021-01-16 20:53:54 +03:00
|
|
|
"A": null,
|
|
|
|
"B": null
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A *struct {
|
2021-01-16 20:53:54 +03:00
|
|
|
A int8 `json:"a,string"`
|
|
|
|
B int8 `json:"b,string"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
B *struct {
|
2021-01-16 20:53:54 +03:00
|
|
|
A int8 `json:"a,string"`
|
|
|
|
B int8 `json:"b,string"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
2021-01-16 20:53:54 +03:00
|
|
|
}{A: nil, B: nil},
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
2021-01-16 20:53:54 +03:00
|
|
|
|
|
|
|
// PtrHeadInt8NilDoubleMultiFieldsNotRoot
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "PtrHeadInt8NilDoubleMultiFieldsNotRoot",
|
2021-01-16 20:53:54 +03:00
|
|
|
expected: `null`,
|
2021-01-16 16:16:26 +03:00
|
|
|
indentExpected: `
|
2021-01-16 20:53:54 +03:00
|
|
|
null
|
2021-01-16 16:16:26 +03:00
|
|
|
`,
|
2021-01-16 20:53:54 +03:00
|
|
|
data: (*struct {
|
2021-01-16 16:16:26 +03:00
|
|
|
A *struct {
|
|
|
|
A int8 `json:"a"`
|
|
|
|
B int8 `json:"b"`
|
|
|
|
}
|
|
|
|
B *struct {
|
|
|
|
A int8 `json:"a"`
|
|
|
|
B int8 `json:"b"`
|
|
|
|
}
|
2021-01-16 20:53:54 +03:00
|
|
|
})(nil),
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
|
|
|
{
|
2021-01-16 20:53:54 +03:00
|
|
|
name: "PtrHeadInt8NilDoubleMultiFieldsNotRootOmitEmpty",
|
2021-01-16 16:16:26 +03:00
|
|
|
expected: `null`,
|
|
|
|
indentExpected: `
|
|
|
|
null
|
|
|
|
`,
|
|
|
|
data: (*struct {
|
|
|
|
A *struct {
|
2021-01-16 20:53:54 +03:00
|
|
|
A int8 `json:"a,omitempty"`
|
|
|
|
B int8 `json:"b,omitempty"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
B *struct {
|
2021-01-16 20:53:54 +03:00
|
|
|
A int8 `json:"a,omitempty"`
|
|
|
|
B int8 `json:"b,omitempty"`
|
|
|
|
}
|
|
|
|
})(nil),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadInt8NilDoubleMultiFieldsNotRootString",
|
|
|
|
expected: `null`,
|
|
|
|
indentExpected: `
|
|
|
|
null
|
|
|
|
`,
|
|
|
|
data: (*struct {
|
|
|
|
A *struct {
|
|
|
|
A int8 `json:"a,string"`
|
|
|
|
B int8 `json:"b,string"`
|
|
|
|
}
|
|
|
|
B *struct {
|
|
|
|
A int8 `json:"a,string"`
|
|
|
|
B int8 `json:"b,string"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
})(nil),
|
|
|
|
},
|
2021-01-16 20:53:54 +03:00
|
|
|
|
|
|
|
// PtrHeadInt8PtrDoubleMultiFieldsNotRoot
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "PtrHeadInt8PtrDoubleMultiFieldsNotRoot",
|
|
|
|
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 *int8 `json:"a"`
|
|
|
|
B *int8 `json:"b"`
|
|
|
|
}
|
|
|
|
B *struct {
|
|
|
|
A *int8 `json:"a"`
|
|
|
|
B *int8 `json:"b"`
|
|
|
|
}
|
|
|
|
}{A: &(struct {
|
|
|
|
A *int8 `json:"a"`
|
|
|
|
B *int8 `json:"b"`
|
|
|
|
}{A: int8ptr(1), B: int8ptr(2)}), B: &(struct {
|
|
|
|
A *int8 `json:"a"`
|
|
|
|
B *int8 `json:"b"`
|
|
|
|
}{A: int8ptr(3), B: int8ptr(4)})},
|
|
|
|
},
|
2021-01-16 20:53:54 +03:00
|
|
|
{
|
|
|
|
name: "PtrHeadInt8PtrDoubleMultiFieldsNotRootOmitEmpty",
|
|
|
|
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 *int8 `json:"a,omitempty"`
|
|
|
|
B *int8 `json:"b,omitempty"`
|
|
|
|
}
|
|
|
|
B *struct {
|
|
|
|
A *int8 `json:"a,omitempty"`
|
|
|
|
B *int8 `json:"b,omitempty"`
|
|
|
|
}
|
|
|
|
}{A: &(struct {
|
|
|
|
A *int8 `json:"a,omitempty"`
|
|
|
|
B *int8 `json:"b,omitempty"`
|
|
|
|
}{A: int8ptr(1), B: int8ptr(2)}), B: &(struct {
|
|
|
|
A *int8 `json:"a,omitempty"`
|
|
|
|
B *int8 `json:"b,omitempty"`
|
|
|
|
}{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"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A *struct {
|
|
|
|
A *int8 `json:"a,string"`
|
|
|
|
B *int8 `json:"b,string"`
|
|
|
|
}
|
|
|
|
B *struct {
|
|
|
|
A *int8 `json:"a,string"`
|
|
|
|
B *int8 `json:"b,string"`
|
|
|
|
}
|
|
|
|
}{A: &(struct {
|
|
|
|
A *int8 `json:"a,string"`
|
|
|
|
B *int8 `json:"b,string"`
|
|
|
|
}{A: int8ptr(1), B: int8ptr(2)}), B: &(struct {
|
|
|
|
A *int8 `json:"a,string"`
|
|
|
|
B *int8 `json:"b,string"`
|
|
|
|
}{A: int8ptr(3), B: int8ptr(4)})},
|
|
|
|
},
|
|
|
|
|
|
|
|
// PtrHeadInt8PtrNilDoubleMultiFieldsNotRoot
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "PtrHeadInt8PtrNilDoubleMultiFieldsNotRoot",
|
|
|
|
expected: `{"A":null,"B":null}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": null,
|
|
|
|
"B": null
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A *struct {
|
|
|
|
A *int8 `json:"a"`
|
|
|
|
B *int8 `json:"b"`
|
|
|
|
}
|
|
|
|
B *struct {
|
|
|
|
A *int8 `json:"a"`
|
|
|
|
B *int8 `json:"b"`
|
|
|
|
}
|
|
|
|
}{A: nil, B: nil},
|
|
|
|
},
|
2021-01-16 20:53:54 +03:00
|
|
|
{
|
|
|
|
name: "PtrHeadInt8PtrNilDoubleMultiFieldsNotRootOmitEmpty",
|
|
|
|
expected: `{}`,
|
|
|
|
indentExpected: `
|
|
|
|
{}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A *struct {
|
|
|
|
A *int8 `json:"a,omitempty"`
|
|
|
|
B *int8 `json:"b,omitempty"`
|
|
|
|
} `json:",omitempty"`
|
|
|
|
B *struct {
|
|
|
|
A *int8 `json:"a,omitempty"`
|
|
|
|
B *int8 `json:"b,omitempty"`
|
|
|
|
} `json:",omitempty"`
|
|
|
|
}{A: nil, B: nil},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadInt8PtrNilDoubleMultiFieldsNotRootString",
|
|
|
|
expected: `{"A":null,"B":null}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"A": null,
|
|
|
|
"B": null
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: &struct {
|
|
|
|
A *struct {
|
|
|
|
A *int8 `json:"a,string"`
|
|
|
|
B *int8 `json:"b,string"`
|
|
|
|
}
|
|
|
|
B *struct {
|
|
|
|
A *int8 `json:"a,string"`
|
|
|
|
B *int8 `json:"b,string"`
|
|
|
|
}
|
|
|
|
}{A: nil, B: nil},
|
|
|
|
},
|
|
|
|
|
|
|
|
// PtrHeadInt8PtrNilDoubleMultiFieldsNotRoot
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "PtrHeadInt8PtrNilDoubleMultiFieldsNotRoot",
|
|
|
|
expected: `null`,
|
|
|
|
indentExpected: `
|
|
|
|
null
|
|
|
|
`,
|
|
|
|
data: (*struct {
|
|
|
|
A *struct {
|
|
|
|
A *int8 `json:"a"`
|
|
|
|
B *int8 `json:"b"`
|
|
|
|
}
|
|
|
|
B *struct {
|
|
|
|
A *int8 `json:"a"`
|
|
|
|
B *int8 `json:"b"`
|
|
|
|
}
|
|
|
|
})(nil),
|
|
|
|
},
|
|
|
|
{
|
2021-01-16 20:53:54 +03:00
|
|
|
name: "PtrHeadInt8PtrNilDoubleMultiFieldsNotRootOmitEmpty",
|
|
|
|
expected: `null`,
|
|
|
|
indentExpected: `
|
|
|
|
null
|
|
|
|
`,
|
|
|
|
data: (*struct {
|
|
|
|
A *struct {
|
|
|
|
A *int8 `json:"a,omitempty"`
|
|
|
|
B *int8 `json:"b,omitempty"`
|
|
|
|
}
|
|
|
|
B *struct {
|
|
|
|
A *int8 `json:"a,omitempty"`
|
|
|
|
B *int8 `json:"b,omitempty"`
|
|
|
|
}
|
|
|
|
})(nil),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrHeadInt8PtrNilDoubleMultiFieldsNotRootString",
|
|
|
|
expected: `null`,
|
|
|
|
indentExpected: `
|
|
|
|
null
|
|
|
|
`,
|
|
|
|
data: (*struct {
|
|
|
|
A *struct {
|
|
|
|
A *int8 `json:"a,string"`
|
|
|
|
B *int8 `json:"b,string"`
|
|
|
|
}
|
|
|
|
B *struct {
|
|
|
|
A *int8 `json:"a,string"`
|
|
|
|
B *int8 `json:"b,string"`
|
|
|
|
}
|
|
|
|
})(nil),
|
|
|
|
},
|
|
|
|
|
|
|
|
// AnonymousHeadInt8
|
|
|
|
{
|
|
|
|
name: "AnonymousHeadInt8",
|
|
|
|
expected: `{"a":1,"b":2}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1,
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
structInt8
|
|
|
|
B int8 `json:"b"`
|
|
|
|
}{
|
|
|
|
structInt8: structInt8{A: 1},
|
|
|
|
B: 2,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "AnonymousHeadInt8OmitEmpty",
|
|
|
|
expected: `{"a":1,"b":2}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1,
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
structInt8OmitEmpty
|
|
|
|
B int8 `json:"b,omitempty"`
|
|
|
|
}{
|
|
|
|
structInt8OmitEmpty: structInt8OmitEmpty{A: 1},
|
|
|
|
B: 2,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "AnonymousHeadInt8String",
|
|
|
|
expected: `{"a":"1","b":"2"}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": "1",
|
|
|
|
"b": "2"
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
structInt8String
|
|
|
|
B int8 `json:"b,string"`
|
|
|
|
}{
|
|
|
|
structInt8String: structInt8String{A: 1},
|
|
|
|
B: 2,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// PtrAnonymousHeadInt8
|
|
|
|
{
|
|
|
|
name: "PtrAnonymousHeadInt8",
|
|
|
|
expected: `{"a":1,"b":2}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1,
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
*structInt8
|
|
|
|
B int8 `json:"b"`
|
|
|
|
}{
|
|
|
|
structInt8: &structInt8{A: 1},
|
|
|
|
B: 2,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrAnonymousHeadInt8OmitEmpty",
|
|
|
|
expected: `{"a":1,"b":2}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1,
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
*structInt8OmitEmpty
|
|
|
|
B int8 `json:"b,omitempty"`
|
|
|
|
}{
|
|
|
|
structInt8OmitEmpty: &structInt8OmitEmpty{A: 1},
|
|
|
|
B: 2,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrAnonymousHeadInt8String",
|
|
|
|
expected: `{"a":"1","b":"2"}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": "1",
|
|
|
|
"b": "2"
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
*structInt8String
|
|
|
|
B int8 `json:"b,string"`
|
|
|
|
}{
|
|
|
|
structInt8String: &structInt8String{A: 1},
|
|
|
|
B: 2,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// NilPtrAnonymousHeadInt8
|
|
|
|
{
|
|
|
|
name: "NilPtrAnonymousHeadInt8",
|
|
|
|
expected: `{"b":2}`,
|
2021-01-16 16:16:26 +03:00
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
2021-01-16 20:53:54 +03:00
|
|
|
*structInt8
|
2021-01-16 16:16:26 +03:00
|
|
|
B int8 `json:"b"`
|
|
|
|
}{
|
2021-01-16 20:53:54 +03:00
|
|
|
structInt8: nil,
|
2021-01-16 16:16:26 +03:00
|
|
|
B: 2,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2021-01-16 20:53:54 +03:00
|
|
|
name: "NilPtrAnonymousHeadInt8OmitEmpty",
|
|
|
|
expected: `{"b":2}`,
|
2021-01-16 16:16:26 +03:00
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
2021-01-16 20:53:54 +03:00
|
|
|
*structInt8OmitEmpty
|
|
|
|
B int8 `json:"b,omitempty"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}{
|
2021-01-16 20:53:54 +03:00
|
|
|
structInt8OmitEmpty: nil,
|
|
|
|
B: 2,
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2021-01-16 20:53:54 +03:00
|
|
|
name: "NilPtrAnonymousHeadInt8String",
|
|
|
|
expected: `{"b":"2"}`,
|
2021-01-16 16:16:26 +03:00
|
|
|
indentExpected: `
|
|
|
|
{
|
2021-01-16 20:53:54 +03:00
|
|
|
"b": "2"
|
2021-01-16 16:16:26 +03:00
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
2021-01-16 20:53:54 +03:00
|
|
|
*structInt8String
|
|
|
|
B int8 `json:"b,string"`
|
2021-01-16 16:16:26 +03:00
|
|
|
}{
|
2021-01-16 20:53:54 +03:00
|
|
|
structInt8String: nil,
|
|
|
|
B: 2,
|
2021-01-16 16:16:26 +03:00
|
|
|
},
|
|
|
|
},
|
2021-01-16 20:53:54 +03:00
|
|
|
|
|
|
|
// AnonymousHeadInt8Ptr
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "AnonymousHeadInt8Ptr",
|
|
|
|
expected: `{"a":1,"b":2}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1,
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
structInt8Ptr
|
|
|
|
B *int8 `json:"b"`
|
|
|
|
}{
|
|
|
|
structInt8Ptr: structInt8Ptr{A: int8ptr(1)},
|
|
|
|
B: int8ptr(2),
|
|
|
|
},
|
|
|
|
},
|
2021-01-16 20:53:54 +03:00
|
|
|
{
|
|
|
|
name: "AnonymousHeadInt8PtrOmitEmpty",
|
|
|
|
expected: `{"a":1,"b":2}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1,
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
structInt8PtrOmitEmpty
|
|
|
|
B *int8 `json:"b,omitempty"`
|
|
|
|
}{
|
|
|
|
structInt8PtrOmitEmpty: structInt8PtrOmitEmpty{A: int8ptr(1)},
|
|
|
|
B: int8ptr(2),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "AnonymousHeadInt8PtrString",
|
|
|
|
expected: `{"a":"1","b":"2"}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": "1",
|
|
|
|
"b": "2"
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
structInt8PtrString
|
|
|
|
B *int8 `json:"b,string"`
|
|
|
|
}{
|
|
|
|
structInt8PtrString: structInt8PtrString{A: int8ptr(1)},
|
|
|
|
B: int8ptr(2),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// AnonymousHeadInt8PtrNil
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "AnonymousHeadInt8PtrNil",
|
|
|
|
expected: `{"a":null,"b":2}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": null,
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
structInt8Ptr
|
|
|
|
B *int8 `json:"b"`
|
|
|
|
}{
|
|
|
|
structInt8Ptr: structInt8Ptr{A: nil},
|
|
|
|
B: int8ptr(2),
|
|
|
|
},
|
|
|
|
},
|
2021-01-16 20:53:54 +03:00
|
|
|
{
|
|
|
|
name: "AnonymousHeadInt8PtrNilOmitEmpty",
|
|
|
|
expected: `{"b":2}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
structInt8PtrOmitEmpty
|
|
|
|
B *int8 `json:"b,omitempty"`
|
|
|
|
}{
|
|
|
|
structInt8PtrOmitEmpty: structInt8PtrOmitEmpty{A: nil},
|
|
|
|
B: int8ptr(2),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "AnonymousHeadInt8PtrNilString",
|
|
|
|
expected: `{"a":null,"b":"2"}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": null,
|
|
|
|
"b": "2"
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
structInt8PtrString
|
|
|
|
B *int8 `json:"b,string"`
|
|
|
|
}{
|
|
|
|
structInt8PtrString: structInt8PtrString{A: nil},
|
|
|
|
B: int8ptr(2),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// PtrAnonymousHeadInt8Ptr
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "PtrAnonymousHeadInt8Ptr",
|
|
|
|
expected: `{"a":1,"b":2}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1,
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
*structInt8Ptr
|
|
|
|
B *int8 `json:"b"`
|
|
|
|
}{
|
|
|
|
structInt8Ptr: &structInt8Ptr{A: int8ptr(1)},
|
|
|
|
B: int8ptr(2),
|
|
|
|
},
|
|
|
|
},
|
2021-01-16 20:53:54 +03:00
|
|
|
{
|
|
|
|
name: "PtrAnonymousHeadInt8PtrOmitEmpty",
|
|
|
|
expected: `{"a":1,"b":2}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1,
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
*structInt8PtrOmitEmpty
|
|
|
|
B *int8 `json:"b,omitempty"`
|
|
|
|
}{
|
|
|
|
structInt8PtrOmitEmpty: &structInt8PtrOmitEmpty{A: int8ptr(1)},
|
|
|
|
B: int8ptr(2),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrAnonymousHeadInt8PtrString",
|
|
|
|
expected: `{"a":"1","b":"2"}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": "1",
|
|
|
|
"b": "2"
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
*structInt8PtrString
|
|
|
|
B *int8 `json:"b,string"`
|
|
|
|
}{
|
|
|
|
structInt8PtrString: &structInt8PtrString{A: int8ptr(1)},
|
|
|
|
B: int8ptr(2),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// NilPtrAnonymousHeadInt8Ptr
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "NilPtrAnonymousHeadInt8Ptr",
|
|
|
|
expected: `{"b":2}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
*structInt8Ptr
|
|
|
|
B *int8 `json:"b"`
|
|
|
|
}{
|
|
|
|
structInt8Ptr: nil,
|
|
|
|
B: int8ptr(2),
|
|
|
|
},
|
|
|
|
},
|
2021-01-16 20:53:54 +03:00
|
|
|
{
|
|
|
|
name: "NilPtrAnonymousHeadInt8PtrOmitEmpty",
|
|
|
|
expected: `{"b":2}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"b": 2
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
*structInt8PtrOmitEmpty
|
|
|
|
B *int8 `json:"b,omitempty"`
|
|
|
|
}{
|
|
|
|
structInt8PtrOmitEmpty: nil,
|
|
|
|
B: int8ptr(2),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "NilPtrAnonymousHeadInt8PtrString",
|
|
|
|
expected: `{"b":"2"}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"b": "2"
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
*structInt8PtrString
|
|
|
|
B *int8 `json:"b,string"`
|
|
|
|
}{
|
|
|
|
structInt8PtrString: nil,
|
|
|
|
B: int8ptr(2),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// AnonymousHeadInt8Only
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "AnonymousHeadInt8Only",
|
|
|
|
expected: `{"a":1}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
structInt8
|
|
|
|
}{
|
|
|
|
structInt8: structInt8{A: 1},
|
|
|
|
},
|
|
|
|
},
|
2021-01-16 20:53:54 +03:00
|
|
|
{
|
|
|
|
name: "AnonymousHeadInt8OnlyOmitEmpty",
|
|
|
|
expected: `{"a":1}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
structInt8OmitEmpty
|
|
|
|
}{
|
|
|
|
structInt8OmitEmpty: structInt8OmitEmpty{A: 1},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "AnonymousHeadInt8OnlyString",
|
|
|
|
expected: `{"a":"1"}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": "1"
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
structInt8String
|
|
|
|
}{
|
|
|
|
structInt8String: structInt8String{A: 1},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// PtrAnonymousHeadInt8Only
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "PtrAnonymousHeadInt8Only",
|
|
|
|
expected: `{"a":1}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
*structInt8
|
|
|
|
}{
|
|
|
|
structInt8: &structInt8{A: 1},
|
|
|
|
},
|
|
|
|
},
|
2021-01-16 20:53:54 +03:00
|
|
|
{
|
|
|
|
name: "PtrAnonymousHeadInt8OnlyOmitEmpty",
|
|
|
|
expected: `{"a":1}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
*structInt8OmitEmpty
|
|
|
|
}{
|
|
|
|
structInt8OmitEmpty: &structInt8OmitEmpty{A: 1},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrAnonymousHeadInt8OnlyString",
|
|
|
|
expected: `{"a":"1"}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": "1"
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
*structInt8String
|
|
|
|
}{
|
|
|
|
structInt8String: &structInt8String{A: 1},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// NilPtrAnonymousHeadInt8Only
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "NilPtrAnonymousHeadInt8Only",
|
|
|
|
expected: `{}`,
|
|
|
|
indentExpected: `
|
|
|
|
{}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
*structInt8
|
|
|
|
}{
|
|
|
|
structInt8: nil,
|
|
|
|
},
|
|
|
|
},
|
2021-01-16 20:53:54 +03:00
|
|
|
{
|
|
|
|
name: "NilPtrAnonymousHeadInt8OnlyOmitEmpty",
|
|
|
|
expected: `{}`,
|
|
|
|
indentExpected: `
|
|
|
|
{}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
*structInt8OmitEmpty
|
|
|
|
}{
|
|
|
|
structInt8OmitEmpty: nil,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "NilPtrAnonymousHeadInt8OnlyString",
|
|
|
|
expected: `{}`,
|
|
|
|
indentExpected: `
|
|
|
|
{}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
*structInt8String
|
|
|
|
}{
|
|
|
|
structInt8String: nil,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// AnonymousHeadInt8PtrOnly
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "AnonymousHeadInt8PtrOnly",
|
|
|
|
expected: `{"a":1}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
structInt8Ptr
|
|
|
|
}{
|
|
|
|
structInt8Ptr: structInt8Ptr{A: int8ptr(1)},
|
|
|
|
},
|
|
|
|
},
|
2021-01-16 20:53:54 +03:00
|
|
|
{
|
|
|
|
name: "AnonymousHeadInt8PtrOnlyOmitEmpty",
|
|
|
|
expected: `{"a":1}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
structInt8PtrOmitEmpty
|
|
|
|
}{
|
|
|
|
structInt8PtrOmitEmpty: structInt8PtrOmitEmpty{A: int8ptr(1)},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "AnonymousHeadInt8PtrOnlyString",
|
|
|
|
expected: `{"a":"1"}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": "1"
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
structInt8PtrString
|
|
|
|
}{
|
|
|
|
structInt8PtrString: structInt8PtrString{A: int8ptr(1)},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// AnonymousHeadInt8PtrNilOnly
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "AnonymousHeadInt8PtrNilOnly",
|
|
|
|
expected: `{"a":null}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": null
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
structInt8Ptr
|
|
|
|
}{
|
|
|
|
structInt8Ptr: structInt8Ptr{A: nil},
|
|
|
|
},
|
|
|
|
},
|
2021-01-16 20:53:54 +03:00
|
|
|
{
|
|
|
|
name: "AnonymousHeadInt8PtrNilOnlyOmitEmpty",
|
|
|
|
expected: `{}`,
|
|
|
|
indentExpected: `
|
|
|
|
{}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
structInt8PtrOmitEmpty
|
|
|
|
}{
|
|
|
|
structInt8PtrOmitEmpty: structInt8PtrOmitEmpty{A: nil},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "AnonymousHeadInt8PtrNilOnlyString",
|
|
|
|
expected: `{"a":null}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": null
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
structInt8PtrString
|
|
|
|
}{
|
|
|
|
structInt8PtrString: structInt8PtrString{A: nil},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// PtrAnonymousHeadInt8PtrOnly
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "PtrAnonymousHeadInt8PtrOnly",
|
|
|
|
expected: `{"a":1}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
*structInt8Ptr
|
|
|
|
}{
|
|
|
|
structInt8Ptr: &structInt8Ptr{A: int8ptr(1)},
|
|
|
|
},
|
|
|
|
},
|
2021-01-16 20:53:54 +03:00
|
|
|
{
|
|
|
|
name: "PtrAnonymousHeadInt8PtrOnlyOmitEmpty",
|
|
|
|
expected: `{"a":1}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": 1
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
*structInt8PtrOmitEmpty
|
|
|
|
}{
|
|
|
|
structInt8PtrOmitEmpty: &structInt8PtrOmitEmpty{A: int8ptr(1)},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PtrAnonymousHeadInt8PtrOnlyString",
|
|
|
|
expected: `{"a":"1"}`,
|
|
|
|
indentExpected: `
|
|
|
|
{
|
|
|
|
"a": "1"
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
*structInt8PtrString
|
|
|
|
}{
|
|
|
|
structInt8PtrString: &structInt8PtrString{A: int8ptr(1)},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// NilPtrAnonymousHeadInt8PtrOnly
|
2021-01-16 16:16:26 +03:00
|
|
|
{
|
|
|
|
name: "NilPtrAnonymousHeadInt8PtrOnly",
|
|
|
|
expected: `{}`,
|
|
|
|
indentExpected: `
|
|
|
|
{}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
*structInt8Ptr
|
|
|
|
}{
|
|
|
|
structInt8Ptr: nil,
|
|
|
|
},
|
|
|
|
},
|
2021-01-16 20:53:54 +03:00
|
|
|
{
|
|
|
|
name: "NilPtrAnonymousHeadInt8PtrOnlyOmitEmpty",
|
|
|
|
expected: `{}`,
|
|
|
|
indentExpected: `
|
|
|
|
{}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
*structInt8PtrOmitEmpty
|
|
|
|
}{
|
|
|
|
structInt8PtrOmitEmpty: nil,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "NilPtrAnonymousHeadInt8PtrOnlyString",
|
|
|
|
expected: `{}`,
|
|
|
|
indentExpected: `
|
|
|
|
{}
|
|
|
|
`,
|
|
|
|
data: struct {
|
|
|
|
*structInt8PtrString
|
|
|
|
}{
|
|
|
|
structInt8PtrString: 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:01:43 +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())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|