aboutsummaryrefslogtreecommitdiff
path: root/core/parse/parse_test.go
blob: 48746300fa5ca1bd0020591f50d85675a0233e01 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package parse

import (
	"strings"
	"testing"
)

func TestAllTokens(t *testing.T) {
	input := strings.NewReader("a b c\nd e")
	expected := []string{"a", "b", "c", "d", "e"}
	tokens := allTokens(input)

	if len(tokens) != len(expected) {
		t.Fatalf("Expected %d tokens, got %d", len(expected), len(tokens))
	}

	for i, val := range expected {
		if tokens[i].text != val {
			t.Errorf("Token %d should be '%s' but was '%s'", i, val, tokens[i].text)
		}
	}
}