File: tokens_test.go

package info (click to toggle)
mtail 3.2.24-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,384 kB
  • sloc: yacc: 647; makefile: 226; sh: 78; lisp: 77; awk: 17
file content (29 lines) | stat: -rw-r--r-- 786 bytes parent folder | download
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
// Copyright 2018 Google Inc. All Rights Reserved.
// This file is available under the Apache license.

package parser

import (
	"fmt"
	"testing"
	"testing/quick"

	"github.com/jaqx0r/mtail/internal/runtime/compiler/position"
)

func TestKindHasString(t *testing.T) {
	for k := INVALID; k <= NL; k++ {
		if Kind(k).String() != mtailToknames[k-INVALID+3] {
			t.Errorf("kind string not match. expected %s, received %s", mtailToknames[k-INVALID], Kind(k).String())
		}
	}
}

func TestTokenString(t *testing.T) {
	if err := quick.Check(func(kind Kind, spelling string, pos position.Position) bool {
		tok := Token{Kind: kind, Spelling: spelling, Pos: pos}
		return tok.String() == fmt.Sprintf("%s(%q,%s)", kind.String(), spelling, pos.String())
	}, nil); err != nil {
		t.Error(err)
	}
}