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

Function TestIsDiffSmaller

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

Source from the content-addressed store, hash-verified

62}
63
64func TestIsDiffSmaller(t *testing.T) {
65 // Small change to large doc — diff should be smaller
66 large := strings.Repeat("Line of text\n", 100)
67 modified := large + "Added line\n"
68 patch := CreatePatch(large, modified)
69 if !IsDiffSmaller(patch, large) {
70 t.Errorf("expected diff (%d bytes) to be smaller than full content (%d bytes)", len(patch), len(large))
71 }
72
73 // Near-complete rewrite — diff should NOT be smaller
74 completely := strings.Repeat("Totally different\n", 100)
75 patch2 := CreatePatch(large, completely)
76 if IsDiffSmaller(patch2, large) {
77 t.Errorf("expected diff (%d bytes) to NOT be smaller for complete rewrite (%d bytes)", len(patch2), len(large))
78 }
79}
80
81func TestIsDiffSmallerEmptyContent(t *testing.T) {
82 if IsDiffSmaller("some patch", "") {

Callers

nothing calls this directly

Calls 2

CreatePatchFunction · 0.85
IsDiffSmallerFunction · 0.85

Tested by

no test coverage detected