1
0
mirror of https://github.com/json-iterator/go.git synced 2025-12-23 23:33:38 +02:00

consolidate mor tests

This commit is contained in:
Tao Wen
2018-02-13 23:49:40 +08:00
parent 761ce8cce2
commit 8fa357ab7b
33 changed files with 1132 additions and 1663 deletions

View File

@@ -0,0 +1,82 @@
package test
import (
"time"
"encoding/json"
)
func init() {
unmarshalCases = append(unmarshalCases, unmarshalCase{
ptr: (*struct {
Field interface{}
})(nil),
input: `{"Field": "hello"}`,
})
marshalCases = append(marshalCases,
struct {
Field map[string]interface{}
}{
map[string]interface{}{"hello": "world"},
},
struct {
Field map[string]interface{}
Field2 string
}{
map[string]interface{}{"hello": "world"}, "",
},
struct {
Field interface{}
}{
1024,
},
struct {
Field MyInterface
}{
MyString("hello"),
},
struct {
F *float64
}{},
// TODO: fix this
//struct {
// *time.Time
//}{},
struct {
*time.Time
}{&time.Time{}},
struct {
*StructVarious
}{&StructVarious{}},
struct {
*StructVarious
}{},
struct {
Field1 int
Field2 [1]*float64
}{},
struct {
Field interface{} `json:"field,omitempty"`
}{},
struct {
Field MyInterface `json:"field,omitempty"`
}{},
struct {
Field MyInterface `json:"field,omitempty"`
}{MyString("hello")},
struct {
Field json.Marshaler `json:"field"`
}{},
struct {
Field MyInterface `json:"field"`
}{},
struct {
Field MyInterface `json:"field"`
}{MyString("hello")},
)
}
type StructVarious struct {
Field0 string
Field1 []string
Field2 map[string]interface{}
}