/* * Copyright (c) 2011 Jan Kaluza * Licensed under the Simplified BSD license. * See Documentation/Licenses/BSD-simplified.txt for more information. */ #include #include #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( "" "" "Group 1" "Group 2" "" "" "")); RosterItemExchangePayload* payload = dynamic_cast(parser.getPayload().get()); const RosterItemExchangePayload::RosterItemExchangePayloadItems& items = payload->getItems(); CPPUNIT_ASSERT_EQUAL(static_cast(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(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(0), items[1].groups.size()); } }; CPPUNIT_TEST_SUITE_REGISTRATION(RosterItemExchangeParserTest);