-
Notifications
You must be signed in to change notification settings - Fork 1
/
main_test.go
52 lines (50 loc) · 898 Bytes
/
main_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 main
import (
"testing"
)
func TestMovedown(t *testing.T) {
body := []byte(` printf("hello world\n");
printf("hello world\n");
}
`)
testCases := []struct {
currentQ0 int
startQ0 int
endQ0 int
tabwidth int
}{
// printf("hello world\n");
// ^
{
currentQ0: 88,
startQ0: 88,
endQ0: 114,
tabwidth: 8,
},
// printf("hello world\n");
// ^
{
currentQ0: 89,
startQ0: 88,
endQ0: 122,
tabwidth: 8,
},
// printf("hello world\n");
// ^
{
currentQ0: 113,
startQ0: 88,
endQ0: 138,
tabwidth: 8,
},
}
for _, tc := range testCases {
endQ0c := body[tc.endQ0-tc.startQ0]
nQ0 := down(body, tc.tabwidth, tc.startQ0, tc.currentQ0)
nQ0c := body[nQ0-tc.currentQ0]
if nQ0 != tc.endQ0 {
t.Fatalf("expected nq0=%d(%c), got nq0=%d(%c)",
tc.endQ0, endQ0c, nQ0, nQ0c)
}
}
}