diff options
author | Jonas Smedegaard <dr@jones.dk> | 2017-06-24 09:21:37 +0200 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2017-06-24 09:21:37 +0200 |
commit | 3d39f109ba8ea7ae9778c58bd1665b9e8e0f45cb (patch) | |
tree | 9a5684babcd16d302fbe59c56b6045660ad62488 /tests/xmpp.cpp | |
parent | f9cee98aacd6aea8ccb7f5677b4ff1e1e234e4d1 (diff) | |
parent | c21cbbf9667991d2b928562a9c199e625d3f9bba (diff) | |
download | biboumi-3d39f109ba8ea7ae9778c58bd1665b9e8e0f45cb.tar.gz biboumi-3d39f109ba8ea7ae9778c58bd1665b9e8e0f45cb.tar.bz2 biboumi-3d39f109ba8ea7ae9778c58bd1665b9e8e0f45cb.tar.xz biboumi-3d39f109ba8ea7ae9778c58bd1665b9e8e0f45cb.zip |
Updated version 5.0 from 'upstream/5.0'
with Debian dir 2ae31d03ffb1d79153a692af23c7b2b097cc4b2b
Diffstat (limited to 'tests/xmpp.cpp')
-rw-r--r-- | tests/xmpp.cpp | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/tests/xmpp.cpp b/tests/xmpp.cpp index 37d2b54..14c51da 100644 --- a/tests/xmpp.cpp +++ b/tests/xmpp.cpp @@ -30,20 +30,21 @@ TEST_CASE("Test basic XML parsing") // And do the same checks on moved-constructed stanza Stanza moved(std::move(copy)); }); - xml.feed(doc.data(), doc.size(), true); + CHECK(doc.size() <= std::numeric_limits<int>::max()); + xml.feed(doc.data(), static_cast<int>(doc.size()), true); const std::string doc2 = "<stream xmlns='s'><stanza>coucou\r\n\a</stanza></stream>"; xml.add_stanza_callback([](const Stanza& stanza) { CHECK(stanza.get_inner() == "coucou\r\n"); }); - - xml.feed(doc2.data(), doc.size(), true); + CHECK(doc.size() <= std::numeric_limits<int>::max()); + xml.feed(doc2.data(), static_cast<int>(doc.size()), true); } TEST_CASE("XML escape") { - const std::string unescaped = "'coucou'<cc>/&\"gaga\""; + const std::string unescaped = R"('coucou'<cc>/&"gaga")"; CHECK(xml_escape(unescaped) == "'coucou'<cc>/&"gaga""); } @@ -52,3 +53,20 @@ TEST_CASE("handshake_digest") const auto res = get_handshake_digest("id1234", "S4CR3T"); CHECK(res == "c92901b5d376ad56269914da0cce3aab976847df"); } + +TEST_CASE("substanzas") +{ + Stanza a("a"); + { + XmlSubNode b(a, "b"); + { + CHECK(!a.has_children()); + XmlSubNode c(b, "c"); + XmlSubNode d(b, "d"); + CHECK(!c.has_children()); + CHECK(!d.has_children()); + } + CHECK(b.has_children()); + } + CHECK(a.has_children()); +} |