mirror of https://github.com/AxioDL/tinyxml2.git
Merge pull request #577 from Dmitry-Me/checkParseResult
Check result of Parse() call
This commit is contained in:
commit
cd33699926
56
xmltest.cpp
56
xmltest.cpp
|
@ -375,6 +375,7 @@ int main( int argc, const char ** argv )
|
||||||
for( int i=0; test[i]; ++i ) {
|
for( int i=0; test[i]; ++i ) {
|
||||||
XMLDocument doc;
|
XMLDocument doc;
|
||||||
doc.Parse( test[i] );
|
doc.Parse( test[i] );
|
||||||
|
XMLTest( "Element test", false, doc.Error() );
|
||||||
doc.Print();
|
doc.Print();
|
||||||
printf( "----------------------------------------------\n" );
|
printf( "----------------------------------------------\n" );
|
||||||
}
|
}
|
||||||
|
@ -389,6 +390,7 @@ int main( int argc, const char ** argv )
|
||||||
|
|
||||||
XMLDocument doc;
|
XMLDocument doc;
|
||||||
doc.Parse( test );
|
doc.Parse( test );
|
||||||
|
XMLTest( "Hello world declaration", false, doc.Error() );
|
||||||
doc.Print();
|
doc.Print();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -396,6 +398,7 @@ int main( int argc, const char ** argv )
|
||||||
static const char* test = "<element>Text before.</element>";
|
static const char* test = "<element>Text before.</element>";
|
||||||
XMLDocument doc;
|
XMLDocument doc;
|
||||||
doc.Parse( test );
|
doc.Parse( test );
|
||||||
|
XMLTest( "Element text before", false, doc.Error() );
|
||||||
XMLElement* root = doc.FirstChildElement();
|
XMLElement* root = doc.FirstChildElement();
|
||||||
XMLElement* newElement = doc.NewElement( "Subelement" );
|
XMLElement* newElement = doc.NewElement( "Subelement" );
|
||||||
root->InsertEndChild( newElement );
|
root->InsertEndChild( newElement );
|
||||||
|
@ -405,6 +408,7 @@ int main( int argc, const char ** argv )
|
||||||
XMLDocument* doc = new XMLDocument();
|
XMLDocument* doc = new XMLDocument();
|
||||||
static const char* test = "<element><sub/></element>";
|
static const char* test = "<element><sub/></element>";
|
||||||
doc->Parse( test );
|
doc->Parse( test );
|
||||||
|
XMLTest( "Element with sub element", false, doc->Error() );
|
||||||
delete doc;
|
delete doc;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
@ -520,6 +524,7 @@ int main( int argc, const char ** argv )
|
||||||
|
|
||||||
XMLDocument doc;
|
XMLDocument doc;
|
||||||
doc.Parse( str );
|
doc.Parse( str );
|
||||||
|
XMLTest( "Top level attributes", false, doc.Error() );
|
||||||
|
|
||||||
XMLElement* ele = doc.FirstChildElement();
|
XMLElement* ele = doc.FirstChildElement();
|
||||||
|
|
||||||
|
@ -555,6 +560,7 @@ int main( int argc, const char ** argv )
|
||||||
|
|
||||||
XMLDocument doc;
|
XMLDocument doc;
|
||||||
doc.Parse( str );
|
doc.Parse( str );
|
||||||
|
XMLTest( "Empty top element", false, doc.Error() );
|
||||||
|
|
||||||
XMLElement* ele = doc.FirstChildElement();
|
XMLElement* ele = doc.FirstChildElement();
|
||||||
|
|
||||||
|
@ -645,12 +651,14 @@ int main( int argc, const char ** argv )
|
||||||
const char* str = "<foo>This is text</foo>";
|
const char* str = "<foo>This is text</foo>";
|
||||||
XMLDocument doc;
|
XMLDocument doc;
|
||||||
doc.Parse( str );
|
doc.Parse( str );
|
||||||
|
XMLTest( "Double whitespace", false, doc.Error() );
|
||||||
const XMLElement* element = doc.RootElement();
|
const XMLElement* element = doc.RootElement();
|
||||||
|
|
||||||
XMLTest( "GetText() normal use.", "This is text", element->GetText() );
|
XMLTest( "GetText() normal use.", "This is text", element->GetText() );
|
||||||
|
|
||||||
str = "<foo><b>This is text</b></foo>";
|
str = "<foo><b>This is text</b></foo>";
|
||||||
doc.Parse( str );
|
doc.Parse( str );
|
||||||
|
XMLTest( "Bold text simulation", false, doc.Error() );
|
||||||
element = doc.RootElement();
|
element = doc.RootElement();
|
||||||
|
|
||||||
XMLTest( "GetText() contained element.", element->GetText() == 0, true );
|
XMLTest( "GetText() contained element.", element->GetText() == 0, true );
|
||||||
|
@ -662,6 +670,7 @@ int main( int argc, const char ** argv )
|
||||||
const char* str = "<foo></foo>";
|
const char* str = "<foo></foo>";
|
||||||
XMLDocument doc;
|
XMLDocument doc;
|
||||||
doc.Parse( str );
|
doc.Parse( str );
|
||||||
|
XMLTest( "Empty closed element", false, doc.Error() );
|
||||||
XMLElement* element = doc.RootElement();
|
XMLElement* element = doc.RootElement();
|
||||||
|
|
||||||
element->SetText("darkness.");
|
element->SetText("darkness.");
|
||||||
|
@ -672,6 +681,7 @@ int main( int argc, const char ** argv )
|
||||||
|
|
||||||
str = "<foo/>";
|
str = "<foo/>";
|
||||||
doc.Parse( str );
|
doc.Parse( str );
|
||||||
|
XMLTest( "Empty self-closed element", false, doc.Error() );
|
||||||
element = doc.RootElement();
|
element = doc.RootElement();
|
||||||
|
|
||||||
element->SetText("The driver");
|
element->SetText("The driver");
|
||||||
|
@ -683,6 +693,7 @@ int main( int argc, const char ** argv )
|
||||||
|
|
||||||
str = "<foo><bar>Text in nested element</bar></foo>";
|
str = "<foo><bar>Text in nested element</bar></foo>";
|
||||||
doc.Parse( str );
|
doc.Parse( str );
|
||||||
|
XMLTest( "Text in nested element", false, doc.Error() );
|
||||||
element = doc.RootElement();
|
element = doc.RootElement();
|
||||||
|
|
||||||
element->SetText("wolves");
|
element->SetText("wolves");
|
||||||
|
@ -690,6 +701,7 @@ int main( int argc, const char ** argv )
|
||||||
|
|
||||||
str = "<foo/>";
|
str = "<foo/>";
|
||||||
doc.Parse( str );
|
doc.Parse( str );
|
||||||
|
XMLTest( "Empty self-closed element round 2", false, doc.Error() );
|
||||||
element = doc.RootElement();
|
element = doc.RootElement();
|
||||||
|
|
||||||
element->SetText( "str" );
|
element->SetText( "str" );
|
||||||
|
@ -841,6 +853,7 @@ int main( int argc, const char ** argv )
|
||||||
"</xmlElement>";
|
"</xmlElement>";
|
||||||
XMLDocument doc;
|
XMLDocument doc;
|
||||||
doc.Parse( str );
|
doc.Parse( str );
|
||||||
|
XMLTest( "CDATA symbolic puns round 1", false, doc.Error() );
|
||||||
doc.Print();
|
doc.Print();
|
||||||
|
|
||||||
XMLTest( "CDATA parse.", "I am > the rules!\n...since I make symbolic puns",
|
XMLTest( "CDATA parse.", "I am > the rules!\n...since I make symbolic puns",
|
||||||
|
@ -858,6 +871,7 @@ int main( int argc, const char ** argv )
|
||||||
"</xmlElement>";
|
"</xmlElement>";
|
||||||
XMLDocument doc;
|
XMLDocument doc;
|
||||||
doc.Parse( str );
|
doc.Parse( str );
|
||||||
|
XMLTest( "CDATA symbolic puns round 2", false, doc.Error() );
|
||||||
doc.Print();
|
doc.Print();
|
||||||
|
|
||||||
XMLTest( "CDATA parse. [ tixml1:1480107 ]",
|
XMLTest( "CDATA parse. [ tixml1:1480107 ]",
|
||||||
|
@ -895,6 +909,7 @@ int main( int argc, const char ** argv )
|
||||||
|
|
||||||
XMLDocument doc;
|
XMLDocument doc;
|
||||||
doc.Parse( passages );
|
doc.Parse( passages );
|
||||||
|
XMLTest( "Entity transformation parse round 1", false, doc.Error() );
|
||||||
XMLElement* psg = doc.RootElement()->FirstChildElement();
|
XMLElement* psg = doc.RootElement()->FirstChildElement();
|
||||||
const char* context = psg->Attribute( "context" );
|
const char* context = psg->Attribute( "context" );
|
||||||
const char* expected = "Line 5 has \"quotation marks\" and 'apostrophe marks'. It also has <, >, and &, as well as a fake copyright \xC2\xA9.";
|
const char* expected = "Line 5 has \"quotation marks\" and 'apostrophe marks'. It also has <, >, and &, as well as a fake copyright \xC2\xA9.";
|
||||||
|
@ -933,6 +948,7 @@ int main( int argc, const char ** argv )
|
||||||
|
|
||||||
XMLDocument doc( false );
|
XMLDocument doc( false );
|
||||||
doc.Parse( passages );
|
doc.Parse( passages );
|
||||||
|
XMLTest( "Entity transformation parse round 2", false, doc.Error() );
|
||||||
|
|
||||||
XMLTest( "No entity parsing.",
|
XMLTest( "No entity parsing.",
|
||||||
"Line 5 has "quotation marks" and 'apostrophe marks'.",
|
"Line 5 has "quotation marks" and 'apostrophe marks'.",
|
||||||
|
@ -957,6 +973,7 @@ int main( int argc, const char ** argv )
|
||||||
|
|
||||||
XMLDocument doc;
|
XMLDocument doc;
|
||||||
doc.Parse( test );
|
doc.Parse( test );
|
||||||
|
XMLTest( "fin thickness", false, doc.Error() );
|
||||||
|
|
||||||
XMLText* text = doc.FirstChildElement()->FirstChildElement()->FirstChild()->ToText();
|
XMLText* text = doc.FirstChildElement()->FirstChildElement()->FirstChild()->ToText();
|
||||||
XMLTest( "Entity with one digit.",
|
XMLTest( "Entity with one digit.",
|
||||||
|
@ -976,9 +993,12 @@ int main( int argc, const char ** argv )
|
||||||
|
|
||||||
XMLDocument doc;
|
XMLDocument doc;
|
||||||
doc.Parse( doctype );
|
doc.Parse( doctype );
|
||||||
|
XMLTest( "PLAY SYSTEM parse", false, doc.Error() );
|
||||||
doc.SaveFile( "resources/out/test7.xml" );
|
doc.SaveFile( "resources/out/test7.xml" );
|
||||||
|
XMLTest( "PLAY SYSTEM save", false, doc.Error() );
|
||||||
doc.DeleteChild( doc.RootElement() );
|
doc.DeleteChild( doc.RootElement() );
|
||||||
doc.LoadFile( "resources/out/test7.xml" );
|
doc.LoadFile( "resources/out/test7.xml" );
|
||||||
|
XMLTest( "PLAY SYSTEM load", false, doc.Error() );
|
||||||
doc.Print();
|
doc.Print();
|
||||||
|
|
||||||
const XMLUnknown* decl = doc.FirstChild()->NextSibling()->ToUnknown();
|
const XMLUnknown* decl = doc.FirstChild()->NextSibling()->ToUnknown();
|
||||||
|
@ -992,6 +1012,7 @@ int main( int argc, const char ** argv )
|
||||||
"<!-- Somewhat<evil> -->";
|
"<!-- Somewhat<evil> -->";
|
||||||
XMLDocument doc;
|
XMLDocument doc;
|
||||||
doc.Parse( doctype );
|
doc.Parse( doctype );
|
||||||
|
XMLTest( "Comment somewhat evil", false, doc.Error() );
|
||||||
|
|
||||||
XMLComment* comment = doc.FirstChild()->ToComment();
|
XMLComment* comment = doc.FirstChild()->ToComment();
|
||||||
|
|
||||||
|
@ -1037,6 +1058,7 @@ int main( int argc, const char ** argv )
|
||||||
// Low entities
|
// Low entities
|
||||||
XMLDocument doc;
|
XMLDocument doc;
|
||||||
doc.Parse( "<test></test>" );
|
doc.Parse( "<test></test>" );
|
||||||
|
XMLTest( "Hex values", false, doc.Error() );
|
||||||
const char result[] = { 0x0e, 0 };
|
const char result[] = { 0x0e, 0 };
|
||||||
XMLTest( "Low entities.", result, doc.FirstChildElement()->GetText() );
|
XMLTest( "Low entities.", result, doc.FirstChildElement()->GetText() );
|
||||||
doc.Print();
|
doc.Print();
|
||||||
|
@ -1066,6 +1088,7 @@ int main( int argc, const char ** argv )
|
||||||
XMLDocument xml;
|
XMLDocument xml;
|
||||||
xml.Parse("<!-- declarations for <head> & <body> -->"
|
xml.Parse("<!-- declarations for <head> & <body> -->"
|
||||||
"<!-- far & away -->" );
|
"<!-- far & away -->" );
|
||||||
|
XMLTest( "Declarations for head and body", false, xml.Error() );
|
||||||
|
|
||||||
XMLNode* e0 = xml.FirstChild();
|
XMLNode* e0 = xml.FirstChild();
|
||||||
XMLNode* e1 = e0->NextSibling();
|
XMLNode* e1 = e0->NextSibling();
|
||||||
|
@ -1083,6 +1106,7 @@ int main( int argc, const char ** argv )
|
||||||
"<!-- With this comment, child2 will not be parsed! -->"
|
"<!-- With this comment, child2 will not be parsed! -->"
|
||||||
"<child2 att=''/>"
|
"<child2 att=''/>"
|
||||||
"</Parent>" );
|
"</Parent>" );
|
||||||
|
XMLTest( "Comments iteration", false, xml.Error() );
|
||||||
xml.Print();
|
xml.Print();
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
@ -1105,6 +1129,7 @@ int main( int argc, const char ** argv )
|
||||||
|
|
||||||
XMLDocument doc;
|
XMLDocument doc;
|
||||||
doc.Parse( (const char*)buf);
|
doc.Parse( (const char*)buf);
|
||||||
|
XMLTest( "Broken CDATA", true, doc.Error() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1120,6 +1145,7 @@ int main( int argc, const char ** argv )
|
||||||
// This one must not result in an infinite loop
|
// This one must not result in an infinite loop
|
||||||
XMLDocument xml;
|
XMLDocument xml;
|
||||||
xml.Parse( "<infinite>loop" );
|
xml.Parse( "<infinite>loop" );
|
||||||
|
XMLTest( "No closing element", true, xml.Error() );
|
||||||
XMLTest( "Infinite loop test.", true, true );
|
XMLTest( "Infinite loop test.", true, true );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1127,6 +1153,7 @@ int main( int argc, const char ** argv )
|
||||||
const char* pub = "<?xml version='1.0'?> <element><sub/></element> <!--comment--> <!DOCTYPE>";
|
const char* pub = "<?xml version='1.0'?> <element><sub/></element> <!--comment--> <!DOCTYPE>";
|
||||||
XMLDocument doc;
|
XMLDocument doc;
|
||||||
doc.Parse( pub );
|
doc.Parse( pub );
|
||||||
|
XMLTest( "Trailing DOCTYPE", false, doc.Error() );
|
||||||
|
|
||||||
XMLDocument clone;
|
XMLDocument clone;
|
||||||
for( const XMLNode* node=doc.FirstChild(); node; node=node->NextSibling() ) {
|
for( const XMLNode* node=doc.FirstChild(); node; node=node->NextSibling() ) {
|
||||||
|
@ -1160,6 +1187,7 @@ int main( int argc, const char ** argv )
|
||||||
"</root>";
|
"</root>";
|
||||||
XMLDocument doc;
|
XMLDocument doc;
|
||||||
doc.Parse(xml);
|
doc.Parse(xml);
|
||||||
|
XMLTest( "Parse before deep cloning root element", false, doc.Error() );
|
||||||
|
|
||||||
doc.Print(&printer1);
|
doc.Print(&printer1);
|
||||||
XMLNode* root = doc.RootElement()->DeepClone(&doc2);
|
XMLNode* root = doc.RootElement()->DeepClone(&doc2);
|
||||||
|
@ -1186,6 +1214,7 @@ int main( int argc, const char ** argv )
|
||||||
"</root>";
|
"</root>";
|
||||||
XMLDocument doc;
|
XMLDocument doc;
|
||||||
doc.Parse(xml);
|
doc.Parse(xml);
|
||||||
|
XMLTest( "Parse before deep cloning sub element", false, doc.Error() );
|
||||||
|
|
||||||
const XMLElement* subElement = doc.FirstChildElement("root")->FirstChildElement("child2");
|
const XMLElement* subElement = doc.FirstChildElement("root")->FirstChildElement("child2");
|
||||||
subElement->Accept(&printer1);
|
subElement->Accept(&printer1);
|
||||||
|
@ -1215,6 +1244,7 @@ int main( int argc, const char ** argv )
|
||||||
"</root>";
|
"</root>";
|
||||||
XMLDocument doc;
|
XMLDocument doc;
|
||||||
doc.Parse(xml);
|
doc.Parse(xml);
|
||||||
|
XMLTest( "Parse before deep cloning document", false, doc.Error() );
|
||||||
doc.Print(&printer1);
|
doc.Print(&printer1);
|
||||||
|
|
||||||
doc.DeepCopy(&doc2);
|
doc.DeepCopy(&doc2);
|
||||||
|
@ -1241,6 +1271,7 @@ int main( int argc, const char ** argv )
|
||||||
static const char* xml = "<element attrib1=\"1\" attrib2=\"2\" attrib3=\"3\" />";
|
static const char* xml = "<element attrib1=\"1\" attrib2=\"2\" attrib3=\"3\" />";
|
||||||
XMLDocument doc;
|
XMLDocument doc;
|
||||||
doc.Parse( xml );
|
doc.Parse( xml );
|
||||||
|
XMLTest( "Parse for attribute ordering", false, doc.Error() );
|
||||||
XMLElement* ele = doc.FirstChildElement();
|
XMLElement* ele = doc.FirstChildElement();
|
||||||
|
|
||||||
const XMLAttribute* a = ele->FirstAttribute();
|
const XMLAttribute* a = ele->FirstAttribute();
|
||||||
|
@ -1269,10 +1300,13 @@ int main( int argc, const char ** argv )
|
||||||
static const char* xml2 = "<element attribute1 = \"Test Attribute\"/>";
|
static const char* xml2 = "<element attribute1 = \"Test Attribute\"/>";
|
||||||
XMLDocument doc0;
|
XMLDocument doc0;
|
||||||
doc0.Parse( xml0 );
|
doc0.Parse( xml0 );
|
||||||
|
XMLTest( "Parse attribute with space 1", false, doc0.Error() );
|
||||||
XMLDocument doc1;
|
XMLDocument doc1;
|
||||||
doc1.Parse( xml1 );
|
doc1.Parse( xml1 );
|
||||||
|
XMLTest( "Parse attribute with space 2", false, doc1.Error() );
|
||||||
XMLDocument doc2;
|
XMLDocument doc2;
|
||||||
doc2.Parse( xml2 );
|
doc2.Parse( xml2 );
|
||||||
|
XMLTest( "Parse attribute with space 3", false, doc2.Error() );
|
||||||
|
|
||||||
XMLElement* ele = 0;
|
XMLElement* ele = 0;
|
||||||
ele = doc0.FirstChildElement();
|
ele = doc0.FirstChildElement();
|
||||||
|
@ -1288,6 +1322,7 @@ int main( int argc, const char ** argv )
|
||||||
static const char* xml = "<doc><element attribute='attribute'/><element attribute='attribute'/></doc>";
|
static const char* xml = "<doc><element attribute='attribute'/><element attribute='attribute'/></doc>";
|
||||||
XMLDocument doc;
|
XMLDocument doc;
|
||||||
doc.Parse( xml );
|
doc.Parse( xml );
|
||||||
|
XMLTest( "Parse two elements with attribute", false, doc.Error() );
|
||||||
XMLElement* ele0 = doc.FirstChildElement()->FirstChildElement();
|
XMLElement* ele0 = doc.FirstChildElement()->FirstChildElement();
|
||||||
XMLElement* ele1 = ele0->NextSiblingElement();
|
XMLElement* ele1 = ele0->NextSiblingElement();
|
||||||
bool equal = ele0->ShallowEqual( ele1 );
|
bool equal = ele0->ShallowEqual( ele1 );
|
||||||
|
@ -1300,6 +1335,7 @@ int main( int argc, const char ** argv )
|
||||||
static const char* xml = "<element attrib='bar'><sub>Text</sub></element>";
|
static const char* xml = "<element attrib='bar'><sub>Text</sub></element>";
|
||||||
XMLDocument doc;
|
XMLDocument doc;
|
||||||
doc.Parse( xml );
|
doc.Parse( xml );
|
||||||
|
XMLTest( "Parse element with attribute and nested element round 1", false, doc.Error() );
|
||||||
|
|
||||||
XMLElement* ele = XMLHandle( doc ).FirstChildElement( "element" ).FirstChild().ToElement();
|
XMLElement* ele = XMLHandle( doc ).FirstChildElement( "element" ).FirstChild().ToElement();
|
||||||
XMLTest( "Handle, success, mutable", "sub", ele->Value() );
|
XMLTest( "Handle, success, mutable", "sub", ele->Value() );
|
||||||
|
@ -1313,6 +1349,7 @@ int main( int argc, const char ** argv )
|
||||||
static const char* xml = "<element attrib='bar'><sub>Text</sub></element>";
|
static const char* xml = "<element attrib='bar'><sub>Text</sub></element>";
|
||||||
XMLDocument doc;
|
XMLDocument doc;
|
||||||
doc.Parse( xml );
|
doc.Parse( xml );
|
||||||
|
XMLTest( "Parse element with attribute and nested element round 2", false, doc.Error() );
|
||||||
XMLConstHandle docH( doc );
|
XMLConstHandle docH( doc );
|
||||||
|
|
||||||
const XMLElement* ele = docH.FirstChildElement( "element" ).FirstChild().ToElement();
|
const XMLElement* ele = docH.FirstChildElement( "element" ).FirstChild().ToElement();
|
||||||
|
@ -1346,6 +1383,7 @@ int main( int argc, const char ** argv )
|
||||||
const char* xml = "<point> <x>1.2</x> <y>1</y> <z>38</z> <valid>true</valid> </point>";
|
const char* xml = "<point> <x>1.2</x> <y>1</y> <z>38</z> <valid>true</valid> </point>";
|
||||||
XMLDocument doc;
|
XMLDocument doc;
|
||||||
doc.Parse( xml );
|
doc.Parse( xml );
|
||||||
|
XMLTest( "Parse points", false, doc.Error() );
|
||||||
|
|
||||||
const XMLElement* pointElement = doc.RootElement();
|
const XMLElement* pointElement = doc.RootElement();
|
||||||
|
|
||||||
|
@ -1417,6 +1455,7 @@ int main( int argc, const char ** argv )
|
||||||
"</element>";
|
"</element>";
|
||||||
XMLDocument doc( true, COLLAPSE_WHITESPACE );
|
XMLDocument doc( true, COLLAPSE_WHITESPACE );
|
||||||
doc.Parse( xml );
|
doc.Parse( xml );
|
||||||
|
XMLTest( "Parse with whitespace collapsing and &apos", false, doc.Error() );
|
||||||
|
|
||||||
const XMLElement* element = doc.FirstChildElement();
|
const XMLElement* element = doc.FirstChildElement();
|
||||||
for( const XMLElement* parent = element->FirstChildElement();
|
for( const XMLElement* parent = element->FirstChildElement();
|
||||||
|
@ -1444,6 +1483,7 @@ int main( int argc, const char ** argv )
|
||||||
const char* xml = "<element> </element>";
|
const char* xml = "<element> </element>";
|
||||||
XMLDocument doc( true, COLLAPSE_WHITESPACE );
|
XMLDocument doc( true, COLLAPSE_WHITESPACE );
|
||||||
doc.Parse( xml );
|
doc.Parse( xml );
|
||||||
|
XMLTest( "Parse with all whitespaces", false, doc.Error() );
|
||||||
XMLTest( "Whitespace all space", true, 0 == doc.FirstChildElement()->FirstChild() );
|
XMLTest( "Whitespace all space", true, 0 == doc.FirstChildElement()->FirstChild() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1452,6 +1492,7 @@ int main( int argc, const char ** argv )
|
||||||
const char* xml = "<element/>";
|
const char* xml = "<element/>";
|
||||||
XMLDocument doc;
|
XMLDocument doc;
|
||||||
doc.Parse( xml );
|
doc.Parse( xml );
|
||||||
|
XMLTest( "Parse with self-closed element", false, doc.Error() );
|
||||||
XMLElement* ele = doc.NewElement( "unused" ); // This will get cleaned up with the 'doc' going out of scope.
|
XMLElement* ele = doc.NewElement( "unused" ); // This will get cleaned up with the 'doc' going out of scope.
|
||||||
XMLTest( "Tracking unused elements", true, ele != 0, false );
|
XMLTest( "Tracking unused elements", true, ele != 0, false );
|
||||||
}
|
}
|
||||||
|
@ -1461,6 +1502,7 @@ int main( int argc, const char ** argv )
|
||||||
const char* xml = "<parent><child>abc</child></parent>";
|
const char* xml = "<parent><child>abc</child></parent>";
|
||||||
XMLDocument doc;
|
XMLDocument doc;
|
||||||
doc.Parse( xml );
|
doc.Parse( xml );
|
||||||
|
XMLTest( "Parse for printing of sub-element", false, doc.Error() );
|
||||||
XMLElement* ele = doc.FirstChildElement( "parent")->FirstChildElement( "child");
|
XMLElement* ele = doc.FirstChildElement( "parent")->FirstChildElement( "child");
|
||||||
|
|
||||||
XMLPrinter printer;
|
XMLPrinter printer;
|
||||||
|
@ -1539,6 +1581,7 @@ int main( int argc, const char ** argv )
|
||||||
|
|
||||||
XMLDocument doc;
|
XMLDocument doc;
|
||||||
doc.Parse(xml);
|
doc.Parse(xml);
|
||||||
|
XMLTest( "Insertion with removal parse round 1", false, doc.Error() );
|
||||||
XMLElement* subtree = doc.RootElement()->FirstChildElement("one")->FirstChildElement("subtree");
|
XMLElement* subtree = doc.RootElement()->FirstChildElement("one")->FirstChildElement("subtree");
|
||||||
XMLElement* two = doc.RootElement()->FirstChildElement("two");
|
XMLElement* two = doc.RootElement()->FirstChildElement("two");
|
||||||
two->InsertFirstChild(subtree);
|
two->InsertFirstChild(subtree);
|
||||||
|
@ -1547,6 +1590,7 @@ int main( int argc, const char ** argv )
|
||||||
XMLTest("Move node from within <one> to <two>", xmlInsideTwo, printer1.CStr());
|
XMLTest("Move node from within <one> to <two>", xmlInsideTwo, printer1.CStr());
|
||||||
|
|
||||||
doc.Parse(xml);
|
doc.Parse(xml);
|
||||||
|
XMLTest( "Insertion with removal parse round 2", false, doc.Error() );
|
||||||
subtree = doc.RootElement()->FirstChildElement("one")->FirstChildElement("subtree");
|
subtree = doc.RootElement()->FirstChildElement("one")->FirstChildElement("subtree");
|
||||||
two = doc.RootElement()->FirstChildElement("two");
|
two = doc.RootElement()->FirstChildElement("two");
|
||||||
doc.RootElement()->InsertAfterChild(two, subtree);
|
doc.RootElement()->InsertAfterChild(two, subtree);
|
||||||
|
@ -1555,6 +1599,7 @@ int main( int argc, const char ** argv )
|
||||||
XMLTest("Move node from within <one> after <two>", xmlAfterTwo, printer2.CStr(), false);
|
XMLTest("Move node from within <one> after <two>", xmlAfterTwo, printer2.CStr(), false);
|
||||||
|
|
||||||
doc.Parse(xml);
|
doc.Parse(xml);
|
||||||
|
XMLTest( "Insertion with removal parse round 3", false, doc.Error() );
|
||||||
XMLNode* one = doc.RootElement()->FirstChildElement("one");
|
XMLNode* one = doc.RootElement()->FirstChildElement("one");
|
||||||
subtree = one->FirstChildElement("subtree");
|
subtree = one->FirstChildElement("subtree");
|
||||||
doc.RootElement()->InsertAfterChild(one, subtree);
|
doc.RootElement()->InsertAfterChild(one, subtree);
|
||||||
|
@ -1563,6 +1608,7 @@ int main( int argc, const char ** argv )
|
||||||
XMLTest("Move node from within <one> after <one>", xmlAfterOne, printer3.CStr(), false);
|
XMLTest("Move node from within <one> after <one>", xmlAfterOne, printer3.CStr(), false);
|
||||||
|
|
||||||
doc.Parse(xml);
|
doc.Parse(xml);
|
||||||
|
XMLTest( "Insertion with removal parse round 4", false, doc.Error() );
|
||||||
subtree = doc.RootElement()->FirstChildElement("one")->FirstChildElement("subtree");
|
subtree = doc.RootElement()->FirstChildElement("one")->FirstChildElement("subtree");
|
||||||
two = doc.RootElement()->FirstChildElement("two");
|
two = doc.RootElement()->FirstChildElement("two");
|
||||||
doc.RootElement()->InsertEndChild(subtree);
|
doc.RootElement()->InsertEndChild(subtree);
|
||||||
|
@ -1577,6 +1623,7 @@ int main( int argc, const char ** argv )
|
||||||
"</svg>";
|
"</svg>";
|
||||||
XMLDocument doc;
|
XMLDocument doc;
|
||||||
doc.Parse(xml);
|
doc.Parse(xml);
|
||||||
|
XMLTest( "Parse svg with text", false, doc.Error() );
|
||||||
doc.Print();
|
doc.Print();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1585,6 +1632,7 @@ int main( int argc, const char ** argv )
|
||||||
const char* xml = "<?xml version=\"1.0\"?><root><sample><field0><1</field0><field1>2</field1></sample></root>";
|
const char* xml = "<?xml version=\"1.0\"?><root><sample><field0><1</field0><field1>2</field1></sample></root>";
|
||||||
XMLDocument doc;
|
XMLDocument doc;
|
||||||
doc.Parse(xml);
|
doc.Parse(xml);
|
||||||
|
XMLTest( "Parse root-sample-field0", true, doc.Error() );
|
||||||
doc.PrintError();
|
doc.PrintError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1596,6 +1644,7 @@ int main( int argc, const char ** argv )
|
||||||
const char* xml = "<element/>";
|
const char* xml = "<element/>";
|
||||||
XMLDocument doc;
|
XMLDocument doc;
|
||||||
doc.Parse( xml );
|
doc.Parse( xml );
|
||||||
|
XMLTest( "Parse self-closed empty element", false, doc.Error() );
|
||||||
doc.FirstChildElement()->SetAttribute( "attrA-f64", 123456789.123456789 );
|
doc.FirstChildElement()->SetAttribute( "attrA-f64", 123456789.123456789 );
|
||||||
doc.FirstChildElement()->SetAttribute( "attrB-f64", 1.001e9 );
|
doc.FirstChildElement()->SetAttribute( "attrB-f64", 1.001e9 );
|
||||||
doc.FirstChildElement()->SetAttribute( "attrC-f64", 1.0e9 );
|
doc.FirstChildElement()->SetAttribute( "attrC-f64", 1.0e9 );
|
||||||
|
@ -1632,10 +1681,12 @@ int main( int argc, const char ** argv )
|
||||||
{
|
{
|
||||||
XMLDocument doc;
|
XMLDocument doc;
|
||||||
doc.Parse(xmlText);
|
doc.Parse(xmlText);
|
||||||
|
XMLTest( "Parse hex no closing tag round 1", true, doc.Error() );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
XMLDocument doc;
|
XMLDocument doc;
|
||||||
doc.Parse(xmlText);
|
doc.Parse(xmlText);
|
||||||
|
XMLTest( "Parse hex no closing tag round 2", true, doc.Error() );
|
||||||
doc.Clear();
|
doc.Clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1657,6 +1708,7 @@ int main( int argc, const char ** argv )
|
||||||
const char* xml = "�</a>";
|
const char* xml = "�</a>";
|
||||||
XMLDocument doc;
|
XMLDocument doc;
|
||||||
doc.Parse( xml );
|
doc.Parse( xml );
|
||||||
|
XMLTest( "Parse hex with closing tag", false, doc.Error() );
|
||||||
|
|
||||||
XMLPrinter printer;
|
XMLPrinter printer;
|
||||||
doc.Print( &printer );
|
doc.Print( &printer );
|
||||||
|
@ -1730,6 +1782,7 @@ int main( int argc, const char ** argv )
|
||||||
XMLDocument* doc = new XMLDocument();
|
XMLDocument* doc = new XMLDocument();
|
||||||
XMLTest( "XMLDocument::Value() returns null?", NULL, doc->Value() );
|
XMLTest( "XMLDocument::Value() returns null?", NULL, doc->Value() );
|
||||||
doc->Parse( validXml );
|
doc->Parse( validXml );
|
||||||
|
XMLTest( "Parse to test XMLDocument::Value()", false, doc->Error());
|
||||||
XMLTest( "XMLDocument::Value() returns null?", NULL, doc->Value() );
|
XMLTest( "XMLDocument::Value() returns null?", NULL, doc->Value() );
|
||||||
delete doc;
|
delete doc;
|
||||||
}
|
}
|
||||||
|
@ -1974,11 +2027,14 @@ int main( int argc, const char ** argv )
|
||||||
#else
|
#else
|
||||||
clock_t cstart = clock();
|
clock_t cstart = clock();
|
||||||
#endif
|
#endif
|
||||||
|
bool parseDreamXmlFailed = false;
|
||||||
static const int COUNT = 10;
|
static const int COUNT = 10;
|
||||||
for (int i = 0; i < COUNT; ++i) {
|
for (int i = 0; i < COUNT; ++i) {
|
||||||
XMLDocument doc;
|
XMLDocument doc;
|
||||||
doc.Parse(mem);
|
doc.Parse(mem);
|
||||||
|
parseDreamXmlFailed = parseDreamXmlFailed || doc.Error();
|
||||||
}
|
}
|
||||||
|
XMLTest( "Parse dream.xml", false, parseDreamXmlFailed );
|
||||||
#if defined( _MSC_VER )
|
#if defined( _MSC_VER )
|
||||||
QueryPerformanceCounter((LARGE_INTEGER*)&end);
|
QueryPerformanceCounter((LARGE_INTEGER*)&end);
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Reference in New Issue