diff options
author | Remko Tronçon <git@el-tramo.be> | 2009-06-20 09:00:52 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2009-06-20 14:37:51 (GMT) |
commit | fcd2d7cfb5a05be0fd13bfa3582b46c1a1b595aa (patch) | |
tree | 17e3eef980584b8f194d68d1d9b9eae967423885 /Swiften/Parser/PayloadParsers/UnitTest | |
parent | 6310bc00ceeb65f0cf6fc0ada9d1b188517d8a76 (diff) | |
download | swift-fcd2d7cfb5a05be0fd13bfa3582b46c1a1b595aa.zip swift-fcd2d7cfb5a05be0fd13bfa3582b46c1a1b595aa.tar.bz2 |
Added beginnings of a vCard parser.
Only implemented PHOTO subtag, because it's the only thing we
need right now.
Diffstat (limited to 'Swiften/Parser/PayloadParsers/UnitTest')
-rw-r--r-- | Swiften/Parser/PayloadParsers/UnitTest/Makefile.inc | 3 | ||||
-rw-r--r-- | Swiften/Parser/PayloadParsers/UnitTest/VCardParserTest.cpp | 39 |
2 files changed, 41 insertions, 1 deletions
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/Makefile.inc b/Swiften/Parser/PayloadParsers/UnitTest/Makefile.inc index 6d492c1..26f7b3c 100644 --- a/Swiften/Parser/PayloadParsers/UnitTest/Makefile.inc +++ b/Swiften/Parser/PayloadParsers/UnitTest/Makefile.inc @@ -10,4 +10,5 @@ UNITTEST_SOURCES += \ Swiften/Parser/PayloadParsers/UnitTest/ResourceBindParserTest.cpp \ Swiften/Parser/PayloadParsers/UnitTest/SecurityLabelParserTest.cpp \ Swiften/Parser/PayloadParsers/UnitTest/SecurityLabelsCatalogParserTest.cpp \ - Swiften/Parser/PayloadParsers/UnitTest/VCardUpdateParserTest.cpp + Swiften/Parser/PayloadParsers/UnitTest/VCardUpdateParserTest.cpp \ + Swiften/Parser/PayloadParsers/UnitTest/VCardParserTest.cpp diff --git a/Swiften/Parser/PayloadParsers/UnitTest/VCardParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/VCardParserTest.cpp new file mode 100644 index 0000000..2d16636 --- /dev/null +++ b/Swiften/Parser/PayloadParsers/UnitTest/VCardParserTest.cpp @@ -0,0 +1,39 @@ +#include <cppunit/extensions/HelperMacros.h> +#include <cppunit/extensions/TestFactoryRegistry.h> + +#include "Swiften/Parser/PayloadParsers/VCardParser.h" +#include "Swiften/Parser/PayloadParsers/UnitTest/PayloadParserTester.h" + +using namespace Swift; + +class VCardParserTest : public CppUnit::TestFixture +{ + CPPUNIT_TEST_SUITE(VCardParserTest); + CPPUNIT_TEST(testParse_Photo); + CPPUNIT_TEST_SUITE_END(); + + public: + VCardParserTest() {} + + void testParse_Photo() { + VCardParser testling; + PayloadParserTester parser(&testling); + + CPPUNIT_ASSERT(parser.parse( + "<vCard xmlns='vcard-temp'>" + "<PHOTO>" + "<TYPE>image/jpeg</TYPE>" + "<BINVAL>" + "QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ej" + "EyMzQ1Njc4OTA=" + "</BINVAL>" + "</PHOTO>" + "</vCard>")); + + VCard* payload = dynamic_cast<VCard*>(testling.getPayload().get()); + CPPUNIT_ASSERT_EQUAL(String("image/jpeg"), payload->getPhotoType()); + CPPUNIT_ASSERT_EQUAL(ByteArray("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890"), payload->getPhoto()); + } +}; + +CPPUNIT_TEST_SUITE_REGISTRATION(VCardParserTest); |