You've already forked json-iterator
mirror of
https://github.com/json-iterator/go.git
synced 2025-11-26 22:40:13 +02:00
consolidate more tests
This commit is contained in:
@@ -3,6 +3,7 @@ package test
|
||||
import "math/big"
|
||||
|
||||
func init() {
|
||||
nilMap := map[string]string(nil)
|
||||
marshalCases = append(marshalCases,
|
||||
map[string]interface{}{"abc": 1},
|
||||
map[string]MyInterface{"hello": MyString("world")},
|
||||
@@ -17,10 +18,15 @@ func init() {
|
||||
uint64(2): "a",
|
||||
uint64(4): "a",
|
||||
},
|
||||
nilMap,
|
||||
&nilMap,
|
||||
)
|
||||
unmarshalCases = append(unmarshalCases, unmarshalCase{
|
||||
ptr: (*map[string]string)(nil),
|
||||
input: `{"k\"ey": "val"}`,
|
||||
}, unmarshalCase{
|
||||
ptr: (*map[string]string)(nil),
|
||||
input: `null`,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
package test
|
||||
|
||||
func init() {
|
||||
marshalCases = append(marshalCases, []interface{}{"hello"})
|
||||
}
|
||||
nilSlice := []string(nil)
|
||||
marshalCases = append(marshalCases,
|
||||
[]interface{}{"hello"},
|
||||
nilSlice,
|
||||
&nilSlice,
|
||||
)
|
||||
unmarshalCases = append(unmarshalCases, unmarshalCase{
|
||||
ptr: (*[]string)(nil),
|
||||
input: "null",
|
||||
})
|
||||
}
|
||||
|
||||
@@ -11,6 +11,11 @@ func init() {
|
||||
Field interface{}
|
||||
})(nil),
|
||||
input: `{"Field": "hello"}`,
|
||||
}, unmarshalCase{
|
||||
ptr: (*struct {
|
||||
Field int `json:"field"`
|
||||
})(nil),
|
||||
input: `{"field": null}`,
|
||||
})
|
||||
marshalCases = append(marshalCases,
|
||||
struct {
|
||||
|
||||
@@ -15,7 +15,9 @@ type unmarshalCase struct {
|
||||
|
||||
var unmarshalCases []unmarshalCase
|
||||
|
||||
var marshalCases []interface{}
|
||||
var marshalCases = []interface{}{
|
||||
nil,
|
||||
}
|
||||
|
||||
func Test_unmarshal(t *testing.T) {
|
||||
should := require.New(t)
|
||||
|
||||
Reference in New Issue
Block a user