-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathdiff_test.go
45 lines (31 loc) · 894 Bytes
/
diff_test.go
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package extedit
import (
"bufio"
"testing"
)
func TestNoDiff(t *testing.T) {
c1, err := contentFromString("Line1\nLine2", bufio.ScanLines)
ok(t, err)
c2, err := contentFromString("Line1\nLine2", bufio.ScanLines)
ok(t, err)
d := NewDiff(c1, c2)
equals(t, len(d.Differences), 0)
}
func TestSimpleDiff(t *testing.T) {
c1, err := contentFromString("Line1\nLine2", bufio.ScanLines)
ok(t, err)
c2, err := contentFromString("Line1\nXLine2", bufio.ScanLines)
ok(t, err)
d := NewDiff(c1, c2)
equals(t, len(d.Differences), 1)
equals(t, d.Line(d.Differences[0]), "XLine2")
}
func TestDiffExtraLines(t *testing.T) {
c1, err := contentFromString("Line1\nLine2", bufio.ScanLines)
ok(t, err)
c2, err := contentFromString("Line1\nLine2\nLine3", bufio.ScanLines)
ok(t, err)
d := NewDiff(c1, c2)
equals(t, len(d.Differences), 1)
equals(t, d.Line(d.Differences[0]), "Line3")
}