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

Function TestStringSetMsgpRoundtrip

pkg/set/msgp_test.go:29–71  ·  view source on GitHub ↗

TestStringSetMsgpRoundtrip tests msgp serialization/deserialization for StringSet

(t *testing.T)

Source from the content-addressed store, hash-verified

27
28// TestStringSetMsgpRoundtrip tests msgp serialization/deserialization for StringSet
29func TestStringSetMsgpRoundtrip(t *testing.T) {
30 testCases := []struct {
31 name string
32 set StringSet
33 }{
34 {
35 name: "empty set",
36 set: NewStringSet(),
37 },
38 {
39 name: "single element",
40 set: CreateStringSet("foo"),
41 },
42 {
43 name: "multiple elements",
44 set: CreateStringSet("foo", "bar", "baz"),
45 },
46 {
47 name: "with special characters",
48 set: CreateStringSet("hello world", "test@example.com", "path/to/file"),
49 },
50 }
51
52 for _, tc := range testCases {
53 t.Run(tc.name, func(t *testing.T) {
54 // Test MarshalMsg/UnmarshalMsg
55 data, err := tc.set.MarshalMsg(nil)
56 if err != nil {
57 t.Fatalf("MarshalMsg() error = %v", err)
58 }
59
60 var decoded StringSet
61 _, err = decoded.UnmarshalMsg(data)
62 if err != nil {
63 t.Fatalf("UnmarshalMsg() error = %v", err)
64 }
65
66 if !tc.set.Equals(decoded) {
67 t.Errorf("Roundtrip failed: original=%v, decoded=%v", tc.set.ToSlice(), decoded.ToSlice())
68 }
69 })
70 }
71}
72
73// TestStringSetMsgpEncodeDecodeMsg tests EncodeMsg/DecodeMsg for StringSet
74func TestStringSetMsgpEncodeDecodeMsg(t *testing.T) {

Callers

nothing calls this directly

Calls 7

UnmarshalMsgMethod · 0.95
ToSliceMethod · 0.95
NewStringSetFunction · 0.85
CreateStringSetFunction · 0.85
MarshalMsgMethod · 0.45
EqualsMethod · 0.45
ToSliceMethod · 0.45

Tested by

no test coverage detected