| 176 | } |
| 177 | |
| 178 | func TestIntersect(t *testing.T) { |
| 179 | for i, tt := range []testIntersect[int]{ |
| 180 | testIntersect[int]{ |
| 181 | input: testIntersectInput[int]{ |
| 182 | []int{1, 2, 3, 3, 4}, |
| 183 | []int{1, 2, 4}, |
| 184 | []int{1, 3, 4}, |
| 185 | }, |
| 186 | output: []int{1, 4}, |
| 187 | }, |
| 188 | } { |
| 189 | t.Run(fmt.Sprintf("%d", i), func(t *testing.T) { |
| 190 | actual := Intersect(tt.input...) |
| 191 | |
| 192 | if !isEqual(actual, tt.output) { |
| 193 | t.Errorf("expected: %v %T, received: %v %T", tt.output, tt.output, actual, actual) |
| 194 | } |
| 195 | }) |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | type testUnionInput[T comparable] [][]T |
| 200 | type testUnionOutput[T comparable] []T |