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/Parser/PayloadParsers/UnitTest
parente8dbe2e2b78cd5e4a66e2e580e12d05b2e69b120 (diff)
downloadswift-contrib-1e2c3461458f4274d539daf51507ce81d845cce0.zip
swift-contrib-1e2c3461458f4274d539daf51507ce81d845cce0.tar.bz2
Partial VCard support without losing unknown data.
Diffstat (limited to 'Swiften/Parser/PayloadParsers/UnitTest')
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/VCardParserTest.cpp59
1 files changed, 56 insertions, 3 deletions
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/VCardParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/VCardParserTest.cpp
index 999eb34..dfcc0ec 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/VCardParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/VCardParserTest.cpp
@@ -12,15 +12,68 @@
using namespace Swift;
-class VCardParserTest : public CppUnit::TestFixture
-{
+class VCardParserTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(VCardParserTest);
+ CPPUNIT_TEST(testParse);
CPPUNIT_TEST(testParse_Photo);
CPPUNIT_TEST(testParse_Nickname);
CPPUNIT_TEST_SUITE_END();
public:
- VCardParserTest() {}
+ void testParse() {
+ PayloadsParserTester parser;
+
+ CPPUNIT_ASSERT(parser.parse(
+ "<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>"
+ "<BDAY>1234</BDAY>"
+ "<MAILER>mutt</MAILER>"
+ "</vCard>"));
+
+ boost::shared_ptr<VCard> payload = boost::dynamic_pointer_cast<VCard>(parser.getPayload());
+ CPPUNIT_ASSERT_EQUAL(String("2.0"), payload->getVersion());
+ CPPUNIT_ASSERT_EQUAL(String("Alice In Wonderland"), payload->getFullName());
+ CPPUNIT_ASSERT_EQUAL(String("Alice"), payload->getGivenName());
+ CPPUNIT_ASSERT_EQUAL(String("In"), payload->getMiddleName());
+ CPPUNIT_ASSERT_EQUAL(String("Wonderland"), payload->getFamilyName());
+ CPPUNIT_ASSERT_EQUAL(String("Mrs"), payload->getPrefix());
+ CPPUNIT_ASSERT_EQUAL(String("PhD"), payload->getSuffix());
+ CPPUNIT_ASSERT_EQUAL(String("DreamGirl"), payload->getNickname());
+ CPPUNIT_ASSERT_EQUAL(String("<BDAY xmlns=\"vcard-temp\">1234</BDAY><MAILER xmlns=\"vcard-temp\">mutt</MAILER>"), payload->getUnknownContent());
+ CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(payload->getEMailAddresses().size()));
+ CPPUNIT_ASSERT_EQUAL(String("alice@wonderland.lit"), payload->getEMailAddresses()[0].address);
+ CPPUNIT_ASSERT(payload->getEMailAddresses()[0].isHome);
+ CPPUNIT_ASSERT(payload->getEMailAddresses()[0].isInternet);
+ CPPUNIT_ASSERT(payload->getEMailAddresses()[0].isPreferred);
+ CPPUNIT_ASSERT(!payload->getEMailAddresses()[0].isWork);
+ CPPUNIT_ASSERT(!payload->getEMailAddresses()[0].isX400);
+ CPPUNIT_ASSERT_EQUAL(String("alice@teaparty.lit"), payload->getEMailAddresses()[1].address);
+ CPPUNIT_ASSERT(!payload->getEMailAddresses()[1].isHome);
+ CPPUNIT_ASSERT(!payload->getEMailAddresses()[1].isInternet);
+ CPPUNIT_ASSERT(!payload->getEMailAddresses()[1].isPreferred);
+ CPPUNIT_ASSERT(payload->getEMailAddresses()[1].isWork);
+ CPPUNIT_ASSERT(payload->getEMailAddresses()[1].isX400);
+ }
void testParse_Photo() {
PayloadsParserTester parser;