Skip to content

chore: implement generalized symmetric difference for set comparison #14407

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Aug 23, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: linting
  • Loading branch information
Emyrk committed Aug 22, 2024
commit 00fc33dc3aa0ad36492c9d16f36dd5493e5a099e
10 changes: 10 additions & 0 deletions coderd/util/slice/slice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,16 @@ func TestSymmetricDifference(t *testing.T) {
t.Parallel()

t.Run("Simple", func(t *testing.T) {
t.Parallel()

add, remove := slice.SymmetricDifference([]int{1, 3, 4}, []int{1, 2})
require.ElementsMatch(t, []int{2}, add)
require.ElementsMatch(t, []int{3, 4}, remove)
})

t.Run("Large", func(t *testing.T) {
t.Parallel()

add, remove := slice.SymmetricDifference(
[]int{1, 2, 3, 4, 5, 10, 11, 12, 13, 14, 15},
[]int{1, 3, 7, 9, 11, 13, 17},
Expand All @@ -151,6 +155,8 @@ func TestSymmetricDifference(t *testing.T) {
})

t.Run("AddOnly", func(t *testing.T) {
t.Parallel()

add, remove := slice.SymmetricDifference(
[]int{1, 2},
[]int{1, 2, 3, 4, 5, 6, 7, 8, 9},
Expand All @@ -160,6 +166,8 @@ func TestSymmetricDifference(t *testing.T) {
})

t.Run("RemoveOnly", func(t *testing.T) {
t.Parallel()

add, remove := slice.SymmetricDifference(
[]int{1, 2, 3, 4, 5, 6, 7, 8, 9},
[]int{1, 2},
Expand All @@ -169,6 +177,8 @@ func TestSymmetricDifference(t *testing.T) {
})

t.Run("Equal", func(t *testing.T) {
t.Parallel()

add, remove := slice.SymmetricDifference(
[]int{1, 2, 3, 4, 5, 6, 7, 8, 9},
[]int{1, 2, 3, 4, 5, 6, 7, 8, 9},
Expand Down
Loading