summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Parser/PayloadParsers/UnitTest/VCardParserTest.cpp')
-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;