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

Function TestPatchAddPadding

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

Source from the content-addressed store, hash-verified

239}
240
241func TestPatchAddPadding(t *testing.T) {
242 type TestCase struct {
243 Name string
244
245 Text1 string
246 Text2 string
247
248 Expected string
249 ExpectedWithPadding string
250 }
251
252 dmp := New()
253
254 for i, tc := range []TestCase{
255 {"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"},
256 {"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"},
257 {"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"},
258 } {
259 patches := dmp.PatchMake(tc.Text1, tc.Text2)
260
261 actual := dmp.PatchToText(patches)
262 assert.Equal(t, tc.Expected, actual, fmt.Sprintf("Test case #%d, %s", i, tc.Name))
263
264 dmp.PatchAddPadding(patches)
265
266 actualWithPadding := dmp.PatchToText(patches)
267 assert.Equal(t, tc.ExpectedWithPadding, actualWithPadding, fmt.Sprintf("Test case #%d, %s", i, tc.Name))
268 }
269}
270
271func TestPatchApply(t *testing.T) {
272 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