(t *testing.T)
| 168 | } |
| 169 | |
| 170 | func TestDifference(t *testing.T) { |
| 171 | td := []struct { |
| 172 | name string |
| 173 | s1 Set[int] |
| 174 | s2 Set[int] |
| 175 | expSet Set[int] |
| 176 | }{ |
| 177 | {"difference of different sets", New(1, 2, 3), New(4, 5, 6), New(1, 2, 3)}, |
| 178 | {"difference of sets with elements in common", New(1, 2, 3), New(1, 2, 4), New(3)}, |
| 179 | {"difference of same sets", New(1, 2, 3), New(1, 2, 3), New[int]()}, |
| 180 | } |
| 181 | for _, tc := range td { |
| 182 | t.Run(tc.name, func(t *testing.T) { |
| 183 | s := tc.s1.Difference(tc.s2) |
| 184 | if s.Len() != tc.expSet.Len() { |
| 185 | t.Errorf("expecting %d elements in the set but got %d: set is %v", tc.expSet.Len(), s.Len(), s.GetItems()) |
| 186 | } |
| 187 | for _, n := range tc.expSet.GetItems() { |
| 188 | if !s.In(n) { |
| 189 | t.Errorf("expecting %d to be present in the set but was not; set is %v", n, s.GetItems()) |
| 190 | } |
| 191 | } |
| 192 | }) |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | func TestSymmetricDifference(t *testing.T) { |
| 197 | td := []struct { |
nothing calls this directly
no test coverage detected