MCPcopy Create free account
hub / github.com/donatj/sqlread / TestStartStateLexer

Function TestStartStateLexer

lexer_test.go:10–45  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestStartStateLexer(t *testing.T) {
11 file, err := os.Open("testfixtures/simple.sql")
12 if err != nil {
13 t.Error(err)
14 return
15 }
16
17 l, li := Lex(file)
18 go func() {
19 l.Run(StartState)
20 }()
21
22 out := []LexItem{}
23 for {
24 x, ok := <-li
25 if !ok {
26 break
27 }
28
29 out = append(out, x)
30 }
31
32 fileExp, err := os.Open("testfixtures/simple.gob")
33 if err != nil {
34 t.Error(err)
35 return
36 }
37
38 g := gob.NewDecoder(fileExp)
39 expOut := []LexItem{}
40 g.Decode(&expOut)
41
42 if !reflect.DeepEqual(out, expOut) {
43 t.Error("did not tokenize correctly")
44 }
45}

Callers

nothing calls this directly

Calls 2

LexFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected