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

Function TestDiffText

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

Source from the content-addressed store, hash-verified

1051}
1052
1053func TestDiffText(t *testing.T) {
1054 type TestCase struct {
1055 Diffs []Diff
1056
1057 ExpectedText1 string
1058 ExpectedText2 string
1059 }
1060
1061 dmp := New()
1062
1063 for i, tc := range []TestCase{
1064 {
1065 Diffs: []Diff{
1066 {DiffEqual, "jump"},
1067 {DiffDelete, "s"},
1068 {DiffInsert, "ed"},
1069 {DiffEqual, " over "},
1070 {DiffDelete, "the"},
1071 {DiffInsert, "a"},
1072 {DiffEqual, " lazy"},
1073 },
1074
1075 ExpectedText1: "jumps over the lazy",
1076 ExpectedText2: "jumped over a lazy",
1077 },
1078 } {
1079 actualText1 := dmp.DiffText1(tc.Diffs)
1080 assert.Equal(t, tc.ExpectedText1, actualText1, fmt.Sprintf("Test case #%d, %#v", i, tc))
1081
1082 actualText2 := dmp.DiffText2(tc.Diffs)
1083 assert.Equal(t, tc.ExpectedText2, actualText2, fmt.Sprintf("Test case #%d, %#v", i, tc))
1084 }
1085}
1086
1087func TestDiffDelta(t *testing.T) {
1088 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

Used in the wild real call sites across dependent graphs

searching dependent graphs…