Commit 5397eef2 authored by Matthew Holt's avatar Matthew Holt

Added tests for allTokens

parent d311345a
...@@ -24,4 +24,6 @@ func allTokens(input io.Reader) (tokens []token) { ...@@ -24,4 +24,6 @@ func allTokens(input io.Reader) (tokens []token) {
return return
} }
// Set of directives that are valid (unordered). Populated
// by config package's init function.
var ValidDirectives = make(map[string]struct{}) var ValidDirectives = make(map[string]struct{})
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)
}
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment