Source file
src/go/token/token_test.go
1
2
3
4
5 package token
6
7 import "testing"
8
9 func TestIsIdentifier(t *testing.T) {
10 tests := []struct {
11 name string
12 in string
13 want bool
14 }{
15 {"Empty", "", false},
16 {"Space", " ", false},
17 {"SpaceSuffix", "foo ", false},
18 {"Number", "123", false},
19 {"Keyword", "func", false},
20
21 {"LettersASCII", "foo", true},
22 {"MixedASCII", "_bar123", true},
23 {"UppercaseKeyword", "Func", true},
24 {"LettersUnicode", "fóö", true},
25 }
26 for _, test := range tests {
27 t.Run(test.name, func(t *testing.T) {
28 if got := IsIdentifier(test.in); got != test.want {
29 t.Fatalf("IsIdentifier(%q) = %t, want %v", test.in, got, test.want)
30 }
31 })
32 }
33 }
34
View as plain text