(t *testing.T)
| 571 | } |
| 572 | |
| 573 | func TestSInter(t *testing.T) { |
| 574 | // Creating a list of cases for testing. |
| 575 | tests := []struct { |
| 576 | name string |
| 577 | setup func(*SetStructure) |
| 578 | keys []string |
| 579 | want []string |
| 580 | wantErr error |
| 581 | }{ |
| 582 | { |
| 583 | name: "test when key empty", |
| 584 | setup: func(s *SetStructure) {}, |
| 585 | keys: []string{""}, |
| 586 | want: nil, |
| 587 | wantErr: _const.ErrKeyIsEmpty, |
| 588 | }, |
| 589 | { |
| 590 | name: "test when no keys", |
| 591 | setup: func(s *SetStructure) {}, |
| 592 | keys: []string{}, |
| 593 | want: nil, |
| 594 | wantErr: nil, |
| 595 | }, |
| 596 | { |
| 597 | name: "test when keys not found", |
| 598 | setup: func(s *SetStructure) {}, |
| 599 | keys: []string{"notfound", "notfound2"}, |
| 600 | want: nil, |
| 601 | wantErr: _const.ErrKeyNotFound, |
| 602 | }, |
| 603 | { |
| 604 | name: "test when first keys found but second not found", |
| 605 | setup: func(s *SetStructure) { |
| 606 | _ = s.SAdds("key1", 0, "mem1") |
| 607 | }, |
| 608 | keys: []string{"key1", "notfound"}, |
| 609 | want: nil, |
| 610 | wantErr: _const.ErrKeyNotFound, |
| 611 | }, |
| 612 | { |
| 613 | name: "test two members", |
| 614 | setup: func(s *SetStructure) { |
| 615 | _ = s.SAdds("key1", 0, "mem1", "mem2") |
| 616 | _ = s.SAdds("key2", 0, "mem1", "mem2") |
| 617 | }, |
| 618 | keys: []string{"key1", "key2"}, |
| 619 | want: []string{"mem1", "mem2"}, |
| 620 | wantErr: nil, |
| 621 | }, |
| 622 | { |
| 623 | name: "test three members with no intersect", |
| 624 | setup: func(s *SetStructure) { |
| 625 | _ = s.SAdds("key1", 0, "mem2", "mem1") |
| 626 | _ = s.SAdds("key2", 0, "mem3") |
| 627 | }, |
| 628 | keys: []string{"key1", "key2"}, |
| 629 | want: nil, |
| 630 | wantErr: nil, |
nothing calls this directly
no test coverage detected