TestStringSetMsgpRoundtrip tests msgp serialization/deserialization for StringSet
(t *testing.T)
| 27 | |
| 28 | // TestStringSetMsgpRoundtrip tests msgp serialization/deserialization for StringSet |
| 29 | func 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 |
| 74 | func TestStringSetMsgpEncodeDecodeMsg(t *testing.T) { |
nothing calls this directly
no test coverage detected