blob: e8328b8cb357ea993ec920cab078d56fa6ec8d5d (
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
/*
* 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/SearchPayloadSerializer.h"
using namespace Swift;
class SearchPayloadSerializerTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(SearchPayloadSerializerTest);
CPPUNIT_TEST(testSerialize_Request);
CPPUNIT_TEST(testSerialize_Items);
CPPUNIT_TEST_SUITE_END();
public:
void testSerialize_Request() {
SearchPayloadSerializer testling;
SearchPayload::ref payload(new SearchPayload());
payload->setFirst("Juliet");
payload->setLast("Capulet");
CPPUNIT_ASSERT_EQUAL(std::string(
"<query xmlns=\"jabber:iq:search\">"
"<first>Juliet</first>"
"<last>Capulet</last>"
"</query>"
), testling.serialize(payload));
}
void testSerialize_Items() {
SearchPayloadSerializer testling;
SearchPayload::ref payload(new SearchPayload());
SearchPayload::Item item1;
item1.jid = JID("juliet@capulet.com");
item1.first = "Juliet";
item1.last = "Capulet";
item1.nick = "JuliC";
item1.email = "juliet@shakespeare.lit";
payload->addItem(item1);
SearchPayload::Item item2;
item2.jid = JID("tybalt@shakespeare.lit");
item2.first = "Tybalt";
item2.last = "Capulet";
item2.nick = "ty";
item2.email = "tybalt@shakespeare.lit";
payload->addItem(item2);
CPPUNIT_ASSERT_EQUAL(std::string(
"<query xmlns=\"jabber:iq:search\">"
"<item jid=\"juliet@capulet.com\">"
"<first>Juliet</first>"
"<last>Capulet</last>"
"<nick>JuliC</nick>"
"<email>juliet@shakespeare.lit</email>"
"</item>"
"<item jid=\"tybalt@shakespeare.lit\">"
"<first>Tybalt</first>"
"<last>Capulet</last>"
"<nick>ty</nick>"
"<email>tybalt@shakespeare.lit</email>"
"</item>"
"</query>"
), testling.serialize(payload));
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(SearchPayloadSerializerTest);
|