MCPcopy Index your code
hub / github.com/coder/coder / TestUnique

Function TestUnique

coderd/util/slice/slice_test.go:42–72  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

40}
41
42func TestUnique(t *testing.T) {
43 t.Parallel()
44
45 require.ElementsMatch(t,
46 []int{1, 2, 3, 4, 5},
47 slice.Unique([]int{
48 1, 2, 3, 4, 5, 1, 2, 3, 4, 5,
49 }))
50
51 require.ElementsMatch(t,
52 []string{"a"},
53 slice.Unique([]string{
54 "a", "a", "a",
55 }))
56
57 require.ElementsMatch(t,
58 []int{1, 2, 3, 4, 5},
59 slice.UniqueFunc([]int{
60 1, 2, 3, 4, 5, 1, 2, 3, 4, 5,
61 }, func(a, b int) bool {
62 return a == b
63 }))
64
65 require.ElementsMatch(t,
66 []string{"a"},
67 slice.UniqueFunc([]string{
68 "a", "a", "a",
69 }, func(a, b string) bool {
70 return a == b
71 }))
72}
73
74func TestContains(t *testing.T) {
75 t.Parallel()

Callers

nothing calls this directly

Calls 2

UniqueFunction · 0.92
UniqueFuncFunction · 0.92

Tested by

no test coverage detected