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

Function TestPatchSplitMax

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

Source from the content-addressed store, hash-verified

215}
216
217func TestPatchSplitMax(t *testing.T) {
218 type TestCase struct {
219 Text1 string
220 Text2 string
221
222 Expected string
223 }
224
225 dmp := New()
226
227 for i, tc := range []TestCase{
228 {"abcdefghijklmnopqrstuvwxyz01234567890", "XabXcdXefXghXijXklXmnXopXqrXstXuvXwxXyzX01X23X45X67X89X0", "@@ -1,32 +1,46 @@\n+X\n ab\n+X\n cd\n+X\n ef\n+X\n gh\n+X\n ij\n+X\n kl\n+X\n mn\n+X\n op\n+X\n qr\n+X\n st\n+X\n uv\n+X\n wx\n+X\n yz\n+X\n 012345\n@@ -25,13 +39,18 @@\n zX01\n+X\n 23\n+X\n 45\n+X\n 67\n+X\n 89\n+X\n 0\n"},
229 {"abcdef1234567890123456789012345678901234567890123456789012345678901234567890uvwxyz", "abcdefuvwxyz", "@@ -3,78 +3,8 @@\n cdef\n-1234567890123456789012345678901234567890123456789012345678901234567890\n uvwx\n"},
230 {"1234567890123456789012345678901234567890123456789012345678901234567890", "abc", "@@ -1,32 +1,4 @@\n-1234567890123456789012345678\n 9012\n@@ -29,32 +1,4 @@\n-9012345678901234567890123456\n 7890\n@@ -57,14 +1,3 @@\n-78901234567890\n+abc\n"},
231 {"abcdefghij , h : 0 , t : 1 abcdefghij , h : 0 , t : 1 abcdefghij , h : 0 , t : 1", "abcdefghij , h : 1 , t : 1 abcdefghij , h : 1 , t : 1 abcdefghij , h : 0 , t : 1", "@@ -2,32 +2,32 @@\n bcdefghij , h : \n-0\n+1\n , t : 1 abcdef\n@@ -29,32 +29,32 @@\n bcdefghij , h : \n-0\n+1\n , t : 1 abcdef\n"},
232 } {
233 patches := dmp.PatchMake(tc.Text1, tc.Text2)
234 patches = dmp.PatchSplitMax(patches)
235
236 actual := dmp.PatchToText(patches)
237 assert.Equal(t, tc.Expected, actual, fmt.Sprintf("Test case #%d, %#v", i, tc))
238 }
239}
240
241func TestPatchAddPadding(t *testing.T) {
242 type TestCase struct {

Callers

nothing calls this directly

Calls 4

NewFunction · 0.85
PatchMakeMethod · 0.80
PatchSplitMaxMethod · 0.80
PatchToTextMethod · 0.80

Tested by

no test coverage detected