go-json/cover_float64_test.go

1787 lines
36 KiB
Go
Raw Permalink Normal View History

2021-01-16 16:16:26 +03:00
package json_test
import (
"bytes"
"testing"
"github.com/goccy/go-json"
)
func TestCoverFloat64(t *testing.T) {
type structFloat64 struct {
A float64 `json:"a"`
}
type structFloat64OmitEmpty struct {
A float64 `json:"a,omitempty"`
}
type structFloat64String struct {
A float64 `json:"a,string"`
}
2021-01-16 16:16:26 +03:00
type structFloat64Ptr struct {
A *float64 `json:"a"`
}
type structFloat64PtrOmitEmpty struct {
A *float64 `json:"a,omitempty"`
}
type structFloat64PtrString struct {
A *float64 `json:"a,string"`
}
2021-01-16 16:16:26 +03:00
tests := []struct {
2021-02-15 05:31:26 +03:00
name string
data interface{}
2021-01-16 16:16:26 +03:00
}{
// HeadFloat64Zero
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:31:26 +03:00
name: "HeadFloat64Zero",
2021-01-16 16:16:26 +03:00
data: struct {
A float64 `json:"a"`
}{},
},
{
2021-02-15 05:31:26 +03:00
name: "HeadFloat64ZeroOmitEmpty",
data: struct {
A float64 `json:"a,omitempty"`
}{},
},
{
2021-02-15 05:31:26 +03:00
name: "HeadFloat64ZeroString",
data: struct {
A float64 `json:"a,string"`
}{},
},
// HeadFloat64
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:31:26 +03:00
name: "HeadFloat64",
2021-01-16 16:16:26 +03:00
data: struct {
A float64 `json:"a"`
}{A: 1},
},
{
2021-02-15 05:31:26 +03:00
name: "HeadFloat64OmitEmpty",
data: struct {
A float64 `json:"a,omitempty"`
}{A: 1},
},
{
2021-02-15 05:31:26 +03:00
name: "HeadFloat64String",
data: struct {
A float64 `json:"a,string"`
}{A: 1},
},
// HeadFloat64Ptr
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:31:26 +03:00
name: "HeadFloat64Ptr",
2021-01-16 16:16:26 +03:00
data: struct {
A *float64 `json:"a"`
}{A: float64ptr(1)},
},
{
2021-02-15 05:31:26 +03:00
name: "HeadFloat64PtrOmitEmpty",
data: struct {
A *float64 `json:"a,omitempty"`
}{A: float64ptr(1)},
},
{
2021-02-15 05:31:26 +03:00
name: "HeadFloat64PtrString",
data: struct {
A *float64 `json:"a,string"`
}{A: float64ptr(1)},
},
// HeadFloat64PtrNil
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:31:26 +03:00
name: "HeadFloat64PtrNil",
2021-01-16 16:16:26 +03:00
data: struct {
A *float64 `json:"a"`
}{A: nil},
},
{
2021-02-15 05:31:26 +03:00
name: "HeadFloat64PtrNilOmitEmpty",
data: struct {
A *float64 `json:"a,omitempty"`
}{A: nil},
},
{
2021-02-15 05:31:26 +03:00
name: "HeadFloat64PtrNilString",
data: struct {
A *float64 `json:"a,string"`
}{A: nil},
},
// PtrHeadFloat64Zero
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64Zero",
2021-01-16 16:16:26 +03:00
data: &struct {
A float64 `json:"a"`
}{},
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64ZeroOmitEmpty",
data: &struct {
A float64 `json:"a,omitempty"`
}{},
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64ZeroString",
data: &struct {
A float64 `json:"a,string"`
}{},
},
// PtrHeadFloat64
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64",
2021-01-16 16:16:26 +03:00
data: &struct {
A float64 `json:"a"`
}{A: 1},
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64OmitEmpty",
data: &struct {
A float64 `json:"a,omitempty"`
}{A: 1},
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64String",
data: &struct {
A float64 `json:"a,string"`
}{A: 1},
},
// PtrHeadFloat64Ptr
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64Ptr",
2021-01-16 16:16:26 +03:00
data: &struct {
A *float64 `json:"a"`
}{A: float64ptr(1)},
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64PtrOmitEmpty",
data: &struct {
A *float64 `json:"a,omitempty"`
}{A: float64ptr(1)},
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64PtrString",
data: &struct {
A *float64 `json:"a,string"`
}{A: float64ptr(1)},
},
// PtrHeadFloat64PtrNil
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64PtrNil",
2021-01-16 16:16:26 +03:00
data: &struct {
A *float64 `json:"a"`
}{A: nil},
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64PtrNilOmitEmpty",
data: &struct {
A *float64 `json:"a,omitempty"`
}{A: nil},
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64PtrNilString",
data: &struct {
A *float64 `json:"a,string"`
}{A: nil},
},
// PtrHeadFloat64Nil
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64Nil",
2021-01-16 16:16:26 +03:00
data: (*struct {
A *float64 `json:"a"`
})(nil),
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64NilOmitEmpty",
data: (*struct {
A *float64 `json:"a,omitempty"`
})(nil),
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64NilString",
data: (*struct {
A *float64 `json:"a,string"`
})(nil),
},
// HeadFloat64ZeroMultiFields
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:31:26 +03:00
name: "HeadFloat64ZeroMultiFields",
2021-01-16 16:16:26 +03:00
data: struct {
A float64 `json:"a"`
B float64 `json:"b"`
2021-02-15 05:31:26 +03:00
C float64 `json:"c"`
2021-01-16 16:16:26 +03:00
}{},
},
{
2021-02-15 05:31:26 +03:00
name: "HeadFloat64ZeroMultiFieldsOmitEmpty",
data: struct {
A float64 `json:"a,omitempty"`
B float64 `json:"b,omitempty"`
2021-02-15 05:31:26 +03:00
C float64 `json:"c,omitempty"`
}{},
},
{
2021-02-15 05:31:26 +03:00
name: "HeadFloat64ZeroMultiFields",
data: struct {
A float64 `json:"a,string"`
B float64 `json:"b,string"`
2021-02-15 05:31:26 +03:00
C float64 `json:"c,string"`
}{},
},
// HeadFloat64MultiFields
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:31:26 +03:00
name: "HeadFloat64MultiFields",
2021-01-16 16:16:26 +03:00
data: struct {
A float64 `json:"a"`
B float64 `json:"b"`
2021-02-15 05:31:26 +03:00
C float64 `json:"c"`
}{A: 1, B: 2, C: 3},
2021-01-16 16:16:26 +03:00
},
{
2021-02-15 05:31:26 +03:00
name: "HeadFloat64MultiFieldsOmitEmpty",
2021-01-16 16:16:26 +03:00
data: struct {
A float64 `json:"a,omitempty"`
B float64 `json:"b,omitempty"`
2021-02-15 05:31:26 +03:00
C float64 `json:"c,omitempty"`
}{A: 1, B: 2, C: 3},
2021-01-16 16:16:26 +03:00
},
{
2021-02-15 05:31:26 +03:00
name: "HeadFloat64MultiFieldsString",
2021-01-16 16:16:26 +03:00
data: struct {
A float64 `json:"a,string"`
B float64 `json:"b,string"`
2021-02-15 05:31:26 +03:00
C float64 `json:"c,string"`
}{A: 1, B: 2, C: 3},
2021-01-16 16:16:26 +03:00
},
// HeadFloat64PtrMultiFields
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:31:26 +03:00
name: "HeadFloat64PtrMultiFields",
data: struct {
A *float64 `json:"a"`
B *float64 `json:"b"`
2021-02-15 05:31:26 +03:00
C *float64 `json:"c"`
}{A: float64ptr(1), B: float64ptr(2), C: float64ptr(3)},
2021-01-16 16:16:26 +03:00
},
{
2021-02-15 05:31:26 +03:00
name: "HeadFloat64PtrMultiFieldsOmitEmpty",
data: struct {
A *float64 `json:"a,omitempty"`
B *float64 `json:"b,omitempty"`
2021-02-15 05:31:26 +03:00
C *float64 `json:"c,omitempty"`
}{A: float64ptr(1), B: float64ptr(2), C: float64ptr(3)},
2021-01-16 16:16:26 +03:00
},
{
2021-02-15 05:31:26 +03:00
name: "HeadFloat64PtrMultiFieldsString",
data: struct {
A *float64 `json:"a,string"`
B *float64 `json:"b,string"`
2021-02-15 05:31:26 +03:00
C *float64 `json:"c,string"`
}{A: float64ptr(1), B: float64ptr(2), C: float64ptr(3)},
2021-01-16 16:16:26 +03:00
},
// HeadFloat64PtrNilMultiFields
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:31:26 +03:00
name: "HeadFloat64PtrNilMultiFields",
data: struct {
2021-01-16 16:16:26 +03:00
A *float64 `json:"a"`
B *float64 `json:"b"`
2021-02-15 05:31:26 +03:00
C *float64 `json:"c"`
}{A: nil, B: nil, C: nil},
2021-01-16 16:16:26 +03:00
},
{
2021-02-15 05:31:26 +03:00
name: "HeadFloat64PtrNilMultiFieldsOmitEmpty",
data: struct {
A *float64 `json:"a,omitempty"`
B *float64 `json:"b,omitempty"`
2021-02-15 05:31:26 +03:00
C *float64 `json:"c,omitempty"`
}{A: nil, B: nil, C: nil},
2021-01-16 16:16:26 +03:00
},
{
2021-02-15 05:31:26 +03:00
name: "HeadFloat64PtrNilMultiFieldsString",
data: struct {
A *float64 `json:"a,string"`
B *float64 `json:"b,string"`
2021-02-15 05:31:26 +03:00
C *float64 `json:"c,string"`
}{A: nil, B: nil, C: nil},
},
// PtrHeadFloat64ZeroMultiFields
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64ZeroMultiFields",
data: &struct {
A float64 `json:"a"`
B float64 `json:"b"`
}{},
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64ZeroMultiFieldsOmitEmpty",
data: &struct {
A float64 `json:"a,omitempty"`
B float64 `json:"b,omitempty"`
}{},
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64ZeroMultiFieldsString",
data: &struct {
A float64 `json:"a,string"`
B float64 `json:"b,string"`
}{},
},
// PtrHeadFloat64MultiFields
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64MultiFields",
data: &struct {
A float64 `json:"a"`
B float64 `json:"b"`
}{A: 1, B: 2},
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64MultiFieldsOmitEmpty",
data: &struct {
A float64 `json:"a,omitempty"`
B float64 `json:"b,omitempty"`
}{A: 1, B: 2},
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64MultiFieldsString",
data: &struct {
A float64 `json:"a,string"`
B float64 `json:"b,string"`
}{A: 1, B: 2},
},
// PtrHeadFloat64PtrMultiFields
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64PtrMultiFields",
data: &struct {
A *float64 `json:"a"`
B *float64 `json:"b"`
}{A: float64ptr(1), B: float64ptr(2)},
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64PtrMultiFieldsOmitEmpty",
data: &struct {
A *float64 `json:"a,omitempty"`
B *float64 `json:"b,omitempty"`
}{A: float64ptr(1), B: float64ptr(2)},
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64PtrMultiFieldsString",
data: &struct {
A *float64 `json:"a,string"`
B *float64 `json:"b,string"`
}{A: float64ptr(1), B: float64ptr(2)},
},
// PtrHeadFloat64PtrNilMultiFields
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64PtrNilMultiFields",
data: &struct {
A *float64 `json:"a"`
B *float64 `json:"b"`
}{A: nil, B: nil},
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64PtrNilMultiFieldsOmitEmpty",
data: &struct {
A *float64 `json:"a,omitempty"`
B *float64 `json:"b,omitempty"`
}{A: nil, B: nil},
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64PtrNilMultiFieldsString",
data: &struct {
A *float64 `json:"a,string"`
B *float64 `json:"b,string"`
}{A: nil, B: nil},
},
// PtrHeadFloat64NilMultiFields
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64NilMultiFields",
data: (*struct {
A *float64 `json:"a"`
B *float64 `json:"b"`
})(nil),
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64NilMultiFieldsOmitEmpty",
data: (*struct {
A *float64 `json:"a,omitempty"`
B *float64 `json:"b,omitempty"`
})(nil),
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64NilMultiFieldsString",
data: (*struct {
A *float64 `json:"a,string"`
B *float64 `json:"b,string"`
})(nil),
},
// HeadFloat64ZeroNotRoot
{
2021-02-15 05:31:26 +03:00
name: "HeadFloat64ZeroNotRoot",
2021-01-16 16:16:26 +03:00
data: struct {
A struct {
A float64 `json:"a"`
}
}{},
},
{
2021-02-15 05:31:26 +03:00
name: "HeadFloat64ZeroNotRootOmitEmpty",
data: struct {
A struct {
A float64 `json:"a,omitempty"`
}
}{},
},
{
2021-02-15 05:31:26 +03:00
name: "HeadFloat64ZeroNotRootString",
data: struct {
A struct {
A float64 `json:"a,string"`
}
}{},
},
// HeadFloat64NotRoot
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:31:26 +03:00
name: "HeadFloat64NotRoot",
2021-01-16 16:16:26 +03:00
data: struct {
A struct {
A float64 `json:"a"`
}
}{A: struct {
A float64 `json:"a"`
}{A: 1}},
},
{
2021-02-15 05:31:26 +03:00
name: "HeadFloat64NotRootOmitEmpty",
2021-01-16 16:16:26 +03:00
data: struct {
A struct {
A float64 `json:"a,omitempty"`
2021-01-16 16:16:26 +03:00
}
}{A: struct {
A float64 `json:"a,omitempty"`
}{A: 1}},
2021-01-16 16:16:26 +03:00
},
{
2021-02-15 05:31:26 +03:00
name: "HeadFloat64NotRootString",
2021-01-16 16:16:26 +03:00
data: struct {
A struct {
A float64 `json:"a,string"`
2021-01-16 16:16:26 +03:00
}
}{A: struct {
A float64 `json:"a,string"`
}{A: 1}},
2021-01-16 16:16:26 +03:00
},
// HeadFloat64PtrNotRoot
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:31:26 +03:00
name: "HeadFloat64PtrNotRoot",
2021-01-16 16:16:26 +03:00
data: struct {
A struct {
A *float64 `json:"a"`
2021-01-16 16:16:26 +03:00
}
}{A: struct {
A *float64 `json:"a"`
}{float64ptr(1)}},
2021-01-16 16:16:26 +03:00
},
{
2021-02-15 05:31:26 +03:00
name: "HeadFloat64PtrNotRootOmitEmpty",
2021-01-16 16:16:26 +03:00
data: struct {
A struct {
A *float64 `json:"a,omitempty"`
2021-01-16 16:16:26 +03:00
}
}{A: struct {
A *float64 `json:"a,omitempty"`
}{float64ptr(1)}},
2021-01-16 16:16:26 +03:00
},
{
2021-02-15 05:31:26 +03:00
name: "HeadFloat64PtrNotRootString",
2021-01-16 16:16:26 +03:00
data: struct {
A struct {
A *float64 `json:"a,string"`
2021-01-16 16:16:26 +03:00
}
}{A: struct {
A *float64 `json:"a,string"`
}{float64ptr(1)}},
2021-01-16 16:16:26 +03:00
},
// HeadFloat64PtrNilNotRoot
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:31:26 +03:00
name: "HeadFloat64PtrNilNotRoot",
data: struct {
A struct {
A *float64 `json:"a"`
}
}{},
},
{
2021-02-15 05:31:26 +03:00
name: "HeadFloat64PtrNilNotRootOmitEmpty",
data: struct {
A struct {
A *float64 `json:"a,omitempty"`
}
}{},
},
{
2021-02-15 05:31:26 +03:00
name: "HeadFloat64PtrNilNotRootString",
data: struct {
A struct {
A *float64 `json:"a,string"`
}
}{},
},
// PtrHeadFloat64ZeroNotRoot
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64ZeroNotRoot",
data: struct {
A *struct {
A float64 `json:"a"`
}
}{A: new(struct {
A float64 `json:"a"`
})},
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64ZeroNotRootOmitEmpty",
data: struct {
A *struct {
A float64 `json:"a,omitempty"`
}
}{A: new(struct {
A float64 `json:"a,omitempty"`
})},
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64ZeroNotRootString",
data: struct {
A *struct {
A float64 `json:"a,string"`
}
}{A: new(struct {
A float64 `json:"a,string"`
})},
},
// PtrHeadFloat64NotRoot
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64NotRoot",
data: struct {
A *struct {
A float64 `json:"a"`
}
}{A: &(struct {
A float64 `json:"a"`
}{A: 1})},
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64NotRootOmitEmpty",
data: struct {
A *struct {
A float64 `json:"a,omitempty"`
}
}{A: &(struct {
A float64 `json:"a,omitempty"`
}{A: 1})},
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64NotRootString",
data: struct {
A *struct {
A float64 `json:"a,string"`
}
}{A: &(struct {
A float64 `json:"a,string"`
}{A: 1})},
},
// PtrHeadFloat64PtrNotRoot
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64PtrNotRoot",
data: struct {
A *struct {
A *float64 `json:"a"`
}
}{A: &(struct {
A *float64 `json:"a"`
}{A: float64ptr(1)})},
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64PtrNotRootOmitEmpty",
data: struct {
A *struct {
A *float64 `json:"a,omitempty"`
}
}{A: &(struct {
A *float64 `json:"a,omitempty"`
}{A: float64ptr(1)})},
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64PtrNotRootString",
data: struct {
A *struct {
A *float64 `json:"a,string"`
}
}{A: &(struct {
A *float64 `json:"a,string"`
}{A: float64ptr(1)})},
},
// PtrHeadFloat64PtrNilNotRoot
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64PtrNilNotRoot",
data: struct {
A *struct {
A *float64 `json:"a"`
}
}{A: &(struct {
A *float64 `json:"a"`
}{A: nil})},
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64PtrNilNotRootOmitEmpty",
data: struct {
A *struct {
A *float64 `json:"a,omitempty"`
}
}{A: &(struct {
A *float64 `json:"a,omitempty"`
}{A: nil})},
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64PtrNilNotRootString",
data: struct {
A *struct {
A *float64 `json:"a,string"`
}
}{A: &(struct {
A *float64 `json:"a,string"`
}{A: nil})},
},
// PtrHeadFloat64NilNotRoot
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64NilNotRoot",
data: struct {
A *struct {
A *float64 `json:"a"`
}
}{A: nil},
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64NilNotRootOmitEmpty",
data: struct {
A *struct {
A *float64 `json:"a,omitempty"`
} `json:",omitempty"`
}{A: nil},
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64NilNotRootString",
data: struct {
A *struct {
A *float64 `json:"a,string"`
} `json:",string"`
}{A: nil},
},
// HeadFloat64ZeroMultiFieldsNotRoot
{
2021-02-15 05:31:26 +03:00
name: "HeadFloat64ZeroMultiFieldsNotRoot",
data: struct {
A struct {
A float64 `json:"a"`
}
B struct {
B float64 `json:"b"`
}
}{},
},
{
2021-02-15 05:31:26 +03:00
name: "HeadFloat64ZeroMultiFieldsNotRootOmitEmpty",
data: struct {
A struct {
A float64 `json:"a,omitempty"`
}
B struct {
B float64 `json:"b,omitempty"`
}
}{},
},
{
2021-02-15 05:31:26 +03:00
name: "HeadFloat64ZeroMultiFieldsNotRootString",
data: struct {
A struct {
A float64 `json:"a,string"`
}
B struct {
B float64 `json:"b,string"`
}
}{},
},
// HeadFloat64MultiFieldsNotRoot
{
2021-02-15 05:31:26 +03:00
name: "HeadFloat64MultiFieldsNotRoot",
data: struct {
A struct {
A float64 `json:"a"`
}
B struct {
B float64 `json:"b"`
}
}{A: struct {
A float64 `json:"a"`
}{A: 1}, B: struct {
B float64 `json:"b"`
}{B: 2}},
},
{
2021-02-15 05:31:26 +03:00
name: "HeadFloat64MultiFieldsNotRootOmitEmpty",
data: struct {
A struct {
A float64 `json:"a,omitempty"`
}
B struct {
B float64 `json:"b,omitempty"`
}
}{A: struct {
A float64 `json:"a,omitempty"`
}{A: 1}, B: struct {
B float64 `json:"b,omitempty"`
}{B: 2}},
},
{
2021-02-15 05:31:26 +03:00
name: "HeadFloat64MultiFieldsNotRootString",
data: struct {
A struct {
A float64 `json:"a,string"`
}
B struct {
B float64 `json:"b,string"`
}
}{A: struct {
A float64 `json:"a,string"`
}{A: 1}, B: struct {
B float64 `json:"b,string"`
}{B: 2}},
},
// HeadFloat64PtrMultiFieldsNotRoot
{
2021-02-15 05:31:26 +03:00
name: "HeadFloat64PtrMultiFieldsNotRoot",
data: struct {
A struct {
A *float64 `json:"a"`
}
B struct {
B *float64 `json:"b"`
}
}{A: struct {
A *float64 `json:"a"`
}{A: float64ptr(1)}, B: struct {
B *float64 `json:"b"`
}{B: float64ptr(2)}},
},
{
2021-02-15 05:31:26 +03:00
name: "HeadFloat64PtrMultiFieldsNotRootOmitEmpty",
data: struct {
A struct {
A *float64 `json:"a,omitempty"`
}
B struct {
B *float64 `json:"b,omitempty"`
}
}{A: struct {
A *float64 `json:"a,omitempty"`
}{A: float64ptr(1)}, B: struct {
B *float64 `json:"b,omitempty"`
}{B: float64ptr(2)}},
},
{
2021-02-15 05:31:26 +03:00
name: "HeadFloat64PtrMultiFieldsNotRootString",
data: struct {
A struct {
A *float64 `json:"a,string"`
}
B struct {
B *float64 `json:"b,string"`
}
}{A: struct {
A *float64 `json:"a,string"`
}{A: float64ptr(1)}, B: struct {
B *float64 `json:"b,string"`
}{B: float64ptr(2)}},
},
// HeadFloat64PtrNilMultiFieldsNotRoot
{
2021-02-15 05:31:26 +03:00
name: "HeadFloat64PtrNilMultiFieldsNotRoot",
data: struct {
A struct {
A *float64 `json:"a"`
}
B struct {
B *float64 `json:"b"`
}
}{A: struct {
A *float64 `json:"a"`
}{A: nil}, B: struct {
B *float64 `json:"b"`
}{B: nil}},
},
{
2021-02-15 05:31:26 +03:00
name: "HeadFloat64PtrNilMultiFieldsNotRootOmitEmpty",
data: struct {
A struct {
A *float64 `json:"a,omitempty"`
}
B struct {
B *float64 `json:"b,omitempty"`
}
}{A: struct {
A *float64 `json:"a,omitempty"`
}{A: nil}, B: struct {
B *float64 `json:"b,omitempty"`
}{B: nil}},
},
{
2021-02-15 05:31:26 +03:00
name: "HeadFloat64PtrNilMultiFieldsNotRootString",
data: struct {
A struct {
A *float64 `json:"a,string"`
}
B struct {
B *float64 `json:"b,string"`
}
}{A: struct {
A *float64 `json:"a,string"`
}{A: nil}, B: struct {
B *float64 `json:"b,string"`
}{B: nil}},
},
// PtrHeadFloat64ZeroMultiFieldsNotRoot
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64ZeroMultiFieldsNotRoot",
data: &struct {
A struct {
A float64 `json:"a"`
2021-01-16 16:16:26 +03:00
}
B struct {
B float64 `json:"b"`
}
}{},
2021-01-16 16:16:26 +03:00
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64ZeroMultiFieldsNotRootOmitEmpty",
data: &struct {
A struct {
A float64 `json:"a,omitempty"`
2021-01-16 16:16:26 +03:00
}
B struct {
B float64 `json:"b,omitempty"`
}
}{},
2021-01-16 16:16:26 +03:00
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64ZeroMultiFieldsNotRootString",
data: &struct {
2021-01-16 16:16:26 +03:00
A struct {
A float64 `json:"a,string"`
2021-01-16 16:16:26 +03:00
}
B struct {
B float64 `json:"b,string"`
2021-01-16 16:16:26 +03:00
}
}{},
},
// PtrHeadFloat64MultiFieldsNotRoot
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64MultiFieldsNotRoot",
data: &struct {
2021-01-16 16:16:26 +03:00
A struct {
A float64 `json:"a"`
}
B struct {
B float64 `json:"b"`
}
}{A: struct {
A float64 `json:"a"`
}{A: 1}, B: struct {
B float64 `json:"b"`
}{B: 2}},
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64MultiFieldsNotRootOmitEmpty",
data: &struct {
2021-01-16 16:16:26 +03:00
A struct {
A float64 `json:"a,omitempty"`
2021-01-16 16:16:26 +03:00
}
B struct {
B float64 `json:"b,omitempty"`
2021-01-16 16:16:26 +03:00
}
}{A: struct {
A float64 `json:"a,omitempty"`
}{A: 1}, B: struct {
B float64 `json:"b,omitempty"`
}{B: 2}},
2021-01-16 16:16:26 +03:00
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64MultiFieldsNotRootString",
data: &struct {
2021-01-16 16:16:26 +03:00
A struct {
A float64 `json:"a,string"`
2021-01-16 16:16:26 +03:00
}
B struct {
B float64 `json:"b,string"`
2021-01-16 16:16:26 +03:00
}
}{A: struct {
A float64 `json:"a,string"`
}{A: 1}, B: struct {
B float64 `json:"b,string"`
}{B: 2}},
2021-01-16 16:16:26 +03:00
},
// PtrHeadFloat64PtrMultiFieldsNotRoot
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64PtrMultiFieldsNotRoot",
2021-01-16 16:16:26 +03:00
data: &struct {
A *struct {
A *float64 `json:"a"`
2021-01-16 16:16:26 +03:00
}
B *struct {
B *float64 `json:"b"`
2021-01-16 16:16:26 +03:00
}
}{A: &(struct {
A *float64 `json:"a"`
}{A: float64ptr(1)}), B: &(struct {
B *float64 `json:"b"`
}{B: float64ptr(2)})},
2021-01-16 16:16:26 +03:00
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64PtrMultiFieldsNotRootOmitEmpty",
2021-01-16 16:16:26 +03:00
data: &struct {
A *struct {
A *float64 `json:"a,omitempty"`
}
B *struct {
B *float64 `json:"b,omitempty"`
}
}{A: &(struct {
A *float64 `json:"a,omitempty"`
}{A: float64ptr(1)}), B: &(struct {
B *float64 `json:"b,omitempty"`
}{B: float64ptr(2)})},
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64PtrMultiFieldsNotRootString",
data: &struct {
A *struct {
A *float64 `json:"a,string"`
}
B *struct {
B *float64 `json:"b,string"`
}
}{A: &(struct {
A *float64 `json:"a,string"`
}{A: float64ptr(1)}), B: &(struct {
B *float64 `json:"b,string"`
}{B: float64ptr(2)})},
},
// PtrHeadFloat64PtrNilMultiFieldsNotRoot
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64PtrNilMultiFieldsNotRoot",
data: &struct {
A *struct {
A *float64 `json:"a"`
}
B *struct {
B *float64 `json:"b"`
}
}{A: nil, B: nil},
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64PtrNilMultiFieldsNotRootOmitEmpty",
data: &struct {
A *struct {
A *float64 `json:"a,omitempty"`
} `json:",omitempty"`
B *struct {
B *float64 `json:"b,omitempty"`
} `json:",omitempty"`
}{A: nil, B: nil},
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64PtrNilMultiFieldsNotRootString",
data: &struct {
A *struct {
A *float64 `json:"a,string"`
} `json:",string"`
B *struct {
B *float64 `json:"b,string"`
} `json:",string"`
}{A: nil, B: nil},
},
// PtrHeadFloat64NilMultiFieldsNotRoot
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64NilMultiFieldsNotRoot",
data: (*struct {
A *struct {
A *float64 `json:"a"`
}
B *struct {
B *float64 `json:"b"`
}
})(nil),
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64NilMultiFieldsNotRootOmitEmpty",
data: (*struct {
A *struct {
A *float64 `json:"a,omitempty"`
}
B *struct {
B *float64 `json:"b,omitempty"`
}
})(nil),
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64NilMultiFieldsNotRootString",
data: (*struct {
A *struct {
A *float64 `json:"a,string"`
}
B *struct {
B *float64 `json:"b,string"`
}
})(nil),
},
// PtrHeadFloat64DoubleMultiFieldsNotRoot
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64DoubleMultiFieldsNotRoot",
data: &struct {
A *struct {
2021-01-16 16:16:26 +03:00
A float64 `json:"a"`
B float64 `json:"b"`
2021-01-16 16:16:26 +03:00
}
B *struct {
A float64 `json:"a"`
2021-01-16 16:16:26 +03:00
B float64 `json:"b"`
}
}{A: &(struct {
2021-01-16 16:16:26 +03:00
A float64 `json:"a"`
B float64 `json:"b"`
}{A: 1, B: 2}), B: &(struct {
A float64 `json:"a"`
B float64 `json:"b"`
}{A: 3, B: 4})},
2021-01-16 16:16:26 +03:00
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64DoubleMultiFieldsNotRootOmitEmpty",
data: &struct {
A *struct {
A float64 `json:"a,omitempty"`
B float64 `json:"b,omitempty"`
}
B *struct {
A float64 `json:"a,omitempty"`
B float64 `json:"b,omitempty"`
}
}{A: &(struct {
A float64 `json:"a,omitempty"`
B float64 `json:"b,omitempty"`
}{A: 1, B: 2}), B: &(struct {
A float64 `json:"a,omitempty"`
B float64 `json:"b,omitempty"`
}{A: 3, B: 4})},
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64DoubleMultiFieldsNotRootString",
2021-01-16 16:16:26 +03:00
data: &struct {
A *struct {
A float64 `json:"a,string"`
B float64 `json:"b,string"`
2021-01-16 16:16:26 +03:00
}
B *struct {
A float64 `json:"a,string"`
B float64 `json:"b,string"`
2021-01-16 16:16:26 +03:00
}
}{A: &(struct {
A float64 `json:"a,string"`
B float64 `json:"b,string"`
}{A: 1, B: 2}), B: &(struct {
A float64 `json:"a,string"`
B float64 `json:"b,string"`
}{A: 3, B: 4})},
2021-01-16 16:16:26 +03:00
},
// PtrHeadFloat64NilDoubleMultiFieldsNotRoot
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64NilDoubleMultiFieldsNotRoot",
2021-01-16 16:16:26 +03:00
data: &struct {
A *struct {
A float64 `json:"a"`
B float64 `json:"b"`
2021-01-16 16:16:26 +03:00
}
B *struct {
A float64 `json:"a"`
B float64 `json:"b"`
2021-01-16 16:16:26 +03:00
}
}{A: nil, B: nil},
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64NilDoubleMultiFieldsNotRootOmitEmpty",
data: &struct {
2021-01-16 16:16:26 +03:00
A *struct {
A float64 `json:"a,omitempty"`
B float64 `json:"b,omitempty"`
} `json:",omitempty"`
2021-01-16 16:16:26 +03:00
B *struct {
A float64 `json:"a,omitempty"`
B float64 `json:"b,omitempty"`
} `json:",omitempty"`
}{A: nil, B: nil},
2021-01-16 16:16:26 +03:00
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64NilDoubleMultiFieldsNotRootString",
2021-01-16 16:16:26 +03:00
data: &struct {
A *struct {
A float64 `json:"a,string"`
B float64 `json:"b,string"`
2021-01-16 16:16:26 +03:00
}
B *struct {
A float64 `json:"a,string"`
B float64 `json:"b,string"`
2021-01-16 16:16:26 +03:00
}
}{A: nil, B: nil},
2021-01-16 16:16:26 +03:00
},
// PtrHeadFloat64NilDoubleMultiFieldsNotRoot
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64NilDoubleMultiFieldsNotRoot",
data: (*struct {
2021-01-16 16:16:26 +03:00
A *struct {
A float64 `json:"a"`
B float64 `json:"b"`
}
B *struct {
A float64 `json:"a"`
B float64 `json:"b"`
}
})(nil),
2021-01-16 16:16:26 +03:00
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64NilDoubleMultiFieldsNotRootOmitEmpty",
2021-01-16 16:16:26 +03:00
data: (*struct {
A *struct {
A float64 `json:"a,omitempty"`
B float64 `json:"b,omitempty"`
2021-01-16 16:16:26 +03:00
}
B *struct {
A float64 `json:"a,omitempty"`
B float64 `json:"b,omitempty"`
}
})(nil),
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64NilDoubleMultiFieldsNotRootString",
data: (*struct {
A *struct {
A float64 `json:"a,string"`
B float64 `json:"b,string"`
}
B *struct {
A float64 `json:"a,string"`
B float64 `json:"b,string"`
2021-01-16 16:16:26 +03:00
}
})(nil),
},
// PtrHeadFloat64PtrDoubleMultiFieldsNotRoot
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64PtrDoubleMultiFieldsNotRoot",
2021-01-16 16:16:26 +03:00
data: &struct {
A *struct {
A *float64 `json:"a"`
B *float64 `json:"b"`
}
B *struct {
A *float64 `json:"a"`
B *float64 `json:"b"`
}
}{A: &(struct {
A *float64 `json:"a"`
B *float64 `json:"b"`
}{A: float64ptr(1), B: float64ptr(2)}), B: &(struct {
A *float64 `json:"a"`
B *float64 `json:"b"`
}{A: float64ptr(3), B: float64ptr(4)})},
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64PtrDoubleMultiFieldsNotRootOmitEmpty",
data: &struct {
A *struct {
A *float64 `json:"a,omitempty"`
B *float64 `json:"b,omitempty"`
}
B *struct {
A *float64 `json:"a,omitempty"`
B *float64 `json:"b,omitempty"`
}
}{A: &(struct {
A *float64 `json:"a,omitempty"`
B *float64 `json:"b,omitempty"`
}{A: float64ptr(1), B: float64ptr(2)}), B: &(struct {
A *float64 `json:"a,omitempty"`
B *float64 `json:"b,omitempty"`
}{A: float64ptr(3), B: float64ptr(4)})},
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64PtrDoubleMultiFieldsNotRootString",
data: &struct {
A *struct {
A *float64 `json:"a,string"`
B *float64 `json:"b,string"`
}
B *struct {
A *float64 `json:"a,string"`
B *float64 `json:"b,string"`
}
}{A: &(struct {
A *float64 `json:"a,string"`
B *float64 `json:"b,string"`
}{A: float64ptr(1), B: float64ptr(2)}), B: &(struct {
A *float64 `json:"a,string"`
B *float64 `json:"b,string"`
}{A: float64ptr(3), B: float64ptr(4)})},
},
// PtrHeadFloat64PtrNilDoubleMultiFieldsNotRoot
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64PtrNilDoubleMultiFieldsNotRoot",
2021-01-16 16:16:26 +03:00
data: &struct {
A *struct {
A *float64 `json:"a"`
B *float64 `json:"b"`
}
B *struct {
A *float64 `json:"a"`
B *float64 `json:"b"`
}
}{A: nil, B: nil},
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64PtrNilDoubleMultiFieldsNotRootOmitEmpty",
data: &struct {
A *struct {
A *float64 `json:"a,omitempty"`
B *float64 `json:"b,omitempty"`
} `json:",omitempty"`
B *struct {
A *float64 `json:"a,omitempty"`
B *float64 `json:"b,omitempty"`
} `json:",omitempty"`
}{A: nil, B: nil},
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64PtrNilDoubleMultiFieldsNotRootString",
data: &struct {
A *struct {
A *float64 `json:"a,string"`
B *float64 `json:"b,string"`
}
B *struct {
A *float64 `json:"a,string"`
B *float64 `json:"b,string"`
}
}{A: nil, B: nil},
},
// PtrHeadFloat64PtrNilDoubleMultiFieldsNotRoot
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64PtrNilDoubleMultiFieldsNotRoot",
2021-01-16 16:16:26 +03:00
data: (*struct {
A *struct {
A *float64 `json:"a"`
B *float64 `json:"b"`
}
B *struct {
A *float64 `json:"a"`
B *float64 `json:"b"`
}
})(nil),
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64PtrNilDoubleMultiFieldsNotRootOmitEmpty",
data: (*struct {
A *struct {
A *float64 `json:"a,omitempty"`
B *float64 `json:"b,omitempty"`
}
B *struct {
A *float64 `json:"a,omitempty"`
B *float64 `json:"b,omitempty"`
}
})(nil),
},
{
2021-02-15 05:31:26 +03:00
name: "PtrHeadFloat64PtrNilDoubleMultiFieldsNotRootString",
data: (*struct {
A *struct {
A *float64 `json:"a,string"`
B *float64 `json:"b,string"`
}
B *struct {
A *float64 `json:"a,string"`
B *float64 `json:"b,string"`
}
})(nil),
},
// AnonymousHeadFloat64
{
2021-02-15 05:31:26 +03:00
name: "AnonymousHeadFloat64",
data: struct {
structFloat64
B float64 `json:"b"`
}{
structFloat64: structFloat64{A: 1},
B: 2,
},
},
{
2021-02-15 05:31:26 +03:00
name: "AnonymousHeadFloat64OmitEmpty",
data: struct {
structFloat64OmitEmpty
B float64 `json:"b,omitempty"`
}{
structFloat64OmitEmpty: structFloat64OmitEmpty{A: 1},
B: 2,
},
},
{
2021-02-15 05:31:26 +03:00
name: "AnonymousHeadFloat64String",
data: struct {
structFloat64String
B float64 `json:"b,string"`
}{
structFloat64String: structFloat64String{A: 1},
B: 2,
},
},
// PtrAnonymousHeadFloat64
{
2021-02-15 05:31:26 +03:00
name: "PtrAnonymousHeadFloat64",
data: struct {
*structFloat64
B float64 `json:"b"`
}{
structFloat64: &structFloat64{A: 1},
B: 2,
},
},
{
2021-02-15 05:31:26 +03:00
name: "PtrAnonymousHeadFloat64OmitEmpty",
data: struct {
*structFloat64OmitEmpty
B float64 `json:"b,omitempty"`
}{
structFloat64OmitEmpty: &structFloat64OmitEmpty{A: 1},
B: 2,
},
},
{
2021-02-15 05:31:26 +03:00
name: "PtrAnonymousHeadFloat64String",
data: struct {
*structFloat64String
B float64 `json:"b,string"`
}{
structFloat64String: &structFloat64String{A: 1},
B: 2,
},
},
// NilPtrAnonymousHeadFloat64
{
2021-02-15 05:31:26 +03:00
name: "NilPtrAnonymousHeadFloat64",
2021-01-16 16:16:26 +03:00
data: struct {
*structFloat64
2021-01-16 16:16:26 +03:00
B float64 `json:"b"`
}{
structFloat64: nil,
2021-01-16 16:16:26 +03:00
B: 2,
},
},
{
2021-02-15 05:31:26 +03:00
name: "NilPtrAnonymousHeadFloat64OmitEmpty",
2021-01-16 16:16:26 +03:00
data: struct {
*structFloat64OmitEmpty
B float64 `json:"b,omitempty"`
2021-01-16 16:16:26 +03:00
}{
structFloat64OmitEmpty: nil,
B: 2,
2021-01-16 16:16:26 +03:00
},
},
{
2021-02-15 05:31:26 +03:00
name: "NilPtrAnonymousHeadFloat64String",
2021-01-16 16:16:26 +03:00
data: struct {
*structFloat64String
B float64 `json:"b,string"`
2021-01-16 16:16:26 +03:00
}{
structFloat64String: nil,
B: 2,
2021-01-16 16:16:26 +03:00
},
},
// AnonymousHeadFloat64Ptr
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:31:26 +03:00
name: "AnonymousHeadFloat64Ptr",
2021-01-16 16:16:26 +03:00
data: struct {
structFloat64Ptr
B *float64 `json:"b"`
}{
structFloat64Ptr: structFloat64Ptr{A: float64ptr(1)},
B: float64ptr(2),
},
},
{
2021-02-15 05:31:26 +03:00
name: "AnonymousHeadFloat64PtrOmitEmpty",
data: struct {
structFloat64PtrOmitEmpty
B *float64 `json:"b,omitempty"`
}{
structFloat64PtrOmitEmpty: structFloat64PtrOmitEmpty{A: float64ptr(1)},
B: float64ptr(2),
},
},
{
2021-02-15 05:31:26 +03:00
name: "AnonymousHeadFloat64PtrString",
data: struct {
structFloat64PtrString
B *float64 `json:"b,string"`
}{
structFloat64PtrString: structFloat64PtrString{A: float64ptr(1)},
B: float64ptr(2),
},
},
// AnonymousHeadFloat64PtrNil
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:31:26 +03:00
name: "AnonymousHeadFloat64PtrNil",
2021-01-16 16:16:26 +03:00
data: struct {
structFloat64Ptr
B *float64 `json:"b"`
}{
structFloat64Ptr: structFloat64Ptr{A: nil},
B: float64ptr(2),
},
},
{
2021-02-15 05:31:26 +03:00
name: "AnonymousHeadFloat64PtrNilOmitEmpty",
data: struct {
structFloat64PtrOmitEmpty
B *float64 `json:"b,omitempty"`
}{
structFloat64PtrOmitEmpty: structFloat64PtrOmitEmpty{A: nil},
B: float64ptr(2),
},
},
{
2021-02-15 05:31:26 +03:00
name: "AnonymousHeadFloat64PtrNilString",
data: struct {
structFloat64PtrString
B *float64 `json:"b,string"`
}{
structFloat64PtrString: structFloat64PtrString{A: nil},
B: float64ptr(2),
},
},
// PtrAnonymousHeadFloat64Ptr
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:31:26 +03:00
name: "PtrAnonymousHeadFloat64Ptr",
2021-01-16 16:16:26 +03:00
data: struct {
*structFloat64Ptr
B *float64 `json:"b"`
}{
structFloat64Ptr: &structFloat64Ptr{A: float64ptr(1)},
B: float64ptr(2),
},
},
{
2021-02-15 05:31:26 +03:00
name: "PtrAnonymousHeadFloat64PtrOmitEmpty",
data: struct {
*structFloat64PtrOmitEmpty
B *float64 `json:"b,omitempty"`
}{
structFloat64PtrOmitEmpty: &structFloat64PtrOmitEmpty{A: float64ptr(1)},
B: float64ptr(2),
},
},
{
2021-02-15 05:31:26 +03:00
name: "PtrAnonymousHeadFloat64PtrString",
data: struct {
*structFloat64PtrString
B *float64 `json:"b,string"`
}{
structFloat64PtrString: &structFloat64PtrString{A: float64ptr(1)},
B: float64ptr(2),
},
},
// NilPtrAnonymousHeadFloat64Ptr
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:31:26 +03:00
name: "NilPtrAnonymousHeadFloat64Ptr",
2021-01-16 16:16:26 +03:00
data: struct {
*structFloat64Ptr
B *float64 `json:"b"`
}{
structFloat64Ptr: nil,
B: float64ptr(2),
},
},
{
2021-02-15 05:31:26 +03:00
name: "NilPtrAnonymousHeadFloat64PtrOmitEmpty",
data: struct {
*structFloat64PtrOmitEmpty
B *float64 `json:"b,omitempty"`
}{
structFloat64PtrOmitEmpty: nil,
B: float64ptr(2),
},
},
{
2021-02-15 05:31:26 +03:00
name: "NilPtrAnonymousHeadFloat64PtrString",
data: struct {
*structFloat64PtrString
B *float64 `json:"b,string"`
}{
structFloat64PtrString: nil,
B: float64ptr(2),
},
},
// AnonymousHeadFloat64Only
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:31:26 +03:00
name: "AnonymousHeadFloat64Only",
2021-01-16 16:16:26 +03:00
data: struct {
structFloat64
}{
structFloat64: structFloat64{A: 1},
},
},
{
2021-02-15 05:31:26 +03:00
name: "AnonymousHeadFloat64OnlyOmitEmpty",
data: struct {
structFloat64OmitEmpty
}{
structFloat64OmitEmpty: structFloat64OmitEmpty{A: 1},
},
},
{
2021-02-15 05:31:26 +03:00
name: "AnonymousHeadFloat64OnlyString",
data: struct {
structFloat64String
}{
structFloat64String: structFloat64String{A: 1},
},
},
// PtrAnonymousHeadFloat64Only
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:31:26 +03:00
name: "PtrAnonymousHeadFloat64Only",
2021-01-16 16:16:26 +03:00
data: struct {
*structFloat64
}{
structFloat64: &structFloat64{A: 1},
},
},
{
2021-02-15 05:31:26 +03:00
name: "PtrAnonymousHeadFloat64OnlyOmitEmpty",
data: struct {
*structFloat64OmitEmpty
}{
structFloat64OmitEmpty: &structFloat64OmitEmpty{A: 1},
},
},
{
2021-02-15 05:31:26 +03:00
name: "PtrAnonymousHeadFloat64OnlyString",
data: struct {
*structFloat64String
}{
structFloat64String: &structFloat64String{A: 1},
},
},
// NilPtrAnonymousHeadFloat64Only
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:31:26 +03:00
name: "NilPtrAnonymousHeadFloat64Only",
2021-01-16 16:16:26 +03:00
data: struct {
*structFloat64
}{
structFloat64: nil,
},
},
{
2021-02-15 05:31:26 +03:00
name: "NilPtrAnonymousHeadFloat64OnlyOmitEmpty",
data: struct {
*structFloat64OmitEmpty
}{
structFloat64OmitEmpty: nil,
},
},
{
2021-02-15 05:31:26 +03:00
name: "NilPtrAnonymousHeadFloat64OnlyString",
data: struct {
*structFloat64String
}{
structFloat64String: nil,
},
},
// AnonymousHeadFloat64PtrOnly
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:31:26 +03:00
name: "AnonymousHeadFloat64PtrOnly",
2021-01-16 16:16:26 +03:00
data: struct {
structFloat64Ptr
}{
structFloat64Ptr: structFloat64Ptr{A: float64ptr(1)},
},
},
{
2021-02-15 05:31:26 +03:00
name: "AnonymousHeadFloat64PtrOnlyOmitEmpty",
data: struct {
structFloat64PtrOmitEmpty
}{
structFloat64PtrOmitEmpty: structFloat64PtrOmitEmpty{A: float64ptr(1)},
},
},
{
2021-02-15 05:31:26 +03:00
name: "AnonymousHeadFloat64PtrOnlyString",
data: struct {
structFloat64PtrString
}{
structFloat64PtrString: structFloat64PtrString{A: float64ptr(1)},
},
},
// AnonymousHeadFloat64PtrNilOnly
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:31:26 +03:00
name: "AnonymousHeadFloat64PtrNilOnly",
2021-01-16 16:16:26 +03:00
data: struct {
structFloat64Ptr
}{
structFloat64Ptr: structFloat64Ptr{A: nil},
},
},
{
2021-02-15 05:31:26 +03:00
name: "AnonymousHeadFloat64PtrNilOnlyOmitEmpty",
data: struct {
structFloat64PtrOmitEmpty
}{
structFloat64PtrOmitEmpty: structFloat64PtrOmitEmpty{A: nil},
},
},
{
2021-02-15 05:31:26 +03:00
name: "AnonymousHeadFloat64PtrNilOnlyString",
data: struct {
structFloat64PtrString
}{
structFloat64PtrString: structFloat64PtrString{A: nil},
},
},
// PtrAnonymousHeadFloat64PtrOnly
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:31:26 +03:00
name: "PtrAnonymousHeadFloat64PtrOnly",
2021-01-16 16:16:26 +03:00
data: struct {
*structFloat64Ptr
}{
structFloat64Ptr: &structFloat64Ptr{A: float64ptr(1)},
},
},
{
2021-02-15 05:31:26 +03:00
name: "PtrAnonymousHeadFloat64PtrOnlyOmitEmpty",
data: struct {
*structFloat64PtrOmitEmpty
}{
structFloat64PtrOmitEmpty: &structFloat64PtrOmitEmpty{A: float64ptr(1)},
},
},
{
2021-02-15 05:31:26 +03:00
name: "PtrAnonymousHeadFloat64PtrOnlyString",
data: struct {
*structFloat64PtrString
}{
structFloat64PtrString: &structFloat64PtrString{A: float64ptr(1)},
},
},
// NilPtrAnonymousHeadFloat64PtrOnly
2021-01-16 16:16:26 +03:00
{
2021-02-15 05:31:26 +03:00
name: "NilPtrAnonymousHeadFloat64PtrOnly",
2021-01-16 16:16:26 +03:00
data: struct {
*structFloat64Ptr
}{
structFloat64Ptr: nil,
},
},
{
2021-02-15 05:31:26 +03:00
name: "NilPtrAnonymousHeadFloat64PtrOnlyOmitEmpty",
data: struct {
*structFloat64PtrOmitEmpty
}{
structFloat64PtrOmitEmpty: nil,
},
},
{
2021-02-15 05:31:26 +03:00
name: "NilPtrAnonymousHeadFloat64PtrOnlyString",
data: struct {
*structFloat64PtrString
}{
structFloat64PtrString: 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 {
2021-02-15 05:31:26 +03:00
t.Fatalf("%s(htmlEscape:%T): %+v: %s", test.name, htmlEscape, test.data, err)
2021-01-16 16:16:26 +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
}
}
}
}