go-json/cover_uint8_test.go

1787 lines
35 KiB
Go
Raw Normal View History

2021-01-16 16:16:26 +03:00
package json_test
import (
"bytes"
"testing"
"github.com/goccy/go-json"
)
func TestCoverUint8(t *testing.T) {
type structUint8 struct {
A uint8 `json:"a"`
}
type structUint8OmitEmpty struct {
A uint8 `json:"a,omitempty"`
}
type structUint8String struct {
A uint8 `json:"a,string"`
}
2021-01-16 16:16:26 +03:00
type structUint8Ptr struct {
A *uint8 `json:"a"`
}
type structUint8PtrOmitEmpty struct {
A *uint8 `json:"a,omitempty"`
}
type structUint8PtrString struct {
A *uint8 `json:"a,string"`
}
2021-01-16 16:16:26 +03:00
tests := []struct {
2021-02-15 05:27:37 +03:00
name string
data interface{}
2021-01-16 16:16:26 +03:00
}{
// HeadUint8Zero
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8Zero",
2021-01-16 16:16:26 +03:00
data: struct {
A uint8 `json:"a"`
}{},
},
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8ZeroOmitEmpty",
data: struct {
A uint8 `json:"a,omitempty"`
}{},
},
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8ZeroString",
data: struct {
A uint8 `json:"a,string"`
}{},
},
// HeadUint8
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8",
2021-01-16 16:16:26 +03:00
data: struct {
A uint8 `json:"a"`
}{A: 1},
},
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8OmitEmpty",
data: struct {
A uint8 `json:"a,omitempty"`
}{A: 1},
},
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8String",
data: struct {
A uint8 `json:"a,string"`
}{A: 1},
},
// HeadUint8Ptr
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8Ptr",
2021-01-16 16:16:26 +03:00
data: struct {
A *uint8 `json:"a"`
}{A: uint8ptr(1)},
},
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8PtrOmitEmpty",
data: struct {
A *uint8 `json:"a,omitempty"`
}{A: uint8ptr(1)},
},
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8PtrString",
data: struct {
A *uint8 `json:"a,string"`
}{A: uint8ptr(1)},
},
// HeadUint8PtrNil
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8PtrNil",
2021-01-16 16:16:26 +03:00
data: struct {
A *uint8 `json:"a"`
}{A: nil},
},
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8PtrNilOmitEmpty",
data: struct {
A *uint8 `json:"a,omitempty"`
}{A: nil},
},
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8PtrNilString",
data: struct {
A *uint8 `json:"a,string"`
}{A: nil},
},
// PtrHeadUint8Zero
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8Zero",
2021-01-16 16:16:26 +03:00
data: &struct {
A uint8 `json:"a"`
}{},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8ZeroOmitEmpty",
data: &struct {
A uint8 `json:"a,omitempty"`
}{},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8ZeroString",
data: &struct {
A uint8 `json:"a,string"`
}{},
},
// PtrHeadUint8
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8",
2021-01-16 16:16:26 +03:00
data: &struct {
A uint8 `json:"a"`
}{A: 1},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8OmitEmpty",
data: &struct {
A uint8 `json:"a,omitempty"`
}{A: 1},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8String",
data: &struct {
A uint8 `json:"a,string"`
}{A: 1},
},
// PtrHeadUint8Ptr
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8Ptr",
2021-01-16 16:16:26 +03:00
data: &struct {
A *uint8 `json:"a"`
}{A: uint8ptr(1)},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8PtrOmitEmpty",
data: &struct {
A *uint8 `json:"a,omitempty"`
}{A: uint8ptr(1)},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8PtrString",
data: &struct {
A *uint8 `json:"a,string"`
}{A: uint8ptr(1)},
},
// PtrHeadUint8PtrNil
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8PtrNil",
2021-01-16 16:16:26 +03:00
data: &struct {
A *uint8 `json:"a"`
}{A: nil},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8PtrNilOmitEmpty",
data: &struct {
A *uint8 `json:"a,omitempty"`
}{A: nil},
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8PtrNilString",
data: &struct {
A *uint8 `json:"a,string"`
}{A: nil},
},
// PtrHeadUint8Nil
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8Nil",
2021-01-16 16:16:26 +03:00
data: (*struct {
A *uint8 `json:"a"`
})(nil),
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8NilOmitEmpty",
data: (*struct {
A *uint8 `json:"a,omitempty"`
})(nil),
},
{
2021-02-15 05:27:37 +03:00
name: "PtrHeadUint8NilString",
data: (*struct {
A *uint8 `json:"a,string"`
})(nil),
},
// HeadUint8ZeroMultiFields
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8ZeroMultiFields",
2021-01-16 16:16:26 +03:00
data: struct {
A uint8 `json:"a"`
B uint8 `json:"b"`
2021-02-15 05:27:37 +03:00
C uint8 `json:"c"`
2021-01-16 16:16:26 +03:00
}{},
},
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8ZeroMultiFieldsOmitEmpty",
data: struct {
A uint8 `json:"a,omitempty"`
B uint8 `json:"b,omitempty"`
2021-02-15 05:27:37 +03:00
C uint8 `json:"c,omitempty"`
}{},
},
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8ZeroMultiFields",
data: struct {
A uint8 `json:"a,string"`
B uint8 `json:"b,string"`
2021-02-15 05:27:37 +03:00
C uint8 `json:"c,string"`
}{},
},
// HeadUint8MultiFields
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8MultiFields",
2021-01-16 16:16:26 +03:00
data: struct {
A uint8 `json:"a"`
B uint8 `json:"b"`
2021-02-15 05:27:37 +03:00
C uint8 `json:"c"`
}{A: 1, B: 2, C: 3},
2021-01-16 16:16:26 +03:00
},
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8MultiFieldsOmitEmpty",
2021-01-16 16:16:26 +03:00
data: struct {
A uint8 `json:"a,omitempty"`
B uint8 `json:"b,omitempty"`
2021-02-15 05:27:37 +03:00
C uint8 `json:"c,omitempty"`
}{A: 1, B: 2, C: 3},
2021-01-16 16:16:26 +03:00
},
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8MultiFieldsString",
2021-01-16 16:16:26 +03:00
data: struct {
A uint8 `json:"a,string"`
B uint8 `json:"b,string"`
2021-02-15 05:27:37 +03:00
C uint8 `json:"c,string"`
}{A: 1, B: 2, C: 3},
2021-01-16 16:16:26 +03:00
},
// HeadUint8PtrMultiFields
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8PtrMultiFields",
data: struct {
A *uint8 `json:"a"`
B *uint8 `json:"b"`
2021-02-15 05:27:37 +03:00
C *uint8 `json:"c"`
}{A: uint8ptr(1), B: uint8ptr(2), C: uint8ptr(3)},
2021-01-16 16:16:26 +03:00
},
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8PtrMultiFieldsOmitEmpty",
data: struct {
A *uint8 `json:"a,omitempty"`
B *uint8 `json:"b,omitempty"`
2021-02-15 05:27:37 +03:00
C *uint8 `json:"c,omitempty"`
}{A: uint8ptr(1), B: uint8ptr(2), C: uint8ptr(3)},
2021-01-16 16:16:26 +03:00
},
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8PtrMultiFieldsString",
data: struct {
A *uint8 `json:"a,string"`
B *uint8 `json:"b,string"`
2021-02-15 05:27:37 +03:00
C *uint8 `json:"c,string"`
}{A: uint8ptr(1), B: uint8ptr(2), C: uint8ptr(3)},
2021-01-16 16:16:26 +03:00
},
// HeadUint8PtrNilMultiFields
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8PtrNilMultiFields",
data: struct {
2021-01-16 16:16:26 +03:00
A *uint8 `json:"a"`
B *uint8 `json:"b"`
2021-02-15 05:27:37 +03:00
C *uint8 `json:"c"`
}{A: nil, B: nil, C: nil},
2021-01-16 16:16:26 +03:00
},
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8PtrNilMultiFieldsOmitEmpty",
data: struct {
A *uint8 `json:"a,omitempty"`
B *uint8 `json:"b,omitempty"`
2021-02-15 05:27:37 +03:00
C *uint8 `json:"c,omitempty"`
}{A: nil, B: nil, C: nil},
2021-01-16 16:16:26 +03:00
},
{
2021-02-15 05:27:37 +03:00
name: "HeadUint8PtrNilMultiFieldsString",