Skip to content

Commit 70aa3ce

Browse files
committed
added TestDiffStrings
This is basically a duplicate of TestDiffRunes: because the rune slice was all ascii, rune indices line up with string indices
1 parent 367a9e1 commit 70aa3ce

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

diff_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,27 @@ func TestDiffRunes(t *testing.T) {
139139
}
140140
}
141141

142+
func TestDiffStrings(t *testing.T) {
143+
a := "brown fox jumps over the lazy dog"
144+
b := "brwn faax junps ovver the lay dago"
145+
res := diff.Strings(a, b)
146+
echange := []diff.Change{
147+
{2, 2, 1, 0},
148+
{7, 6, 1, 2},
149+
{12, 12, 1, 1},
150+
{18, 18, 0, 1},
151+
{27, 28, 1, 0},
152+
{31, 31, 0, 2},
153+
{32, 34, 1, 0},
154+
}
155+
for i, c := range res {
156+
t.Log(c)
157+
if c != echange[i] {
158+
t.Error("expected", echange[i], "got", c)
159+
}
160+
}
161+
}
162+
142163
type ints struct{ a, b []int }
143164

144165
func (d *ints) Equal(i, j int) bool { return d.a[i] == d.b[j] }

0 commit comments

Comments
 (0)