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

Function TestIntSetMsgpEncodeDecodeMsg

pkg/set/msgp_test.go:261–301  ·  view source on GitHub ↗

TestIntSetMsgpEncodeDecodeMsg tests EncodeMsg/DecodeMsg for IntSet

(t *testing.T)

Source from the content-addressed store, hash-verified

259
260// TestIntSetMsgpEncodeDecodeMsg tests EncodeMsg/DecodeMsg for IntSet
261func TestIntSetMsgpEncodeDecodeMsg(t *testing.T) {
262 testCases := []struct {
263 name string
264 set IntSet
265 }{
266 {
267 name: "empty set",
268 set: NewIntSet(),
269 },
270 {
271 name: "populated set",
272 set: CreateIntSet(100, 200, 300, 400),
273 },
274 }
275
276 for _, tc := range testCases {
277 t.Run(tc.name, func(t *testing.T) {
278 var buf bytes.Buffer
279 writer := msgp.NewWriter(&buf)
280
281 // Encode
282 err := tc.set.EncodeMsg(writer)
283 if err != nil {
284 t.Fatalf("EncodeMsg() error = %v", err)
285 }
286 writer.Flush()
287
288 // Decode
289 reader := msgp.NewReader(&buf)
290 var decoded IntSet
291 err = decoded.DecodeMsg(reader)
292 if err != nil {
293 t.Fatalf("DecodeMsg() error = %v", err)
294 }
295
296 if !tc.set.Equals(decoded) {
297 t.Errorf("EncodeMsg/DecodeMsg roundtrip failed: original=%v, decoded=%v", tc.set.ToSlice(), decoded.ToSlice())
298 }
299 })
300 }
301}
302
303// TestIntSetMsgpBinary tests MarshalBinary/UnmarshalBinary for IntSet
304func TestIntSetMsgpBinary(t *testing.T) {

Callers

nothing calls this directly

Calls 7

DecodeMsgMethod · 0.95
ToSliceMethod · 0.95
NewIntSetFunction · 0.85
CreateIntSetFunction · 0.85
EncodeMsgMethod · 0.45
EqualsMethod · 0.45
ToSliceMethod · 0.45

Tested by

no test coverage detected