From 3d92360310d8e35394109058ff723da57af5b380 Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Sun, 10 Nov 2013 02:26:07 +0100 Subject: Use the Expat library directly instead of relying on expatpp And now we handle namespaces, yay. And a nice little test. --- src/test.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/test.cpp') diff --git a/src/test.cpp b/src/test.cpp index d110868..674be98 100644 --- a/src/test.cpp +++ b/src/test.cpp @@ -10,7 +10,7 @@ #include #include -#include +#include int main() { @@ -44,5 +44,23 @@ int main() std::string coucou("\u0002\u0002COUCOU\u0003"); remove_irc_colors(coucou); assert(coucou == "COUCOU"); + + /** + * XML parsing + */ + XmppParser xml; + const std::string doc = "innertail"; + xml.add_stanza_callback([](const Stanza& stanza) + { + assert(stanza.get_name() == "stream_ns:stanza"); + assert(stanza["b"] == "c"); + assert(stanza.get_inner() == "inner"); + assert(stanza.get_tail() == ""); + assert(stanza.get_child("stream_ns:child1") != nullptr); + assert(stanza.get_child("stream_ns:child2") == nullptr); + assert(stanza.get_child("child2_ns:child2") != nullptr); + assert(stanza.get_child("child2_ns:child2")->get_tail() == "tail"); + }); + xml.feed(doc.data(), doc.size(), true); return 0; } -- cgit v1.2.3