-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiff_test.go
More file actions
31 lines (28 loc) · 793 Bytes
/
diff_test.go
File metadata and controls
31 lines (28 loc) · 793 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package batcha
import (
"strings"
"testing"
)
func TestUnifiedDiff_NoDiff(t *testing.T) {
a := "line1\nline2\nline3"
b := "line1\nline2\nline3"
diff := unifiedDiff(a, b, "a", "b")
if diff != "" {
t.Errorf("expected empty diff, got:\n%s", diff)
}
}
func TestUnifiedDiff_WithChanges(t *testing.T) {
a := "line1\nline2\nline3"
b := "line1\nmodified\nline3"
diff := unifiedDiff(a, b, "a", "b")
if diff == "" {
t.Error("expected non-empty diff")
}
// Should contain unified diff markers
if !strings.Contains(diff, "---") || !strings.Contains(diff, "+++") || !strings.Contains(diff, "@@") {
t.Errorf("diff missing markers:\n%s", diff)
}
if !strings.Contains(diff, "-line2") || !strings.Contains(diff, "+modified") {
t.Errorf("diff missing expected lines:\n%s", diff)
}
}