-
Notifications
You must be signed in to change notification settings - Fork 0
/
cursor_test.go
52 lines (40 loc) · 932 Bytes
/
cursor_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
46
47
48
49
50
51
52
package tui_test
import (
"github.com/shreve/tui"
"testing"
)
func TestCursor(t *testing.T) {
cursor := tui.NewCursor(1, 1)
if cursor.Up() {
t.Error("Went up from start")
}
if cursor.Left() {
t.Error("Went left from start")
}
if cursor.Down() {
t.Error("Went down a list of one")
}
if cursor.Right() {
t.Error("Went right over a list of one")
}
cursor.SetSize(0, 0)
if cursor.Down() {
t.Error("Went down an empty list")
}
if cursor.Right() {
t.Error("Went right over a list of one")
}
cursor.SetSize(-1, -1)
if row, col := cursor.Size(); row != 0 || col != 0 {
t.Error("Set size to a negative value")
}
cursor.SetSize(5, 5)
cursor.SetPosition(5, 5)
if row, col := cursor.Position(); row != 4 || col != 4 {
t.Error("Set position beyond size of field")
}
cursor.SetSize(1, 1)
if row, col := cursor.Position(); row != 0 || col != 0 {
t.Error("Shrunk field beneath position")
}
}