diff options
Diffstat (limited to 'Swiften/Serializer/PayloadSerializers/UnitTest/VCardSerializerTest.cpp')
| -rw-r--r-- | Swiften/Serializer/PayloadSerializers/UnitTest/VCardSerializerTest.cpp | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/VCardSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/VCardSerializerTest.cpp new file mode 100644 index 0000000..11b24dc --- /dev/null +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/VCardSerializerTest.cpp | |||
| @@ -0,0 +1,84 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2010 Remko Tronçon | ||
| 3 | * Licensed under the GNU General Public License v3. | ||
| 4 | * See Documentation/Licenses/GPLv3.txt for more information. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include <cppunit/extensions/HelperMacros.h> | ||
| 8 | #include <cppunit/extensions/TestFactoryRegistry.h> | ||
| 9 | |||
| 10 | #include "Swiften/Serializer/PayloadSerializers/VCardSerializer.h" | ||
| 11 | |||
| 12 | using namespace Swift; | ||
| 13 | |||
| 14 | class VCardSerializerTest : public CppUnit::TestFixture | ||
| 15 | { | ||
| 16 | CPPUNIT_TEST_SUITE(VCardSerializerTest); | ||
| 17 | CPPUNIT_TEST(testSerialize); | ||
| 18 | CPPUNIT_TEST_SUITE_END(); | ||
| 19 | |||
| 20 | public: | ||
| 21 | void testSerialize() { | ||
| 22 | VCardSerializer testling; | ||
| 23 | boost::shared_ptr<VCard> vcard(new VCard()); | ||
| 24 | vcard->setVersion("2.0"); | ||
| 25 | vcard->setFullName("Alice In Wonderland"); | ||
| 26 | vcard->setPrefix("Mrs"); | ||
| 27 | vcard->setGivenName("Alice"); | ||
| 28 | vcard->setMiddleName("In"); | ||
| 29 | vcard->setFamilyName("Wonderland"); | ||
| 30 | vcard->setSuffix("PhD"); | ||
| 31 | vcard->setNickname("DreamGirl"); | ||
| 32 | vcard->setPhoto("abcdef"); | ||
| 33 | vcard->setPhotoType("image/png"); | ||
| 34 | vcard->addUnknownContent("<BDAY>1234</BDAY><MAILER>mutt</MAILER>"); | ||
| 35 | |||
| 36 | VCard::EMailAddress address1; | ||
| 37 | address1.address = "alice@wonderland.lit"; | ||
| 38 | address1.isHome = true; | ||
| 39 | address1.isPreferred = true; | ||
| 40 | address1.isInternet = true; | ||
| 41 | vcard->addEMailAddress(address1); | ||
| 42 | |||
| 43 | VCard::EMailAddress address2; | ||
| 44 | address2.address = "alice@teaparty.lit"; | ||
| 45 | address2.isWork = true; | ||
| 46 | address2.isX400 = true; | ||
| 47 | vcard->addEMailAddress(address2); | ||
| 48 | |||
| 49 | String expectedResult = | ||
| 50 | "<vCard xmlns=\"vcard-temp\">" | ||
| 51 | "<VERSION>2.0</VERSION>" | ||
| 52 | "<FN>Alice In Wonderland</FN>" | ||
| 53 | "<N>" | ||
| 54 | "<FAMILY>Wonderland</FAMILY>" | ||
| 55 | "<GIVEN>Alice</GIVEN>" | ||
| 56 | "<MIDDLE>In</MIDDLE>" | ||
| 57 | "<PREFIX>Mrs</PREFIX>" | ||
| 58 | "<SUFFIX>PhD</SUFFIX>" | ||
| 59 | "</N>" | ||
| 60 | "<EMAIL>" | ||
| 61 | "<USERID>alice@wonderland.lit</USERID>" | ||
| 62 | "<HOME/>" | ||
| 63 | "<INTERNET/>" | ||
| 64 | "<PREF/>" | ||
| 65 | "</EMAIL>" | ||
| 66 | "<EMAIL>" | ||
| 67 | "<USERID>alice@teaparty.lit</USERID>" | ||
| 68 | "<WORK/>" | ||
| 69 | "<X400/>" | ||
| 70 | "</EMAIL>" | ||
| 71 | "<NICKNAME>DreamGirl</NICKNAME>" | ||
| 72 | "<PHOTO>" | ||
| 73 | "<TYPE>image/png</TYPE>" | ||
| 74 | "<BINVAL>616263646566</BINVAL>" | ||
| 75 | "</PHOTO>" | ||
| 76 | "<BDAY>1234</BDAY>" | ||
| 77 | "<MAILER>mutt</MAILER>" | ||
| 78 | "</vCard>"; | ||
| 79 | |||
| 80 | CPPUNIT_ASSERT_EQUAL(expectedResult, testling.serialize(vcard)); | ||
| 81 | } | ||
| 82 | }; | ||
| 83 | |||
| 84 | CPPUNIT_TEST_SUITE_REGISTRATION(VCardSerializerTest); | ||
Swift