-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils_test.go
57 lines (50 loc) · 1.29 KB
/
utils_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
package main
import (
"testing"
)
var testMoveCursorCases = []struct {
row int
column int
want string
}{
{1, 1, "\033[1;1H"},
{11, 100, "\033[11;100H"},
}
var testHeaderCases = []struct {
column int
step int
want string
}{
{11, 1, "\033[1;11H 1 "},
{41, 64, "\033[1;41H 8 "},
{21, 38, "\033[1;21H 6 "},
}
var testFooterCases = []struct {
maxColumns int
column int
lastRow int
want string
}{
{42, 35, 6, "\033[6;1H * "},
}
func TestFooter(t *testing.T) {
for _, test := range testFooterCases {
if got := footer(test.maxColumns, test.column, test.lastRow); got != test.want {
t.Fatalf("footer(maxColumns=%d, column=%d, lastRow=%d) Want: %q Got: %q\n", test.maxColumns, test.column, test.lastRow, test.want, got)
}
}
}
func TestHeader(t *testing.T) {
for _, test := range testHeaderCases {
if got := header(test.column, test.step); got != test.want {
t.Fatalf("header(column=%d, step=%d) Want: %q Got: %q\n", test.column, test.step, test.want, got)
}
}
}
func TestMoveCursorCases(t *testing.T) {
for _, test := range testMoveCursorCases {
if got := moveCursor(test.row, test.column); got != test.want {
t.Fatalf("moveCursor(row=%d, column=%d) Want: %q Got: %q\n", test.row, test.column, test.want, got)
}
}
}