diff options
Diffstat (limited to 'pkg/query/lexer_test.go')
| -rw-r--r-- | pkg/query/lexer_test.go | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/pkg/query/lexer_test.go b/pkg/query/lexer_test.go index 0cfc1de..d931b96 100644 --- a/pkg/query/lexer_test.go +++ b/pkg/query/lexer_test.go @@ -1,14 +1,45 @@ -package query +package query_test import ( "testing" + + "github.com/jpappel/atlas/pkg/query" +) + +type Token = query.Token + +const ( + TOK_UNKNOWN = query.TOK_UNKNOWN + TOK_CLAUSE_OR = query.TOK_CLAUSE_OR + TOK_CLAUSE_AND = query.TOK_CLAUSE_AND + TOK_CLAUSE_START = query.TOK_CLAUSE_START + TOK_CLAUSE_END = query.TOK_CLAUSE_END + TOK_OP_NEG = query.TOK_OP_NEG + TOK_OP_EQ = query.TOK_OP_EQ + TOK_OP_AP = query.TOK_OP_AP + TOK_OP_NE = query.TOK_OP_NE + TOK_OP_LT = query.TOK_OP_LT + TOK_OP_LE = query.TOK_OP_LE + TOK_OP_GE = query.TOK_OP_GE + TOK_OP_GT = query.TOK_OP_GT + TOK_OP_PIPE = query.TOK_OP_PIPE + TOK_OP_ARG = query.TOK_OP_ARG + TOK_CAT_TITLE = query.TOK_CAT_TITLE + TOK_CAT_AUTHOR = query.TOK_CAT_AUTHOR + TOK_CAT_DATE = query.TOK_CAT_DATE + TOK_CAT_FILETIME = query.TOK_CAT_FILETIME + TOK_CAT_TAGS = query.TOK_CAT_TAGS + TOK_CAT_LINKS = query.TOK_CAT_LINKS + TOK_CAT_META = query.TOK_CAT_META + TOK_VAL_STR = query.TOK_VAL_STR + TOK_VAL_DATETIME = query.TOK_VAL_DATETIME ) func TestLex(t *testing.T) { tests := []struct { name string query string - want []Token + want []query.Token }{ {"empty query", "", []Token{{Type: TOK_CLAUSE_START}, {TOK_CLAUSE_AND, "and"}, {Type: TOK_CLAUSE_END}}}, {"quoted statement", `a:"ken thompson"`, []Token{ @@ -66,7 +97,7 @@ func TestLex(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - got := Lex(tt.query) + got := query.Lex(tt.query) gl, wl := len(got), len(tt.want) if gl != wl { @@ -83,8 +114,8 @@ func TestLex(t *testing.T) { } if t.Failed() { - t.Log("Got\n", TokensStringify(got)) - t.Log("Want\n", TokensStringify(tt.want)) + t.Log("Got\n", query.TokensStringify(got)) + t.Log("Want\n", query.TokensStringify(tt.want)) } }) } |
