mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
xml: add check of version in document declaration
Check that if a version is declared, for example in '<?xml version="XX" ?>', version must be '1.0'. Change-Id: I16ba9f78873a5f31977dcf75ac8e671fe6c08280 Reviewed-on: https://go-review.googlesource.com/8961 Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
parent
a13606e619
commit
9490fbf755
2 changed files with 24 additions and 15 deletions
|
|
@ -657,20 +657,23 @@ type procInstEncodingTest struct {
|
|||
}
|
||||
|
||||
var procInstTests = []struct {
|
||||
input, expect string
|
||||
input string
|
||||
expect [2]string
|
||||
}{
|
||||
{`version="1.0" encoding="utf-8"`, "utf-8"},
|
||||
{`version="1.0" encoding='utf-8'`, "utf-8"},
|
||||
{`version="1.0" encoding='utf-8' `, "utf-8"},
|
||||
{`version="1.0" encoding=utf-8`, ""},
|
||||
{`encoding="FOO" `, "FOO"},
|
||||
{`version="1.0" encoding="utf-8"`, [2]string{"1.0", "utf-8"}},
|
||||
{`version="1.0" encoding='utf-8'`, [2]string{"1.0", "utf-8"}},
|
||||
{`version="1.0" encoding='utf-8' `, [2]string{"1.0", "utf-8"}},
|
||||
{`version="1.0" encoding=utf-8`, [2]string{"1.0", ""}},
|
||||
{`encoding="FOO" `, [2]string{"", "FOO"}},
|
||||
}
|
||||
|
||||
func TestProcInstEncoding(t *testing.T) {
|
||||
for _, test := range procInstTests {
|
||||
got := procInstEncoding(test.input)
|
||||
if got != test.expect {
|
||||
t.Errorf("procInstEncoding(%q) = %q; want %q", test.input, got, test.expect)
|
||||
if got := procInst("version", test.input); got != test.expect[0] {
|
||||
t.Errorf("procInst(version, %q) = %q; want %q", test.input, got, test.expect[0])
|
||||
}
|
||||
if got := procInst("encoding", test.input); got != test.expect[1] {
|
||||
t.Errorf("procInst(encoding, %q) = %q; want %q", test.input, got, test.expect[1])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue