mirror of https://github.com/AxioDL/tinyxml2.git
Merge pull request #625 from Dmitry-Me/checkAcceptResult
Check result of Accept()
This commit is contained in:
commit
c59b17e5a9
30
xmltest.cpp
30
xmltest.cpp
|
@ -1035,8 +1035,9 @@ int main( int argc, const char ** argv )
|
||||||
if ( textfile )
|
if ( textfile )
|
||||||
{
|
{
|
||||||
XMLPrinter streamer( textfile );
|
XMLPrinter streamer( textfile );
|
||||||
psg->Accept( &streamer );
|
bool acceptResult = psg->Accept( &streamer );
|
||||||
fclose( textfile );
|
fclose( textfile );
|
||||||
|
XMLTest( "Entity transformation: Accept", true, acceptResult );
|
||||||
}
|
}
|
||||||
|
|
||||||
textfile = fopen( textFilePath, "r" );
|
textfile = fopen( textFilePath, "r" );
|
||||||
|
@ -1332,7 +1333,8 @@ int main( int argc, const char ** argv )
|
||||||
XMLTest( "Parse before deep cloning sub element", false, doc.Error() );
|
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);
|
bool acceptResult = subElement->Accept(&printer1);
|
||||||
|
XMLTest( "Accept before deep cloning", true, acceptResult );
|
||||||
|
|
||||||
XMLNode* clonedSubElement = subElement->DeepClone(&doc2);
|
XMLNode* clonedSubElement = subElement->DeepClone(&doc2);
|
||||||
doc2.InsertFirstChild(clonedSubElement);
|
doc2.InsertFirstChild(clonedSubElement);
|
||||||
|
@ -1648,7 +1650,8 @@ int main( int argc, const char ** argv )
|
||||||
XMLElement* ele = doc.FirstChildElement( "parent")->FirstChildElement( "child");
|
XMLElement* ele = doc.FirstChildElement( "parent")->FirstChildElement( "child");
|
||||||
|
|
||||||
XMLPrinter printer;
|
XMLPrinter printer;
|
||||||
ele->Accept( &printer );
|
bool acceptResult = ele->Accept( &printer );
|
||||||
|
XMLTest( "Accept of sub-element", true, acceptResult );
|
||||||
XMLTest( "Printing of sub-element", "<child>abc</child>\n", printer.CStr(), false );
|
XMLTest( "Printing of sub-element", "<child>abc</child>\n", printer.CStr(), false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1730,7 +1733,8 @@ int main( int argc, const char ** argv )
|
||||||
XMLElement* two = doc.RootElement()->FirstChildElement("two");
|
XMLElement* two = doc.RootElement()->FirstChildElement("two");
|
||||||
two->InsertFirstChild(subtree);
|
two->InsertFirstChild(subtree);
|
||||||
XMLPrinter printer1(0, true);
|
XMLPrinter printer1(0, true);
|
||||||
doc.Accept(&printer1);
|
bool acceptResult = doc.Accept(&printer1);
|
||||||
|
XMLTest("Move node from within <one> to <two> - Accept()", true, acceptResult);
|
||||||
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);
|
||||||
|
@ -1739,7 +1743,8 @@ int main( int argc, const char ** argv )
|
||||||
two = doc.RootElement()->FirstChildElement("two");
|
two = doc.RootElement()->FirstChildElement("two");
|
||||||
doc.RootElement()->InsertAfterChild(two, subtree);
|
doc.RootElement()->InsertAfterChild(two, subtree);
|
||||||
XMLPrinter printer2(0, true);
|
XMLPrinter printer2(0, true);
|
||||||
doc.Accept(&printer2);
|
acceptResult = doc.Accept(&printer2);
|
||||||
|
XMLTest("Move node from within <one> after <two> - Accept()", true, acceptResult);
|
||||||
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);
|
||||||
|
@ -1748,7 +1753,8 @@ int main( int argc, const char ** argv )
|
||||||
subtree = one->FirstChildElement("subtree");
|
subtree = one->FirstChildElement("subtree");
|
||||||
doc.RootElement()->InsertAfterChild(one, subtree);
|
doc.RootElement()->InsertAfterChild(one, subtree);
|
||||||
XMLPrinter printer3(0, true);
|
XMLPrinter printer3(0, true);
|
||||||
doc.Accept(&printer3);
|
acceptResult = doc.Accept(&printer3);
|
||||||
|
XMLTest("Move node from within <one> after <one> - Accept()", true, acceptResult);
|
||||||
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);
|
||||||
|
@ -1757,7 +1763,8 @@ int main( int argc, const char ** argv )
|
||||||
two = doc.RootElement()->FirstChildElement("two");
|
two = doc.RootElement()->FirstChildElement("two");
|
||||||
doc.RootElement()->InsertEndChild(subtree);
|
doc.RootElement()->InsertEndChild(subtree);
|
||||||
XMLPrinter printer4(0, true);
|
XMLPrinter printer4(0, true);
|
||||||
doc.Accept(&printer4);
|
acceptResult = doc.Accept(&printer4);
|
||||||
|
XMLTest("Move node from within <one> after <two> - Accept()", true, acceptResult);
|
||||||
XMLTest("Move node from within <one> after <two>", xmlAfterTwo, printer4.CStr(), false);
|
XMLTest("Move node from within <one> after <two>", xmlAfterTwo, printer4.CStr(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1881,7 +1888,8 @@ int main( int argc, const char ** argv )
|
||||||
XMLDocument doc;
|
XMLDocument doc;
|
||||||
XMLElement* newElement = doc.NewElement( "printme" );
|
XMLElement* newElement = doc.NewElement( "printme" );
|
||||||
XMLPrinter printer;
|
XMLPrinter printer;
|
||||||
newElement->Accept( &printer );
|
bool acceptResult = newElement->Accept( &printer );
|
||||||
|
XMLTest( "printme - Accept()", true, acceptResult );
|
||||||
// Delete the node to avoid possible memory leak report in debug output
|
// Delete the node to avoid possible memory leak report in debug output
|
||||||
doc.DeleteNode( newElement );
|
doc.DeleteNode( newElement );
|
||||||
}
|
}
|
||||||
|
@ -2032,7 +2040,8 @@ int main( int argc, const char ** argv )
|
||||||
};
|
};
|
||||||
|
|
||||||
tinyxml2::XMLPrinter printer;
|
tinyxml2::XMLPrinter printer;
|
||||||
playlist->Accept(&printer);
|
const bool acceptResult = playlist->Accept(&printer);
|
||||||
|
XMLTest("Crash bug parsing - Accept()", true, acceptResult);
|
||||||
printf("%s\n", printer.CStr());
|
printf("%s\n", printer.CStr());
|
||||||
|
|
||||||
// No test; it only need to not crash.
|
// No test; it only need to not crash.
|
||||||
|
@ -2121,7 +2130,8 @@ int main( int argc, const char ** argv )
|
||||||
void TestDocLines(const char *testString, XMLDocument &doc, const char *expectedLines)
|
void TestDocLines(const char *testString, XMLDocument &doc, const char *expectedLines)
|
||||||
{
|
{
|
||||||
str.Clear();
|
str.Clear();
|
||||||
doc.Accept(this);
|
const bool acceptResult = doc.Accept(this);
|
||||||
|
XMLTest(testString, true, acceptResult);
|
||||||
str.Push(0);
|
str.Push(0);
|
||||||
XMLTest(testString, expectedLines, str.Mem());
|
XMLTest(testString, expectedLines, str.Mem());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue