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

Function TestDiffLevenshtein

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

Source from the content-addressed store, hash-verified

1219}
1220
1221func TestDiffLevenshtein(t *testing.T) {
1222 type TestCase struct {
1223 Name string
1224
1225 Diffs []Diff
1226
1227 Expected int
1228 }
1229
1230 dmp := New()
1231
1232 for i, tc := range []TestCase{
1233 {"Levenshtein with trailing equality", []Diff{{DiffDelete, "абв"}, {DiffInsert, "1234"}, {DiffEqual, "эюя"}}, 4},
1234 {"Levenshtein with leading equality", []Diff{{DiffEqual, "эюя"}, {DiffDelete, "абв"}, {DiffInsert, "1234"}}, 4},
1235 {"Levenshtein with middle equality", []Diff{{DiffDelete, "абв"}, {DiffEqual, "эюя"}, {DiffInsert, "1234"}}, 7},
1236 } {
1237 actual := dmp.DiffLevenshtein(tc.Diffs)
1238 assert.Equal(t, tc.Expected, actual, fmt.Sprintf("Test case #%d, %s", i, tc.Name))
1239 }
1240}
1241
1242func TestDiffBisect(t *testing.T) {
1243 type TestCase struct {

Callers

nothing calls this directly

Calls 2

NewFunction · 0.85
DiffLevenshteinMethod · 0.80

Tested by

no test coverage detected