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

Function TestIntSetMsgpRoundtrip

pkg/set/msgp_test.go:212–258  ·  view source on GitHub ↗

TestIntSetMsgpRoundtrip tests msgp serialization/deserialization for IntSet

(t *testing.T)

Source from the content-addressed store, hash-verified

210
211// TestIntSetMsgpRoundtrip tests msgp serialization/deserialization for IntSet
212func TestIntSetMsgpRoundtrip(t *testing.T) {
213 testCases := []struct {
214 name string
215 set IntSet
216 }{
217 {
218 name: "empty set",
219 set: NewIntSet(),
220 },
221 {
222 name: "single element",
223 set: CreateIntSet(42),
224 },
225 {
226 name: "multiple elements",
227 set: CreateIntSet(1, 2, 3, 4, 5),
228 },
229 {
230 name: "negative numbers",
231 set: CreateIntSet(-10, -5, 0, 5, 10),
232 },
233 {
234 name: "large numbers",
235 set: CreateIntSet(1000000, 2000000, 3000000),
236 },
237 }
238
239 for _, tc := range testCases {
240 t.Run(tc.name, func(t *testing.T) {
241 // Test MarshalMsg/UnmarshalMsg
242 data, err := tc.set.MarshalMsg(nil)
243 if err != nil {
244 t.Fatalf("MarshalMsg() error = %v", err)
245 }
246
247 var decoded IntSet
248 _, err = decoded.UnmarshalMsg(data)
249 if err != nil {
250 t.Fatalf("UnmarshalMsg() error = %v", err)
251 }
252
253 if !tc.set.Equals(decoded) {
254 t.Errorf("Roundtrip failed: original=%v, decoded=%v", tc.set.ToSlice(), decoded.ToSlice())
255 }
256 })
257 }
258}
259
260// TestIntSetMsgpEncodeDecodeMsg tests EncodeMsg/DecodeMsg for IntSet
261func TestIntSetMsgpEncodeDecodeMsg(t *testing.T) {

Callers

nothing calls this directly

Calls 7

UnmarshalMsgMethod · 0.95
ToSliceMethod · 0.95
NewIntSetFunction · 0.85
CreateIntSetFunction · 0.85
MarshalMsgMethod · 0.45
EqualsMethod · 0.45
ToSliceMethod · 0.45

Tested by

no test coverage detected