blob: 2e7e7af8afc8b6c09b29a47eb2cfeaad634a141c (
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
|
/*
* 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/DiscoInfoParser.h"
#include "Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h"
using namespace Swift;
class DiscoInfoParserTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(DiscoInfoParserTest);
CPPUNIT_TEST(testParse);
CPPUNIT_TEST_SUITE_END();
public:
DiscoInfoParserTest() {}
void testParse() {
PayloadsParserTester parser;
CPPUNIT_ASSERT(parser.parse(
"<query xmlns=\"http://jabber.org/protocol/disco#info\">"
"<identity name=\"Swift\" category=\"client\" type=\"pc\" xml:lang=\"en\"/>"
"<identity name=\"Vlug\" category=\"client\" type=\"pc\" xml:lang=\"nl\"/>"
"<feature var=\"foo-feature\"/>"
"<feature var=\"bar-feature\"/>"
"<feature var=\"baz-feature\"/>"
"</query>"));
DiscoInfo* payload = dynamic_cast<DiscoInfo*>(parser.getPayload().get());
CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(payload->getIdentities().size()));
CPPUNIT_ASSERT_EQUAL(String("Swift"), payload->getIdentities()[0].getName());
CPPUNIT_ASSERT_EQUAL(String("pc"), payload->getIdentities()[0].getType());
CPPUNIT_ASSERT_EQUAL(String("client"), payload->getIdentities()[0].getCategory());
CPPUNIT_ASSERT_EQUAL(String("en"), payload->getIdentities()[0].getLanguage());
CPPUNIT_ASSERT_EQUAL(String("Vlug"), payload->getIdentities()[1].getName());
CPPUNIT_ASSERT_EQUAL(String("pc"), payload->getIdentities()[1].getType());
CPPUNIT_ASSERT_EQUAL(String("client"), payload->getIdentities()[1].getCategory());
CPPUNIT_ASSERT_EQUAL(String("nl"), payload->getIdentities()[1].getLanguage());
CPPUNIT_ASSERT_EQUAL(3, static_cast<int>(payload->getFeatures().size()));
CPPUNIT_ASSERT_EQUAL(String("foo-feature"), payload->getFeatures()[0]);
CPPUNIT_ASSERT_EQUAL(String("bar-feature"), payload->getFeatures()[1]);
CPPUNIT_ASSERT_EQUAL(String("baz-feature"), payload->getFeatures()[2]);
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(DiscoInfoParserTest);
|