| 204 | } |
| 205 | |
| 206 | func TestUnion(t *testing.T) { |
| 207 | for i, tt := range []testUnion[int]{ |
| 208 | testUnion[int]{ |
| 209 | input: testUnionInput[int]{ |
| 210 | []int{1, 2, 3, 3, 4}, |
| 211 | []int{1, 2, 4, 5}, |
| 212 | []int{1, 3, 4, 6}, |
| 213 | }, |
| 214 | output: []int{1, 2, 3, 4, 5, 6}, |
| 215 | }, |
| 216 | } { |
| 217 | t.Run(fmt.Sprintf("%d", i), func(t *testing.T) { |
| 218 | actual := Union(tt.input...) |
| 219 | |
| 220 | if !isEqual(actual, tt.output) { |
| 221 | t.Errorf("expected: %v %T, received: %v %T", tt.output, tt.output, actual, actual) |
| 222 | } |
| 223 | }) |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | type testDifferenceInput[T comparable] [][]T |
| 228 | type testDifferenceOutput[T comparable] []T |