MCPcopy Create free account
hub / github.com/sergi/go-diff / TestRunesIndexOf

Function TestRunesIndexOf

diffmatchpatch/stringutil_test.go:18–42  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

16)
17
18func TestRunesIndexOf(t *testing.T) {
19 type TestCase struct {
20 Pattern string
21 Start int
22
23 Expected int
24 }
25
26 for i, tc := range []TestCase{
27 {"abc", 0, 0},
28 {"cde", 0, 2},
29 {"e", 0, 4},
30 {"cdef", 0, -1},
31 {"abcdef", 0, -1},
32 {"abc", 2, -1},
33 {"cde", 2, 2},
34 {"e", 2, 4},
35 {"cdef", 2, -1},
36 {"abcdef", 2, -1},
37 {"e", 6, -1},
38 } {
39 actual := runesIndexOf([]rune("abcde"), []rune(tc.Pattern), tc.Start)
40 assert.Equal(t, tc.Expected, actual, fmt.Sprintf("Test case #%d, %#v", i, tc))
41 }
42}
43
44func TestIndexOf(t *testing.T) {
45 type TestCase struct {

Callers

nothing calls this directly

Calls 1

runesIndexOfFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…