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

Function TestDiffLevenshtein

diffmatchpatch/diff_test.go:1197–1216  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1195}
1196
1197func TestDiffLevenshtein(t *testing.T) {
1198 type TestCase struct {
1199 Name string
1200
1201 Diffs []Diff
1202
1203 Expected int
1204 }
1205
1206 dmp := New()
1207
1208 for i, tc := range []TestCase{
1209 {"Levenshtein with trailing equality", []Diff{{DiffDelete, "абв"}, {DiffInsert, "1234"}, {DiffEqual, "эюя"}}, 4},
1210 {"Levenshtein with leading equality", []Diff{{DiffEqual, "эюя"}, {DiffDelete, "абв"}, {DiffInsert, "1234"}}, 4},
1211 {"Levenshtein with middle equality", []Diff{{DiffDelete, "абв"}, {DiffEqual, "эюя"}, {DiffInsert, "1234"}}, 7},
1212 } {
1213 actual := dmp.DiffLevenshtein(tc.Diffs)
1214 assert.Equal(t, tc.Expected, actual, fmt.Sprintf("Test case #%d, %s", i, tc.Name))
1215 }
1216}
1217
1218func TestDiffBisect(t *testing.T) {
1219 type TestCase struct {

Callers

nothing calls this directly

Calls 2

NewFunction · 0.85
DiffLevenshteinMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…