/* * Copyright (c) 2010 Remko Tronçon * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. */ #include #include #include "Swiften/Serializer/PayloadSerializers/VCardSerializer.h" using namespace Swift; class VCardSerializerTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(VCardSerializerTest); CPPUNIT_TEST(testSerialize); CPPUNIT_TEST_SUITE_END(); public: void testSerialize() { VCardSerializer testling; boost::shared_ptr vcard(new VCard()); vcard->setVersion("2.0"); vcard->setFullName("Alice In Wonderland"); vcard->setPrefix("Mrs"); vcard->setGivenName("Alice"); vcard->setMiddleName("In"); vcard->setFamilyName("Wonderland"); vcard->setSuffix("PhD"); vcard->setNickname("DreamGirl"); vcard->setPhoto("abcdef"); vcard->setPhotoType("image/png"); vcard->addUnknownContent("1234mutt"); VCard::EMailAddress address1; address1.address = "alice@wonderland.lit"; address1.isHome = true; address1.isPreferred = true; address1.isInternet = true; vcard->addEMailAddress(address1); VCard::EMailAddress address2; address2.address = "alice@teaparty.lit"; address2.isWork = true; address2.isX400 = true; vcard->addEMailAddress(address2); String expectedResult = "" "2.0" "Alice In Wonderland" "" "Wonderland" "Alice" "In" "Mrs" "PhD" "" "" "alice@wonderland.lit" "" "" "" "" "" "alice@teaparty.lit" "" "" "" "DreamGirl" "" "image/png" "YWJjZGVm" "" "1234" "mutt" ""; CPPUNIT_ASSERT_EQUAL(expectedResult, testling.serialize(vcard)); } }; CPPUNIT_TEST_SUITE_REGISTRATION(VCardSerializerTest);