File: lexer_test.go

package info (click to toggle)
golang-github-graph-gophers-graphql-go 0.0~git20180609.bb97385-2
  • links: PTS, VCS
  • area: main
  • in suites: buster, buster-backports
  • size: 632 kB
  • sloc: makefile: 4
file content (43 lines) | stat: -rw-r--r-- 878 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
31
32
33
34
35
36
37
38
39
40
41
42
43
package common_test

import (
	"testing"

	"github.com/graph-gophers/graphql-go/internal/common"
)

type consumeTestCase struct {
	description string
	definition  string
	expected    string // expected description
}

var consumeTests = []consumeTestCase{{
	description: "initial test",
	definition: `

# Comment line 1
# Comment line 2
,,,,,, # Commas are insignificant
type Hello {
	world: String!
}`,
	expected: "Comment line 1\nComment line 2\nCommas are insignificant",
}}

func TestConsume(t *testing.T) {
	for _, test := range consumeTests {
		t.Run(test.description, func(t *testing.T) {
			lex := common.NewLexer(test.definition)

			err := lex.CatchSyntaxError(lex.Consume)
			if err != nil {
				t.Fatal(err)
			}

			if test.expected != lex.DescComment() {
				t.Errorf("wrong description value:\nwant: %q\ngot : %q", test.expected, lex.DescComment())
			}
		})
	}
}