diff options
| author | Giulio Iotti <dullgiulio@gmail.com> | 2015-04-15 16:59:49 +0300 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2015-06-18 18:06:01 +0000 |
| commit | 9490fbf7557f3d1d12051f79d033e2a4fd8fcbcb (patch) | |
| tree | fb1aadea9c652530fdd553940ac3f3dff3772d6b /src/encoding/xml/xml_test.go | |
| parent | a13606e6196e0c4ef3f54542f9ae6fade0a9c19b (diff) | |
| download | go-9490fbf7557f3d1d12051f79d033e2a4fd8fcbcb.tar.xz | |
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>
Diffstat (limited to 'src/encoding/xml/xml_test.go')
| -rw-r--r-- | src/encoding/xml/xml_test.go | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/encoding/xml/xml_test.go b/src/encoding/xml/xml_test.go index be995c0d52..312a7c98a5 100644 --- a/src/encoding/xml/xml_test.go +++ b/src/encoding/xml/xml_test.go @@ -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]) } } } |
