MCPcopy Create free account
hub / github.com/PerpetualSoftware/pad / TestCreateAndApplyPatch

Function TestCreateAndApplyPatch

internal/diff/diff_test.go:8–24  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

6)
7
8func TestCreateAndApplyPatch(t *testing.T) {
9 old := "Hello world\nThis is a test\nThird line"
10 new := "Hello world\nThis is modified\nThird line\nFourth line"
11
12 patch := CreatePatch(old, new)
13 if patch == "" {
14 t.Fatal("expected non-empty patch")
15 }
16
17 result, err := ApplyPatch(old, patch)
18 if err != nil {
19 t.Fatalf("ApplyPatch error: %v", err)
20 }
21 if result != new {
22 t.Errorf("expected %q, got %q", new, result)
23 }
24}
25
26func TestReversePatch(t *testing.T) {
27 old := "# Document\n\nOriginal content here."

Callers

nothing calls this directly

Calls 2

CreatePatchFunction · 0.85
ApplyPatchFunction · 0.85

Tested by

no test coverage detected