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

Function TestPatchAddPadding

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

Source from the content-addressed store, hash-verified

233}
234
235func TestPatchAddPadding(t *testing.T) {
236 type TestCase struct {
237 Name string
238
239 Text1 string
240 Text2 string
241
242 Expected string
243 ExpectedWithPadding string
244 }
245
246 dmp := New()
247
248 for i, tc := range []TestCase{
249 {"Both edges full", "", "test", "@@ -0,0 +1,4 @@\n+test\n", "@@ -1,8 +1,12 @@\n %01%02%03%04\n+test\n %01%02%03%04\n"},
250 {"Both edges partial", "XY", "XtestY", "@@ -1,2 +1,6 @@\n X\n+test\n Y\n", "@@ -2,8 +2,12 @@\n %02%03%04X\n+test\n Y%01%02%03\n"},
251 {"Both edges none", "XXXXYYYY", "XXXXtestYYYY", "@@ -1,8 +1,12 @@\n XXXX\n+test\n YYYY\n", "@@ -5,8 +5,12 @@\n XXXX\n+test\n YYYY\n"},
252 } {
253 patches := dmp.PatchMake(tc.Text1, tc.Text2)
254
255 actual := dmp.PatchToText(patches)
256 assert.Equal(t, tc.Expected, actual, fmt.Sprintf("Test case #%d, %s", i, tc.Name))
257
258 dmp.PatchAddPadding(patches)
259
260 actualWithPadding := dmp.PatchToText(patches)
261 assert.Equal(t, tc.ExpectedWithPadding, actualWithPadding, fmt.Sprintf("Test case #%d, %s", i, tc.Name))
262 }
263}
264
265func TestPatchApply(t *testing.T) {
266 type TestCase struct {

Callers

nothing calls this directly

Calls 4

NewFunction · 0.85
PatchMakeMethod · 0.80
PatchToTextMethod · 0.80
PatchAddPaddingMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…