diff options
author | Jan Kaluza <hanzz.k@gmail.com> | 2011-04-12 11:36:52 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2011-04-18 19:11:42 (GMT) |
commit | e0578b8fc582d431cce61ecac833ecf7031f6e75 (patch) | |
tree | c03e5bbe9419c5e6aed19e22f06491801f9659c1 /Swiften/Serializer/PayloadSerializers/UnitTest | |
parent | 92af1a97f318f7f623df3183e90e7e828fa2eeb9 (diff) | |
download | swift-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/Serializer/PayloadSerializers/UnitTest')
-rw-r--r-- | Swiften/Serializer/PayloadSerializers/UnitTest/RosterItemExchangeSerializerTest.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/RosterItemExchangeSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/RosterItemExchangeSerializerTest.cpp new file mode 100644 index 0000000..0fb44c9 --- /dev/null +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/RosterItemExchangeSerializerTest.cpp @@ -0,0 +1,54 @@ +/* + * 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/Serializer/PayloadSerializers/RosterItemExchangeSerializer.h" + +using namespace Swift; + +class RosterItemExchangeSerializerTest : public CppUnit::TestFixture +{ + CPPUNIT_TEST_SUITE(RosterItemExchangeSerializerTest); + CPPUNIT_TEST(testSerialize); + CPPUNIT_TEST_SUITE_END(); + + public: + RosterItemExchangeSerializerTest() {} + + void testSerialize() { + RosterItemExchangeSerializer testling; + boost::shared_ptr<RosterItemExchangePayload> roster(new RosterItemExchangePayload()); + + RosterItemExchangePayload::Item item1; + item1.jid = JID("foo@bar.com"); + item1.name = "Foo @ Bar"; + item1.action = RosterItemExchangePayload::Add; + item1.groups.push_back("Group 1"); + item1.groups.push_back("Group 2"); + roster->addItem(item1); + + RosterItemExchangePayload::Item item2; + item2.jid = JID("baz@blo.com"); + item2.name = "Baz"; + item2.action = RosterItemExchangePayload::Modify; + roster->addItem(item2); + + std::string expectedResult = + "<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>"; + + CPPUNIT_ASSERT_EQUAL(expectedResult, testling.serialize(roster)); + } +}; + +CPPUNIT_TEST_SUITE_REGISTRATION(RosterItemExchangeSerializerTest); |