mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-23 22:27:38 -05:00
Added tests for allTokens
This commit is contained in:
parent
d311345aa5
commit
5397eef234
2 changed files with 24 additions and 0 deletions
|
@ -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{})
|
||||||
|
|
22
config/parse/parse_test.go
Normal file
22
config/parse/parse_test.go
Normal file
|
@ -0,0 +1,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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue