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

Function TestDiffXIndex

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

Source from the content-addressed store, hash-verified

1198}
1199
1200func TestDiffXIndex(t *testing.T) {
1201 type TestCase struct {
1202 Name string
1203
1204 Diffs []Diff
1205 Location int
1206
1207 Expected int
1208 }
1209
1210 dmp := New()
1211
1212 for i, tc := range []TestCase{
1213 {"Translation on equality", []Diff{{DiffDelete, "a"}, {DiffInsert, "1234"}, {DiffEqual, "xyz"}}, 2, 5},
1214 {"Translation on deletion", []Diff{{DiffEqual, "a"}, {DiffDelete, "1234"}, {DiffEqual, "xyz"}}, 3, 1},
1215 } {
1216 actual := dmp.DiffXIndex(tc.Diffs, tc.Location)
1217 assert.Equal(t, tc.Expected, actual, fmt.Sprintf("Test case #%d, %s", i, tc.Name))
1218 }
1219}
1220
1221func TestDiffLevenshtein(t *testing.T) {
1222 type TestCase struct {

Callers

nothing calls this directly

Calls 2

NewFunction · 0.85
DiffXIndexMethod · 0.80

Tested by

no test coverage detected