File: testing_util_test.go

package info (click to toggle)
golang-github-antlr-antlr4 4.11.1%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,292 kB
  • sloc: makefile: 5
file content (30 lines) | stat: -rw-r--r-- 654 bytes parent folder | download | duplicates (2)
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
package antlr

import (
	"fmt"
	"strings"
)

// newTestCommonToken create common token with tokentype, text and channel
// notice: test purpose only
func newTestCommonToken(tokenType int, text string, channel int) *CommonToken {
	t := new(CommonToken)
	t.BaseToken = new(BaseToken)
	t.tokenType = tokenType
	t.channel = channel
	t.text = text
	t.line = 0
	t.column = -1
	return t
}

// tokensToString returnes []Tokens string
// notice: test purpose only
func tokensToString(tokens []Token) string {
	buf := make([]string, len(tokens))
	for i, token := range tokens {
		buf[i] = fmt.Sprintf("%v", token)
	}

	return "[" + strings.Join(buf, ", ") + "]"
}