MCPcopy Index your code
hub / github.com/cheat/cheat / TestSort

Function TestSort

internal/sheets/sort_test.go:10–34  ·  view source on GitHub ↗

TestSort asserts that Sort properly sorts sheets

(t *testing.T)

Source from the content-addressed store, hash-verified

8
9// TestSort asserts that Sort properly sorts sheets
10func TestSort(t *testing.T) {
11
12 // mock a map of cheatsheets
13 sheets := map[string]sheet.Sheet{
14 "foo": sheet.Sheet{Title: "foo"},
15 "bar": sheet.Sheet{Title: "bar"},
16 "baz": sheet.Sheet{Title: "baz"},
17 }
18
19 // sort the sheets
20 sorted := Sort(sheets)
21
22 // assert that the sheets sorted properly
23 want := []string{"bar", "baz", "foo"}
24
25 for i, got := range sorted {
26 if got.Title != want[i] {
27 t.Errorf(
28 "sort returned incorrect value: want: %s, got: %s",
29 want[i],
30 got.Title,
31 )
32 }
33 }
34}

Callers

nothing calls this directly

Calls 1

SortFunction · 0.85

Tested by

no test coverage detected