summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Kaluza <hanzz.k@gmail.com>2011-04-12 11:36:52 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-04-18 19:11:42 (GMT)
commite0578b8fc582d431cce61ecac833ecf7031f6e75 (patch)
treec03e5bbe9419c5e6aed19e22f06491801f9659c1 /Swiften/Parser/PayloadParsers/UnitTest
parent92af1a97f318f7f623df3183e90e7e828fa2eeb9 (diff)
downloadswift-e0578b8fc582d431cce61ecac833ecf7031f6e75.zip
swift-e0578b8fc582d431cce61ecac833ecf7031f6e75.tar.bz2
Added Roster Item Exchange XEP support.
License: This patch is BSD-licensed, see http://www.opensource.org/licenses/bsd-license.php
Diffstat (limited to 'Swiften/Parser/PayloadParsers/UnitTest')
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/RosterItemExchangeParserTest.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/RosterItemExchangeParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/RosterItemExchangeParserTest.cpp
new file mode 100644
index 0000000..ceba45f
--- /dev/null
+++ b/Swiften/Parser/PayloadParsers/UnitTest/RosterItemExchangeParserTest.cpp
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2011 Jan Kaluza
+ * Licensed under the Simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+
+#include "Swiften/Parser/PayloadParsers/RosterItemExchangeParser.h"
+#include "Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h"
+
+using namespace Swift;
+
+class RosterItemExchangeParserTest : public CppUnit::TestFixture
+{
+ CPPUNIT_TEST_SUITE(RosterItemExchangeParserTest);
+ CPPUNIT_TEST(testParse);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void testParse() {
+ PayloadsParserTester parser;
+ CPPUNIT_ASSERT(parser.parse(
+ "<x xmlns=\"http://jabber.org/protocol/rosterx\">"
+ "<item action=\"add\" jid=\"foo@bar.com\" name=\"Foo @ Bar\">"
+ "<group>Group 1</group>"
+ "<group>Group 2</group>"
+ "</item>"
+ "<item action=\"modify\" jid=\"baz@blo.com\" name=\"Baz\"/>"
+ "</x>"));
+
+ RosterItemExchangePayload* payload = dynamic_cast<RosterItemExchangePayload*>(parser.getPayload().get());
+ const RosterItemExchangePayload::RosterItemExchangePayloadItems& items = payload->getItems();
+
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), items.size());
+
+ CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com"), items[0].jid);
+ CPPUNIT_ASSERT_EQUAL(std::string("Foo @ Bar"), items[0].name);
+ CPPUNIT_ASSERT_EQUAL(RosterItemExchangePayload::Add, items[0].action);
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), items[0].groups.size());
+ CPPUNIT_ASSERT_EQUAL(std::string("Group 1"), items[0].groups[0]);
+ CPPUNIT_ASSERT_EQUAL(std::string("Group 2"), items[0].groups[1]);
+
+ CPPUNIT_ASSERT_EQUAL(JID("baz@blo.com"), items[1].jid);
+ CPPUNIT_ASSERT_EQUAL(std::string("Baz"), items[1].name);
+ CPPUNIT_ASSERT_EQUAL(RosterItemExchangePayload::Modify, items[1].action);
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), items[1].groups.size());
+ }
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION(RosterItemExchangeParserTest);