summaryrefslogtreecommitdiff
path: root/src/test.cpp
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2014-05-30 03:51:54 +0200
committerFlorent Le Coz <louiz@louiz.org>2014-05-30 04:00:23 +0200
commit6bde78b5743d6b323b9af14d434927fd175175c3 (patch)
treeb72e10a690d81a8a11babc71c853789f5ae8eca3 /src/test.cpp
parenteb9a20187098185cc10ad192e91a90dbba12633a (diff)
downloadbiboumi-6bde78b5743d6b323b9af14d434927fd175175c3.tar.gz
biboumi-6bde78b5743d6b323b9af14d434927fd175175c3.tar.bz2
biboumi-6bde78b5743d6b323b9af14d434927fd175175c3.tar.xz
biboumi-6bde78b5743d6b323b9af14d434927fd175175c3.zip
XmlNode’s copy constructor now recursively copies the children nodes as well
Diffstat (limited to 'src/test.cpp')
-rw-r--r--src/test.cpp27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/test.cpp b/src/test.cpp
index e71ea35..8fe739c 100644
--- a/src/test.cpp
+++ b/src/test.cpp
@@ -151,18 +151,25 @@ int main()
std::cout << color << "Testing XML parsing…" << reset << std::endl;
XmppParser xml;
const std::string doc = "<stream xmlns='stream_ns'><stanza b='c'>inner<child1><grandchild/></child1><child2 xmlns='child2_ns'/>tail</stanza></stream>";
- xml.add_stanza_callback([](const Stanza& stanza)
+ auto check_stanza = [](const Stanza& stanza)
+ {
+ assert(stanza.get_name() == "stanza");
+ assert(stanza.get_tag("xmlns") == "stream_ns");
+ assert(stanza.get_tag("b") == "c");
+ assert(stanza.get_inner() == "inner");
+ assert(stanza.get_tail() == "");
+ assert(stanza.get_child("child1", "stream_ns") != nullptr);
+ assert(stanza.get_child("child2", "stream_ns") == nullptr);
+ assert(stanza.get_child("child2", "child2_ns") != nullptr);
+ assert(stanza.get_child("child2", "child2_ns")->get_tail() == "tail");
+ };
+ xml.add_stanza_callback([check_stanza](const Stanza& stanza)
{
std::cout << stanza.to_string() << std::endl;
- assert(stanza.get_name() == "stanza");
- assert(stanza.get_tag("xmlns") == "stream_ns");
- assert(stanza.get_tag("b") == "c");
- assert(stanza.get_inner() == "inner");
- assert(stanza.get_tail() == "");
- assert(stanza.get_child("child1", "stream_ns") != nullptr);
- assert(stanza.get_child("child2", "stream_ns") == nullptr);
- assert(stanza.get_child("child2", "child2_ns") != nullptr);
- assert(stanza.get_child("child2", "child2_ns")->get_tail() == "tail");
+ check_stanza(stanza);
+ // Do the same checks on a copy of that stanza.
+ Stanza copy(stanza);
+ check_stanza(copy);
});
xml.feed(doc.data(), doc.size(), true);