summaryrefslogtreecommitdiff
path: root/src/test.cpp
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2013-11-10 02:26:07 +0100
committerFlorent Le Coz <louiz@louiz.org>2013-11-10 02:30:22 +0100
commit3d92360310d8e35394109058ff723da57af5b380 (patch)
treea268ca56705b09251151919c51daef63f04bee22 /src/test.cpp
parent8acd7a02aeda01c0ac828b05c36f10bbacaea70e (diff)
downloadbiboumi-3d92360310d8e35394109058ff723da57af5b380.tar.gz
biboumi-3d92360310d8e35394109058ff723da57af5b380.tar.bz2
biboumi-3d92360310d8e35394109058ff723da57af5b380.tar.xz
biboumi-3d92360310d8e35394109058ff723da57af5b380.zip
Use the Expat library directly instead of relying on expatpp
And now we handle namespaces, yay. And a nice little test.
Diffstat (limited to 'src/test.cpp')
-rw-r--r--src/test.cpp20
1 files changed, 19 insertions, 1 deletions
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 <utils/encoding.hpp>
#include <string.h>
-#include <fstream>
+#include <xmpp/xmpp_parser.hpp>
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 = "<stream xmlns='stream_ns'><stanza b='c'>inner<child1/><child2 xmlns='child2_ns'/>tail</stanza></stream>";
+ 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;
}