summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-09-06 09:19:02 (GMT)
committerRemko Tronçon <git@el-tramo.be>2010-09-06 11:06:49 (GMT)
commit1e2c3461458f4274d539daf51507ce81d845cce0 (patch)
tree9507863b011691f22212d5cc76d484dff1343d36 /Swiften/Serializer/PayloadSerializers/UnitTest
parente8dbe2e2b78cd5e4a66e2e580e12d05b2e69b120 (diff)
downloadswift-contrib-1e2c3461458f4274d539daf51507ce81d845cce0.zip
swift-contrib-1e2c3461458f4274d539daf51507ce81d845cce0.tar.bz2
Partial VCard support without losing unknown data.
Diffstat (limited to 'Swiften/Serializer/PayloadSerializers/UnitTest')
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/VCardSerializerTest.cpp84
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 @@
+/*
+ * Copyright (c) 2010 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+
+#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> 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("<BDAY>1234</BDAY><MAILER>mutt</MAILER>");
+
+ 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 =
+ "<vCard xmlns=\"vcard-temp\">"
+ "<VERSION>2.0</VERSION>"
+ "<FN>Alice In Wonderland</FN>"
+ "<N>"
+ "<FAMILY>Wonderland</FAMILY>"
+ "<GIVEN>Alice</GIVEN>"
+ "<MIDDLE>In</MIDDLE>"
+ "<PREFIX>Mrs</PREFIX>"
+ "<SUFFIX>PhD</SUFFIX>"
+ "</N>"
+ "<EMAIL>"
+ "<USERID>alice@wonderland.lit</USERID>"
+ "<HOME/>"
+ "<INTERNET/>"
+ "<PREF/>"
+ "</EMAIL>"
+ "<EMAIL>"
+ "<USERID>alice@teaparty.lit</USERID>"
+ "<WORK/>"
+ "<X400/>"
+ "</EMAIL>"
+ "<NICKNAME>DreamGirl</NICKNAME>"
+ "<PHOTO>"
+ "<TYPE>image/png</TYPE>"
+ "<BINVAL>616263646566</BINVAL>"
+ "</PHOTO>"
+ "<BDAY>1234</BDAY>"
+ "<MAILER>mutt</MAILER>"
+ "</vCard>";
+
+ CPPUNIT_ASSERT_EQUAL(expectedResult, testling.serialize(vcard));
+ }
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION(VCardSerializerTest);