(t *testing.T)
| 208 | } |
| 209 | |
| 210 | func TestSymmetricDifference(t *testing.T) { |
| 211 | t.Parallel() |
| 212 | |
| 213 | t.Run("Simple", func(t *testing.T) { |
| 214 | t.Parallel() |
| 215 | |
| 216 | add, remove := slice.SymmetricDifference([]int{1, 3, 4}, []int{1, 2}) |
| 217 | require.ElementsMatch(t, []int{2}, add) |
| 218 | require.ElementsMatch(t, []int{3, 4}, remove) |
| 219 | }) |
| 220 | |
| 221 | t.Run("Large", func(t *testing.T) { |
| 222 | t.Parallel() |
| 223 | |
| 224 | add, remove := slice.SymmetricDifference( |
| 225 | []int{1, 2, 3, 4, 5, 10, 11, 12, 13, 14, 15}, |
| 226 | []int{1, 3, 7, 9, 11, 13, 17}, |
| 227 | ) |
| 228 | require.ElementsMatch(t, []int{7, 9, 17}, add) |
| 229 | require.ElementsMatch(t, []int{2, 4, 5, 10, 12, 14, 15}, remove) |
| 230 | }) |
| 231 | |
| 232 | t.Run("AddOnly", func(t *testing.T) { |
| 233 | t.Parallel() |
| 234 | |
| 235 | add, remove := slice.SymmetricDifference( |
| 236 | []int{1, 2}, |
| 237 | []int{1, 2, 3, 4, 5, 6, 7, 8, 9}, |
| 238 | ) |
| 239 | require.ElementsMatch(t, []int{3, 4, 5, 6, 7, 8, 9}, add) |
| 240 | require.ElementsMatch(t, []int{}, remove) |
| 241 | }) |
| 242 | |
| 243 | t.Run("RemoveOnly", func(t *testing.T) { |
| 244 | t.Parallel() |
| 245 | |
| 246 | add, remove := slice.SymmetricDifference( |
| 247 | []int{1, 2, 3, 4, 5, 6, 7, 8, 9}, |
| 248 | []int{1, 2}, |
| 249 | ) |
| 250 | require.ElementsMatch(t, []int{}, add) |
| 251 | require.ElementsMatch(t, []int{3, 4, 5, 6, 7, 8, 9}, remove) |
| 252 | }) |
| 253 | |
| 254 | t.Run("Equal", func(t *testing.T) { |
| 255 | t.Parallel() |
| 256 | |
| 257 | add, remove := slice.SymmetricDifference( |
| 258 | []int{1, 2, 3, 4, 5, 6, 7, 8, 9}, |
| 259 | []int{1, 2, 3, 4, 5, 6, 7, 8, 9}, |
| 260 | ) |
| 261 | require.ElementsMatch(t, []int{}, add) |
| 262 | require.ElementsMatch(t, []int{}, remove) |
| 263 | }) |
| 264 | |
| 265 | t.Run("ToEmpty", func(t *testing.T) { |
| 266 | t.Parallel() |
| 267 |
nothing calls this directly
no test coverage detected