MCPcopy
hub / github.com/minio/minio-go / TestIntSet_UnmarshalJSON

Function TestIntSet_UnmarshalJSON

pkg/set/intset_test.go:108–158  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

106}
107
108func TestIntSet_UnmarshalJSON(t *testing.T) {
109 type args struct {
110 data []byte
111 expectResult []int
112 }
113 tests := []struct {
114 name string
115 set IntSet
116 args args
117 wantErr bool
118 }{
119 {
120 name: "test ints",
121 set: NewIntSet(),
122 args: args{
123 data: []byte(`[1,2,3]`),
124 expectResult: []int{1, 2, 3},
125 },
126 wantErr: false,
127 },
128 {
129 name: "test negative ints",
130 set: NewIntSet(),
131 args: args{
132 data: []byte(`[-1,-2,0,1,2]`),
133 expectResult: []int{-2, -1, 0, 1, 2},
134 },
135 wantErr: false,
136 },
137 {
138 name: "test empty array",
139 set: NewIntSet(),
140 args: args{
141 data: []byte(`[]`),
142 expectResult: []int{},
143 },
144 wantErr: false,
145 },
146 }
147 for _, tt := range tests {
148 t.Run(tt.name, func(t *testing.T) {
149 if err := tt.set.UnmarshalJSON(tt.args.data); (err != nil) != tt.wantErr {
150 t.Errorf("UnmarshalJSON() error = %v, wantErr %v", err, tt.wantErr)
151 }
152 slice := tt.set.ToSlice()
153 if !reflect.DeepEqual(slice, tt.args.expectResult) {
154 t.Errorf("IntSet() get %v, want %v", slice, tt.args.expectResult)
155 }
156 })
157 }
158}

Callers

nothing calls this directly

Calls 3

NewIntSetFunction · 0.85
UnmarshalJSONMethod · 0.45
ToSliceMethod · 0.45

Tested by

no test coverage detected