-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcursor_test.go
More file actions
45 lines (43 loc) · 756 Bytes
/
cursor_test.go
File metadata and controls
45 lines (43 loc) · 756 Bytes
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
package main
import (
"testing"
)
func TestBFromO(t *testing.T) {
cases := []struct {
line string
o int
tabWidth int
want int
}{
{
line: " yo, how you doin?",
o: 9,
tabWidth: 4,
want: 3,
},
{
line: " func() xxx {",
o: 10,
tabWidth: 4,
want: 7,
},
{
line: "for o := viewer.min.o ; o < viewer.max.o ; o++ {",
o: 10,
tabWidth: 4,
want: 10,
},
{
line: " SetCell(l, o, ' ', term.ColorDefault, term.ColorDefault)",
o: 11,
tabWidth: 4,
want: 8,
},
}
for _, c := range cases {
got := BFromO(c.line, c.o, c.tabWidth)
if got != c.want {
t.Errorf("BFromO(%v, %v): got %v, want %v", c.line, c.o, got, c.want)
}
}
}