示例#1
0
func BenchmarkDiffRunes(b *testing.B) {
	d1 := []rune("1231221")
	d2 := []rune("321213")
	for i := 0; i < b.N; i++ {
		diff.Runes(d1, d2)
	}
}
示例#2
0
func TestDiffRunes(t *testing.T) {
	a := []rune("brown fox jumps over the lazy dog")
	b := []rune("brwn faax junps ovver the lay dago")
	res := diff.Runes(a, b)
	echange := []diff.Change{
		{2, 2, 1, 0},
		{7, 6, 1, 2},
		{12, 12, 1, 1},
		{18, 18, 0, 1},
		{27, 28, 1, 0},
		{31, 31, 0, 2},
		{32, 34, 1, 0},
	}
	for i, c := range res {
		t.Log(c)
		if c != echange[i] {
			t.Error("expected", echange[i], "got", c)
		}
	}
}