mirror of
https://github.com/AxioDL/tinyxml2.git
synced 2025-05-14 19:31:23 +00:00
Add a test case for issue #332
XML Declarations can occur only at the beginning of an XML Document. Parse() should throw an error, for not well-formed XML Documents.
This commit is contained in:
parent
e5e5541af6
commit
2bb6bb5bee
19
xmltest.cpp
19
xmltest.cpp
@ -1460,6 +1460,25 @@ int main( int argc, const char ** argv )
|
|||||||
XMLTest( "Error should be cleared", false, doc.Error() );
|
XMLTest( "Error should be cleared", false, doc.Error() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// Check that declarations are parsed only as the FirstChild
|
||||||
|
const char* xml0 = "<?xml version=\"1.0\" ?>"
|
||||||
|
" <!-- xml version=\"1.1\" -->"
|
||||||
|
"<first />";
|
||||||
|
const char* xml1 = "<?xml version=\"1.0\" ?>"
|
||||||
|
" <?xml version=\"1.1\" ?>"
|
||||||
|
"<first />";
|
||||||
|
const char* xml2 = "<first />"
|
||||||
|
"<?xml version=\"1.0\" ?>";
|
||||||
|
XMLDocument doc;
|
||||||
|
doc.Parse(xml0);
|
||||||
|
XMLTest("Test that the code changes do not affect normal parsing", doc.Error(), false);
|
||||||
|
doc.Parse(xml1);
|
||||||
|
XMLTest("Test that the second declaration throws an error", doc.Error(), true);
|
||||||
|
doc.Parse(xml2);
|
||||||
|
XMLTest("Test that declaration after a child throws an error", doc.Error(), true);
|
||||||
|
}
|
||||||
|
|
||||||
// ----------- Performance tracking --------------
|
// ----------- Performance tracking --------------
|
||||||
{
|
{
|
||||||
#if defined( _MSC_VER )
|
#if defined( _MSC_VER )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user