MCPcopy Create free account
hub / github.com/cheat/cheat / TestSearchMultiMatch

Function TestSearchMultiMatch

internal/sheet/search_test.go:66–93  ·  view source on GitHub ↗

TestSearchMultiMatch asserts that the expected output is returned when a multiple matches are returned

(t *testing.T)

Source from the content-addressed store, hash-verified

64// TestSearchMultiMatch asserts that the expected output is returned
65// when a multiple matches are returned
66func TestSearchMultiMatch(t *testing.T) {
67
68 // mock a cheatsheet
69 sheet := Sheet{
70 Text: "The quick brown fox\n\njumped over\n\nthe lazy dog.",
71 }
72
73 // compile the search regex
74 reg, err := regexp.Compile("(?i)the")
75 if err != nil {
76 t.Errorf("failed to compile regex: %v", err)
77 }
78
79 // search the sheet
80 matches := sheet.Search(reg)
81
82 // specify the expected results
83 want := "The quick brown fox\n\nthe lazy dog."
84
85 // assert that the correct matches were returned
86 if !reflect.DeepEqual(matches, want) {
87 t.Errorf(
88 "failed to return expected matches: want:\n%s, got:\n%s",
89 want,
90 matches,
91 )
92 }
93}

Callers

nothing calls this directly

Calls 1

SearchMethod · 0.95

Tested by

no test coverage detected