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

Function TestMatchMain

diffmatchpatch/match_test.go:141–174  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

139}
140
141func TestMatchMain(t *testing.T) {
142 type TestCase struct {
143 Name string
144
145 Text1 string
146 Text2 string
147 Location int
148
149 Expected int
150 }
151
152 dmp := New()
153
154 for i, tc := range []TestCase{
155 {"Equality", "abcdef", "abcdef", 1000, 0},
156 {"Null text", "", "abcdef", 1, -1},
157 {"Null pattern", "abcdef", "", 3, 3},
158 {"Exact match", "abcdef", "de", 3, 3},
159 {"Beyond end match", "abcdef", "defy", 4, 3},
160 {"Oversized pattern", "abcdef", "abcdefy", 0, 0},
161 } {
162 actual := dmp.MatchMain(tc.Text1, tc.Text2, tc.Location)
163 assert.Equal(t, tc.Expected, actual, fmt.Sprintf("Test case #%d, %s", i, tc.Name))
164 }
165
166 dmp.MatchThreshold = 0.7
167
168 for i, tc := range []TestCase{
169 {"Complex match", "I am the very model of a modern major general.", " that berry ", 5, 4},
170 } {
171 actual := dmp.MatchMain(tc.Text1, tc.Text2, tc.Location)
172 assert.Equal(t, tc.Expected, actual, fmt.Sprintf("Test case #%d, %#v", i, tc))
173 }
174}

Callers

nothing calls this directly

Calls 2

NewFunction · 0.85
MatchMainMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…