Merge pull request #625 from Dmitry-Me/checkAcceptResult

Check result of Accept()
This commit is contained in:
Lee Thomason 2017-10-09 15:58:19 -07:00 committed by GitHub
commit c59b17e5a9
1 changed files with 20 additions and 10 deletions

View File

@ -1035,8 +1035,9 @@ int main( int argc, const char ** argv )
if ( textfile )
{
XMLPrinter streamer( textfile );
psg->Accept( &streamer );
bool acceptResult = psg->Accept( &streamer );
fclose( textfile );
XMLTest( "Entity transformation: Accept", true, acceptResult );
}
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() );
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);
doc2.InsertFirstChild(clonedSubElement);
@ -1648,7 +1650,8 @@ int main( int argc, const char ** argv )
XMLElement* ele = doc.FirstChildElement( "parent")->FirstChildElement( "child");
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 );
}
@ -1730,7 +1733,8 @@ int main( int argc, const char ** argv )
XMLElement* two = doc.RootElement()->FirstChildElement("two");
two->InsertFirstChild(subtree);
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());
doc.Parse(xml);
@ -1739,7 +1743,8 @@ int main( int argc, const char ** argv )
two = doc.RootElement()->FirstChildElement("two");
doc.RootElement()->InsertAfterChild(two, subtree);
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);
doc.Parse(xml);
@ -1748,7 +1753,8 @@ int main( int argc, const char ** argv )
subtree = one->FirstChildElement("subtree");
doc.RootElement()->InsertAfterChild(one, subtree);
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);
doc.Parse(xml);
@ -1757,7 +1763,8 @@ int main( int argc, const char ** argv )
two = doc.RootElement()->FirstChildElement("two");
doc.RootElement()->InsertEndChild(subtree);
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);
}
@ -1881,7 +1888,8 @@ int main( int argc, const char ** argv )
XMLDocument doc;
XMLElement* newElement = doc.NewElement( "printme" );
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
doc.DeleteNode( newElement );
}
@ -2032,7 +2040,8 @@ int main( int argc, const char ** argv )
};
tinyxml2::XMLPrinter printer;
playlist->Accept(&printer);
const bool acceptResult = playlist->Accept(&printer);
XMLTest("Crash bug parsing - Accept()", true, acceptResult);
printf("%s\n", printer.CStr());
// 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)
{
str.Clear();
doc.Accept(this);
const bool acceptResult = doc.Accept(this);
XMLTest(testString, true, acceptResult);
str.Push(0);
XMLTest(testString, expectedLines, str.Mem());
}