blob: 999eb34095377d3e3a5909ac7135420693fcd190 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
/*
* 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/Parser/PayloadParsers/VCardParser.h"
#include "Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h"
using namespace Swift;
class VCardParserTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(VCardParserTest);
CPPUNIT_TEST(testParse_Photo);
CPPUNIT_TEST(testParse_Nickname);
CPPUNIT_TEST_SUITE_END();
public:
VCardParserTest() {}
void testParse_Photo() {
PayloadsParserTester parser;
CPPUNIT_ASSERT(parser.parse(
"<vCard xmlns='vcard-temp'>"
"<PHOTO>"
"<TYPE>image/jpeg</TYPE>"
"<BINVAL>"
"QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ej"
"EyMzQ1Njc4OTA="
"</BINVAL>"
"</PHOTO>"
"</vCard>"));
VCard* payload = dynamic_cast<VCard*>(parser.getPayload().get());
CPPUNIT_ASSERT_EQUAL(String("image/jpeg"), payload->getPhotoType());
CPPUNIT_ASSERT_EQUAL(ByteArray("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890"), payload->getPhoto());
}
void testParse_Nickname() {
PayloadsParserTester parser;
CPPUNIT_ASSERT(parser.parse(
"<vCard xmlns='vcard-temp'>"
"<NICKNAME>mynick</NICKNAME>"
"</vCard>"));
VCard* payload = dynamic_cast<VCard*>(parser.getPayload().get());
CPPUNIT_ASSERT_EQUAL(String("mynick"), payload->getNickname());
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(VCardParserTest);
|