1
0
mirror of https://github.com/json-iterator/go.git synced 2025-06-15 22:50:24 +02:00

rewrite how eface and iface are handled

This commit is contained in:
Tao Wen
2018-02-21 12:16:50 +08:00
parent ea6403326b
commit 2fcbb23d96
13 changed files with 301 additions and 243 deletions

View File

@ -1,25 +1,39 @@
package test
func init() {
var pEFace = func(val interface{}) *interface{} {
return &val
}
var pInt = func(val int) *int {
return &val
}
unmarshalCases = append(unmarshalCases, unmarshalCase{
ptr: (**interface{})(nil),
input: `"hello"`,
}, unmarshalCase{
ptr: (**interface{})(nil),
input: `1e1`,
}, unmarshalCase{
ptr: (**interface{})(nil),
input: `1.0e1`,
})
marshalCases = append(marshalCases,
pEFace("hello"),
(*int)(nil),
pInt(100),
)
unmarshalCases = append(unmarshalCases, unmarshalCase{
obj: func() interface{} {
var i int
return &i
},
input: "null",
}, unmarshalCase{
obj: func() interface{} {
var i *int
return &i
},
input: "10",
}, unmarshalCase{
obj: func() interface{} {
var i int
pi := &i
return &pi
},
input: "null",
}, unmarshalCase{
obj: func() interface{} {
var i int
pi := &i
ppi := &pi
return &ppi
},
input: "null",
})
}