31 lines
679 B
Go
31 lines
679 B
Go
package ocr
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestPageMovementRetainsColumnAndBounds(t *testing.T) {
|
|
lines := make([]string, 45)
|
|
for index := range lines {
|
|
lines[index] = "abcd"
|
|
}
|
|
cursor := NewCursor(Result{Text: strings.Join(lines, "\n")})
|
|
cursor.Set(3)
|
|
if got := cursor.Move(PageUnit, 1); got.Line != "abcd" || got.Cursor != 3 || got.Offset != 103 {
|
|
t.Fatal(got)
|
|
}
|
|
if got := cursor.Move(PageUnit, 1); got.Offset != 203 {
|
|
t.Fatal(got)
|
|
}
|
|
if got := cursor.Move(PageUnit, 1); got.Offset != 223 {
|
|
t.Fatal(got)
|
|
}
|
|
if got := cursor.Move(PageUnit, 1); got.Moved {
|
|
t.Fatal(got)
|
|
}
|
|
if got := cursor.Move(PageUnit, -1); got.Offset != 123 {
|
|
t.Fatal(got)
|
|
}
|
|
}
|