blob: 3f7cdc966a556edfc833f075121653b175599343 (
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
|
/*
* Copyright (c) 2014 Kevin Smith and 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/Elements/MAMFin.h>
#include <Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h>
using namespace Swift;
class MAMFinParserTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(MAMFinParserTest);
CPPUNIT_TEST(testParse_XEP0313_Exmaple1);
CPPUNIT_TEST(testParse_XEP0313_Exmaple9);
CPPUNIT_TEST_SUITE_END();
public:
void testParse_XEP0313_Exmaple1() {
PayloadsParserTester parser;
CPPUNIT_ASSERT(parser.parse(
"<fin xmlns='urn:xmpp:mam:0' queryid='f27' />"));
boost::shared_ptr<MAMFin> payload = parser.getPayload<MAMFin>();
CPPUNIT_ASSERT(!!payload);
CPPUNIT_ASSERT_EQUAL(false, payload->isComplete());
CPPUNIT_ASSERT_EQUAL(true, payload->isStable());
boost::optional<std::string> queryID = payload->getQueryID();
CPPUNIT_ASSERT(queryID);
CPPUNIT_ASSERT_EQUAL(std::string("f27"), queryID.get());
}
void testParse_XEP0313_Exmaple9() {
PayloadsParserTester parser;
CPPUNIT_ASSERT(parser.parse(
"<fin xmlns='urn:xmpp:mam:0' complete='true'>"
"<set xmlns='http://jabber.org/protocol/rsm'>"
"<first index='0'>23452-4534-1</first>"
"<last>390-2342-22</last>"
"<count>16</count>"
"</set>"
"</fin>"));
boost::shared_ptr<MAMFin> payload = parser.getPayload<MAMFin>();
CPPUNIT_ASSERT(!!payload);
CPPUNIT_ASSERT_EQUAL(true, payload->isComplete());
CPPUNIT_ASSERT_EQUAL(true, payload->isStable());
CPPUNIT_ASSERT(!!payload->getResultSet());
boost::shared_ptr<ResultSet> resultSet = payload->getResultSet();
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(MAMFinParserTest);
|