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

Function TestPatchString

diffmatchpatch/patch_test.go:19–51  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

17)
18
19func TestPatchString(t *testing.T) {
20 type TestCase struct {
21 Patch Patch
22
23 Expected string
24 }
25
26 for i, tc := range []TestCase{
27 {
28 Patch: Patch{
29 Start1: 20,
30 Start2: 21,
31 Length1: 18,
32 Length2: 17,
33
34 diffs: []Diff{
35 {DiffEqual, "jump"},
36 {DiffDelete, "s"},
37 {DiffInsert, "ed"},
38 {DiffEqual, " over "},
39 {DiffDelete, "the"},
40 {DiffInsert, "a"},
41 {DiffEqual, "\nlaz"},
42 },
43 },
44
45 Expected: "@@ -21,18 +22,17 @@\n jump\n-s\n+ed\n over \n-the\n+a\n %0Alaz\n",
46 },
47 } {
48 actual := tc.Patch.String()
49 assert.Equal(t, tc.Expected, actual, fmt.Sprintf("Test case #%d, %#v", i, tc))
50 }
51}
52
53func TestPatchFromText(t *testing.T) {
54 type TestCase struct {

Callers

nothing calls this directly

Calls 1

StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…