-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoken_test.go
More file actions
58 lines (53 loc) · 1.2 KB
/
token_test.go
File metadata and controls
58 lines (53 loc) · 1.2 KB
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
58
package wirefilter
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestTokenTypeString(t *testing.T) {
t.Run("known token types", func(t *testing.T) {
tests := []struct {
tokenType TokenType
expected string
}{
{TokenEOF, "EOF"},
{TokenIdent, "IDENT"},
{TokenString, "STRING"},
{TokenInt, "INT"},
{TokenBool, "BOOL"},
{TokenIP, "IP"},
{TokenEq, "=="},
{TokenNe, "!="},
{TokenAllEq, "==="},
{TokenAnyNe, "!=="},
{TokenLt, "<"},
{TokenGt, ">"},
{TokenLe, "<="},
{TokenGe, ">="},
{TokenAnd, "&&"},
{TokenOr, "||"},
{TokenNot, "not"},
{TokenContains, "contains"},
{TokenMatches, "matches"},
{TokenIn, "in"},
{TokenLParen, "("},
{TokenRParen, ")"},
{TokenLBrace, "{"},
{TokenRBrace, "}"},
{TokenLBracket, "["},
{TokenRBracket, "]"},
{TokenComma, ","},
{TokenRange, ".."},
{TokenRawString, "RAWSTRING"},
{TokenAsterisk, "*"},
{TokenListRef, "$"},
{TokenFloat, "FLOAT"},
}
for _, tt := range tests {
assert.Equal(t, tt.expected, tt.tokenType.String())
}
})
t.Run("unknown token type", func(t *testing.T) {
unknownToken := TokenType(255)
assert.Equal(t, "UNKNOWN", unknownToken.String())
})
}