|
1 | 1 | package slice_test
|
2 | 2 |
|
3 | 3 | import (
|
4 |
| - "github.com/coder/coder/coderd/util/slice" |
| 4 | + "testing" |
| 5 | + |
5 | 6 | "github.com/google/uuid"
|
6 | 7 | "github.com/stretchr/testify/require"
|
7 |
| - "testing" |
| 8 | + |
| 9 | + "github.com/coder/coder/coderd/util/slice" |
8 | 10 | )
|
9 | 11 |
|
10 | 12 | func TestContains(t *testing.T) {
|
11 |
| - testContains(t, []int{1, 2, 3, 4, 5}, []int{1, 2, 3, 4, 5}, []int{0, 6, -1, -2, 100}) |
12 |
| - testContains(t, []string{"hello", "world", "foo", "bar", "baz"}, []string{"hello", "world", "baz"}, []string{"not", "words", "in", "set"}) |
13 |
| - testContains(t, |
| 13 | + t.Parallel() |
| 14 | + |
| 15 | + assertSetContains(t, []int{1, 2, 3, 4, 5}, []int{1, 2, 3, 4, 5}, []int{0, 6, -1, -2, 100}) |
| 16 | + assertSetContains(t, []string{"hello", "world", "foo", "bar", "baz"}, []string{"hello", "world", "baz"}, []string{"not", "words", "in", "set"}) |
| 17 | + assertSetContains(t, |
14 | 18 | []uuid.UUID{uuid.New(), uuid.MustParse("c7c6686d-a93c-4df2-bef9-5f837e9a33d5"), uuid.MustParse("8f3b3e0b-2c3f-46a5-a365-fd5b62bd8818")},
|
15 | 19 | []uuid.UUID{uuid.MustParse("c7c6686d-a93c-4df2-bef9-5f837e9a33d5")},
|
16 | 20 | []uuid.UUID{uuid.MustParse("1d00e27d-8de6-46f8-80d5-1da0ca83874a")},
|
17 | 21 | )
|
18 | 22 | }
|
19 | 23 |
|
20 |
| -func testContains[T comparable](t *testing.T, set []T, in []T, out []T) { |
| 24 | +func assertSetContains[T comparable](t *testing.T, set []T, in []T, out []T) { |
| 25 | + t.Helper() |
21 | 26 | for _, e := range set {
|
22 | 27 | require.True(t, slice.Contains(set, e), "elements in set should be in the set")
|
23 | 28 | }
|
|
0 commit comments