File: iface_test.go

package info (click to toggle)
golang-github-json-iterator-go 1.1.12-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 916 kB
  • sloc: sh: 19; makefile: 3
file content (45 lines) | stat: -rw-r--r-- 812 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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
}