-
Notifications
You must be signed in to change notification settings - Fork 0
/
flattables_test.go
52 lines (47 loc) · 1.05 KB
/
flattables_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 flattables
import (
"go/token"
"testing"
)
func TestIsGoKeyword(t *testing.T) {
var tests = []struct {
maybeKeyword string
isKeyword bool
}{
{"break", true},
{"case", true},
{"chan", true},
{"const", true},
{"continue", true},
{"default", true},
{"defer", true},
{"else", true},
{"fallthrough", true},
{"for", true},
{"func", true},
{"go", true},
{"goto", true},
{"if", true},
{"import", true},
{"interface", true},
{"map", true},
{"package", true},
{"range", true},
{"return", true},
{"select", true},
{"struct", true},
{"switch", true},
{"type", true},
{"var", true},
{"int", false},
}
for i, test := range tests {
var result bool = token.Lookup(test.maybeKeyword).IsKeyword()
if result != test.isKeyword && test.isKeyword == true {
t.Errorf("test[%d] expected %s to be a Go keyword, but it's not", i, test.maybeKeyword)
}
if result != test.isKeyword && test.isKeyword == false {
t.Errorf("test[%d] expected %s to NOT be a Go keyword, but it is", i, test.maybeKeyword)
}
}
}