(t *testing.T)
| 10 | ) |
| 11 | |
| 12 | func TestValidIdentifier(t *testing.T) { |
| 13 | tests := []struct { |
| 14 | Input string |
| 15 | Want bool |
| 16 | }{ |
| 17 | {"", false}, |
| 18 | {"hello", true}, |
| 19 | {"hello.world", false}, |
| 20 | {"hello ", false}, |
| 21 | {" hello", false}, |
| 22 | {"hello\n", false}, |
| 23 | {"hello world", false}, |
| 24 | {"aws_instance", true}, |
| 25 | {"aws.instance", false}, |
| 26 | {"foo-bar", true}, |
| 27 | {"foo--bar", true}, |
| 28 | {"foo_", true}, |
| 29 | {"foo-", true}, |
| 30 | {"_foobar", true}, |
| 31 | {"-foobar", false}, |
| 32 | {"blah1", true}, |
| 33 | {"blah1blah", true}, |
| 34 | {"1blah1blah", false}, |
| 35 | {"héllo", true}, // combining acute accent |
| 36 | {"Χαίρετε", true}, |
| 37 | {"звать", true}, |
| 38 | {"今日は", true}, |
| 39 | {"\x80", false}, // UTF-8 continuation without an introducer |
| 40 | {"a\x80", false}, // UTF-8 continuation after a non-introducer |
| 41 | } |
| 42 | |
| 43 | for _, test := range tests { |
| 44 | t.Run(test.Input, func(t *testing.T) { |
| 45 | got := ValidIdentifier(test.Input) |
| 46 | if got != test.Want { |
| 47 | t.Errorf("wrong result %#v; want %#v", got, test.Want) |
| 48 | } |
| 49 | }) |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | var T Tokens |
| 54 |
nothing calls this directly
no test coverage detected