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

Function TestDiffText

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

Source from the content-addressed store, hash-verified

1075}
1076
1077func TestDiffText(t *testing.T) {
1078 type TestCase struct {
1079 Diffs []Diff
1080
1081 ExpectedText1 string
1082 ExpectedText2 string
1083 }
1084
1085 dmp := New()
1086
1087 for i, tc := range []TestCase{
1088 {
1089 Diffs: []Diff{
1090 {DiffEqual, "jump"},
1091 {DiffDelete, "s"},
1092 {DiffInsert, "ed"},
1093 {DiffEqual, " over "},
1094 {DiffDelete, "the"},
1095 {DiffInsert, "a"},
1096 {DiffEqual, " lazy"},
1097 },
1098
1099 ExpectedText1: "jumps over the lazy",
1100 ExpectedText2: "jumped over a lazy",
1101 },
1102 } {
1103 actualText1 := dmp.DiffText1(tc.Diffs)
1104 assert.Equal(t, tc.ExpectedText1, actualText1, fmt.Sprintf("Test case #%d, %#v", i, tc))
1105
1106 actualText2 := dmp.DiffText2(tc.Diffs)
1107 assert.Equal(t, tc.ExpectedText2, actualText2, fmt.Sprintf("Test case #%d, %#v", i, tc))
1108 }
1109}
1110
1111func TestDiffDelta(t *testing.T) {
1112 type TestCase struct {

Callers

nothing calls this directly

Calls 3

NewFunction · 0.85
DiffText1Method · 0.80
DiffText2Method · 0.80

Tested by

no test coverage detected