-
Notifications
You must be signed in to change notification settings - Fork 12
/
cursor_test.go
63 lines (55 loc) · 1.16 KB
/
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
53
54
55
56
57
58
59
60
61
62
63
package input_autocomplete
import "testing"
func TestNewCursor(t *testing.T) {
c := NewCursor()
expected := Cursor{position: 0}
if *c != expected {
t.Errorf("Expected %v", expected)
}
}
func TestIncrementPosition(t *testing.T) {
c := NewCursor()
expected := Cursor{position: 1}
c.IncrementPosition()
if *c != expected {
t.Errorf("Expected %v", expected)
}
}
func TestSetPosition(t *testing.T) {
c := NewCursor()
expected := Cursor{position: 69}
c.SetPosition(69)
if *c != expected {
t.Errorf("Expected %v", expected)
}
}
func TestMoveRight(t *testing.T) {
c := NewCursor()
expected := Cursor{position: 1}
c.MoveRight()
if *c != expected {
t.Errorf("Expected %v", expected)
}
}
func TestMoveLeft(t *testing.T) {
c := &Cursor{position: 421}
expected := Cursor{position: 420}
c.MoveLeft()
if *c != expected {
t.Errorf("Expected %v", expected)
}
}
func TestMoveLeftNPos(t *testing.T) {
c := &Cursor{position: 50}
expected := Cursor{position: 25}
c.MoveLeftNPos(25)
if *c != expected {
t.Errorf("Expected %v", expected)
}
}
func TestGetPosition(t *testing.T) {
c := &Cursor{position: 20}
if c.GetPosition() != 20 {
t.Errorf("Expected 20")
}
}