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

Function TestReversePatch

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

Source from the content-addressed store, hash-verified

24}
25
26func TestReversePatch(t *testing.T) {
27 old := "# Document\n\nOriginal content here."
28 new := "# Document\n\nUpdated content here.\n\nNew section added."
29
30 patch := CreateReversePatch(old, new)
31 if patch == "" {
32 t.Fatal("expected non-empty reverse patch")
33 }
34
35 // Applying reverse patch to new content should give old content
36 result, err := ApplyPatch(new, patch)
37 if err != nil {
38 t.Fatalf("ApplyPatch error: %v", err)
39 }
40 if result != old {
41 t.Errorf("expected %q, got %q", old, result)
42 }
43}
44
45func TestEmptyPatch(t *testing.T) {
46 content := "Hello world"

Callers

nothing calls this directly

Calls 2

CreateReversePatchFunction · 0.85
ApplyPatchFunction · 0.85

Tested by

no test coverage detected