(t *testing.T)
| 142 | } |
| 143 | |
| 144 | func TestIntersection(t *testing.T) { |
| 145 | td := []struct { |
| 146 | name string |
| 147 | s1 Set[int] |
| 148 | s2 Set[int] |
| 149 | expSet Set[int] |
| 150 | }{ |
| 151 | {"intersection of different sets", New(0, 1, 2, 3), New(4, 5, 6), New[int]()}, |
| 152 | {"intersection of sets with elements in common", New(1, 2, 3), New(1, 2, 4), New(1, 2)}, |
| 153 | {"intersection of same sets", New(1, 2, 3), New(1, 2, 3), New(1, 2, 3)}, |
| 154 | } |
| 155 | for _, tc := range td { |
| 156 | t.Run(tc.name, func(t *testing.T) { |
| 157 | s := tc.s1.Intersection(tc.s2) |
| 158 | if s.Len() != tc.expSet.Len() { |
| 159 | t.Errorf("expecting %d elements in the set but got %d: set is %v", tc.expSet.Len(), s.Len(), s.GetItems()) |
| 160 | } |
| 161 | for _, n := range tc.expSet.GetItems() { |
| 162 | if !s.In(n) { |
| 163 | t.Errorf("expecting %d to be present in the set but was not; set is %v", n, s.GetItems()) |
| 164 | } |
| 165 | } |
| 166 | }) |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | func TestDifference(t *testing.T) { |
| 171 | td := []struct { |
nothing calls this directly
no test coverage detected