From 8e06370191061cea050bab259d14d988c9c45f5e Mon Sep 17 00:00:00 2001 From: Dmitry-Me Date: Tue, 1 Aug 2017 17:40:40 +0300 Subject: [PATCH] Test return values from nodes insertion --- xmltest.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/xmltest.cpp b/xmltest.cpp index 3fada04..529ae37 100644 --- a/xmltest.cpp +++ b/xmltest.cpp @@ -402,6 +402,25 @@ int main( int argc, const char ** argv ) XMLTest( "Element with sub element", false, doc->Error() ); delete doc; } + { + // Test: Programmatic DOM nodes insertion return values + XMLDocument doc; + + XMLNode* first = doc.NewElement( "firstElement" ); + XMLTest( "New element", true, first != 0 ); + XMLNode* firstAfterInsertion = doc.InsertFirstChild( first ); + XMLTest( "New element inserted first", true, firstAfterInsertion == first ); + + XMLNode* last = doc.NewElement( "lastElement" ); + XMLTest( "New element", true, last != 0 ); + XMLNode* lastAfterInsertion = doc.InsertEndChild( last ); + XMLTest( "New element inserted last", true, lastAfterInsertion == last ); + + XMLNode* middle = doc.NewElement( "middleElement" ); + XMLTest( "New element", true, middle != 0 ); + XMLNode* middleAfterInsertion = doc.InsertAfterChild( first, middle ); + XMLTest( "New element inserted middle", true, middleAfterInsertion == middle ); + } { // Test: Programmatic DOM // Build: @@ -946,7 +965,9 @@ int main( int argc, const char ** argv ) XMLElement* childText1 = doc.NewElement( "childText1" ); XMLNode* childNode0 = parent->InsertEndChild( childText0 ); + XMLTest( "InsertEndChild() return", true, childNode0 == childText0 ); XMLNode* childNode1 = parent->InsertAfterChild( childNode0, childText1 ); + XMLTest( "InsertAfterChild() return", true, childNode1 == childText1 ); XMLTest( "Test InsertAfterChild on empty node. ", true, ( childNode1 == parent->LastChild() ) ); }