TestIntSetMsgpAppendBinary tests AppendBinary for IntSet
(t *testing.T)
| 322 | |
| 323 | // TestIntSetMsgpAppendBinary tests AppendBinary for IntSet |
| 324 | func TestIntSetMsgpAppendBinary(t *testing.T) { |
| 325 | set1 := CreateIntSet(1, 2, 3) |
| 326 | set2 := CreateIntSet(100, 200, 300) |
| 327 | |
| 328 | // Append set1 |
| 329 | data, err := set1.AppendBinary(nil) |
| 330 | if err != nil { |
| 331 | t.Fatalf("AppendBinary(set1) error = %v", err) |
| 332 | } |
| 333 | |
| 334 | // Append set2 to existing data |
| 335 | data, err = set2.AppendBinary(data) |
| 336 | if err != nil { |
| 337 | t.Fatalf("AppendBinary(set2) error = %v", err) |
| 338 | } |
| 339 | |
| 340 | // Decode both sets |
| 341 | var decoded1 IntSet |
| 342 | remaining, err := decoded1.UnmarshalMsg(data) |
| 343 | if err != nil { |
| 344 | t.Fatalf("UnmarshalMsg(set1) error = %v", err) |
| 345 | } |
| 346 | |
| 347 | var decoded2 IntSet |
| 348 | _, err = decoded2.UnmarshalMsg(remaining) |
| 349 | if err != nil { |
| 350 | t.Fatalf("UnmarshalMsg(set2) error = %v", err) |
| 351 | } |
| 352 | |
| 353 | if !set1.Equals(decoded1) { |
| 354 | t.Errorf("AppendBinary failed for set1: original=%v, decoded=%v", set1.ToSlice(), decoded1.ToSlice()) |
| 355 | } |
| 356 | |
| 357 | if !set2.Equals(decoded2) { |
| 358 | t.Errorf("AppendBinary failed for set2: original=%v, decoded=%v", set2.ToSlice(), decoded2.ToSlice()) |
| 359 | } |
| 360 | } |
| 361 | |
| 362 | // TestIntSetMsgsize tests Msgsize for IntSet |
| 363 | func TestIntSetMsgsize(t *testing.T) { |
nothing calls this directly
no test coverage detected