go-toml/parse/document_test.go

32 lines
869 B
Go

package parse
import (
"testing"
)
func TestComment(t *testing.T) {
for _, test := range []parseTest{
{``, `{}`, ``},
{`#`, `{}`, ``},
{`# `, `{}`, ``},
{`# aaaaaa`, `{}`, ``},
{"# ending in EOL & EOF\r\n", `{}`, ``},
{`# \xxx/ \u can't escape/`, `{}`, ``},
{"# \tlexe\r accepts embedded ca\r\riage \returns\r\n", `{}`, ``},
{" # multiple\n#lines\n \t\n\n\t#with\n ### comments!", `{}`, ``},
{"# with data and newline\ncode continues here", `{}`, `unexpected input (expected a value assignment) at line 2, column 6`},
} {
p := newParser()
testParse(t, p, p.startDocument, test)
}
}
func TestInvalidDocument(t *testing.T) {
for _, test := range []parseTest{
{`!false!`, `{}`, `unexpected input (expected key/value pair, table or array of tables) at start of file`},
} {
p := newParser()
testParse(t, p, p.startDocument, test)
}
}