File: slice_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, trixie-proposed-updates
  • size: 916 kB
  • sloc: sh: 19; makefile: 3
file content (125 lines) | stat: -rw-r--r-- 2,476 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
package test

func init() {
	testCases = append(testCases,
		(*[][4]bool)(nil),
		(*[][4]byte)(nil),
		(*[][4]float64)(nil),
		(*[][4]int32)(nil),
		(*[][4]*string)(nil),
		(*[][4]string)(nil),
		(*[][4]uint8)(nil),
		(*[]bool)(nil),
		(*[]byte)(nil),
		(*[]float64)(nil),
		(*[]int32)(nil),
		(*[]int64)(nil),
		(*[]map[int32]string)(nil),
		(*[]map[string]string)(nil),
		(*[4]*[4]bool)(nil),
		(*[4]*[4]byte)(nil),
		(*[4]*[4]float64)(nil),
		(*[4]*[4]int32)(nil),
		(*[4]*[4]*string)(nil),
		(*[4]*[4]string)(nil),
		(*[4]*[4]uint8)(nil),
		(*[]*bool)(nil),
		(*[]*float64)(nil),
		(*[]*int32)(nil),
		(*[]*map[int32]string)(nil),
		(*[]*map[string]string)(nil),
		(*[]*[]bool)(nil),
		(*[]*[]byte)(nil),
		(*[]*[]float64)(nil),
		(*[]*[]int32)(nil),
		(*[]*[]*string)(nil),
		(*[]*[]string)(nil),
		(*[]*[]uint8)(nil),
		(*[]*string)(nil),
		(*[]*struct {
			String string
			Int    int32
			Float  float64
			Struct struct {
				X string
			}
			Slice []string
			Map   map[string]string
		})(nil),
		(*[]*uint8)(nil),
		(*[][]bool)(nil),
		(*[][]byte)(nil),
		(*[][]float64)(nil),
		(*[][]int32)(nil),
		(*[][]*string)(nil),
		(*[][]string)(nil),
		(*[][]uint8)(nil),
		(*[]string)(nil),
		(*[]struct{})(nil),
		(*[]structEmpty)(nil),
		(*[]struct {
			F *string
		})(nil),
		(*[]struct {
			String string
			Int    int32
			Float  float64
			Struct struct {
				X string
			}
			Slice []string
			Map   map[string]string
		})(nil),
		(*[]uint8)(nil),
		(*[]jsonMarshaler)(nil),
		(*[]jsonMarshalerMap)(nil),
		(*[]textMarshaler)(nil),
		(*[]textMarshalerMap)(nil),
	)
}

type jsonMarshaler struct {
	Id string `json:"id,omitempty" db:"id"`
}

func (p *jsonMarshaler) MarshalJSON() ([]byte, error) {
	return []byte(`{}`), nil
}

func (p *jsonMarshaler) UnmarshalJSON(input []byte) error {
	p.Id = "hello"
	return nil
}

type jsonMarshalerMap map[int]int

func (p *jsonMarshalerMap) MarshalJSON() ([]byte, error) {
	return []byte(`{}`), nil
}

func (p *jsonMarshalerMap) UnmarshalJSON(input []byte) error {
	return nil
}

type textMarshaler struct {
	Id string `json:"id,omitempty" db:"id"`
}

func (p *textMarshaler) MarshalText() ([]byte, error) {
	return []byte(`{}`), nil
}

func (p *textMarshaler) UnmarshalText(input []byte) error {
	p.Id = "hello"
	return nil
}

type textMarshalerMap map[int]int

func (p *textMarshalerMap) MarshalText() ([]byte, error) {
	return []byte(`{}`), nil
}

func (p *textMarshalerMap) UnmarshalText(input []byte) error {
	return nil
}