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

Function TestSortedKeys

coderd/util/maps/maps_test.go:12–52  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestSortedKeys(t *testing.T) {
13 t.Parallel()
14
15 for idx, tc := range []struct {
16 name string
17 input map[string]int
18 expected []string
19 }{
20 {
21 name: "SortsAlphabetically",
22 input: map[string]int{
23 "banana": 1,
24 "apple": 2,
25 "cherry": 3,
26 },
27 expected: []string{"apple", "banana", "cherry"},
28 },
29 {
30 name: "AlreadySorted",
31 input: map[string]int{
32 "alpha": 1,
33 "mango": 2,
34 "zebra": 3,
35 },
36 expected: []string{"alpha", "mango", "zebra"},
37 },
38 {
39 name: "EmptyMap",
40 input: map[string]int{},
41 expected: nil,
42 },
43 } {
44 t.Run("#"+strconv.Itoa(idx)+"_"+tc.name, func(t *testing.T) {
45 t.Parallel()
46 got := maps.SortedKeys(tc.input)
47 if diff := cmp.Diff(tc.expected, got); diff != "" {
48 t.Fatalf("unexpected result (-want +got):\n%s", diff)
49 }
50 })
51 }
52}
53
54func TestSubset(t *testing.T) {
55 t.Parallel()

Callers

nothing calls this directly

Calls 3

SortedKeysFunction · 0.92
RunMethod · 0.65
FatalfMethod · 0.45

Tested by

no test coverage detected