You've already forked json-iterator
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:
82
value_tests/struct_test.go
Normal file
82
value_tests/struct_test.go
Normal 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{}
|
||||
}
|
||||
Reference in New Issue
Block a user