From 321072ee0b3ab0b64b1e94c2e2a2e00096892a2f Mon Sep 17 00:00:00 2001 From: Uli Kusterer Date: Tue, 21 Jan 2014 01:57:38 +0100 Subject: [PATCH] Add tests for SetText(). --- xmltest.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/xmltest.cpp b/xmltest.cpp index 2c1fece..6cde449 100644 --- a/xmltest.cpp +++ b/xmltest.cpp @@ -617,6 +617,38 @@ int main( int argc, const char ** argv ) } + // --------SetText()----------- + { + const char* str = ""; + XMLDocument doc; + doc.Parse( str ); + XMLElement* element = doc.RootElement(); + + element->SetText("He kept turning his head to left and right, but I could not see anything through the darkness."); + XMLTest( "SetText() normal use (open/close).", "He kept turning his head to left and right, but I could not see anything through the darkness.", element->GetText() ); + + element->SetText("Suddenly, away on our left I saw a faint flickering blue flame."); + XMLTest( "SetText() replace.", "Suddenly, away on our left I saw a faint flickering blue flame.", element->GetText() ); + + str = ""; + doc.Parse( str ); + element = doc.RootElement(); + + element->SetText("The driver saw it at the same moment."); + XMLTest( "SetText() normal use. (self-closing)", "The driver saw it at the same moment.", element->GetText() ); + + element->SetText("He at once checked the horses, and, jumping to the ground, disappeared into the darkness."); + XMLTest( "SetText() replace with tag-like text.", "He at once checked the horses, and, jumping to the ground, disappeared into the darkness.", element->GetText() ); + + str = "Text in nested element"; + doc.Parse( str ); + element = doc.RootElement(); + + element->SetText("I did not know what to do, the less as the howling of the wolves grew closer."); + XMLTest( "SetText() prefix to nested non-text children.", "I did not know what to do, the less as the howling of the wolves grew closer.", element->GetText() ); + } + + // ---------- CDATA --------------- { const char* str = ""