You've already forked json-iterator
mirror of
https://github.com/json-iterator/go.git
synced 2025-12-23 23:33:38 +02:00
rewrite how eface and iface are handled
This commit is contained in:
45
value_tests/iface_test.go
Normal file
45
value_tests/iface_test.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package test
|
||||
|
||||
import "io"
|
||||
|
||||
func init() {
|
||||
var pCloser1 = func(str string) *io.Closer {
|
||||
closer := io.Closer(strCloser1(str))
|
||||
return &closer
|
||||
}
|
||||
var pCloser2 = func(str string) *io.Closer {
|
||||
strCloser := strCloser2(str)
|
||||
closer := io.Closer(&strCloser)
|
||||
return &closer
|
||||
}
|
||||
marshalCases = append(marshalCases,
|
||||
pCloser1("hello"),
|
||||
pCloser2("hello"),
|
||||
)
|
||||
unmarshalCases = append(unmarshalCases, unmarshalCase{
|
||||
ptr: (*[]io.Closer)(nil),
|
||||
input: "[null]",
|
||||
}, unmarshalCase{
|
||||
obj: func() interface{} {
|
||||
strCloser := strCloser2("")
|
||||
return &struct {
|
||||
Field io.Closer
|
||||
}{
|
||||
&strCloser,
|
||||
}
|
||||
},
|
||||
input: `{"Field": "hello"}`,
|
||||
})
|
||||
}
|
||||
|
||||
type strCloser1 string
|
||||
|
||||
func (closer strCloser1) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
type strCloser2 string
|
||||
|
||||
func (closer *strCloser2) Close() error {
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user