summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2012-12-04 13:01:36 (GMT)
committerKevin Smith <git@kismith.co.uk>2012-12-04 13:34:42 (GMT)
commita6f8c4e4579b93b3e004229dcdeb098bd5b356a4 (patch)
treeecf3908d57917505234c636e6836b0d4d31ce277 /Swiften/Parser/PayloadParsers/UnitTest
parent3b2a5153a79ec627113223222ed61190bcb3a7e3 (diff)
downloadswift-a6f8c4e4579b93b3e004229dcdeb098bd5b356a4.zip
swift-a6f8c4e4579b93b3e004229dcdeb098bd5b356a4.tar.bz2
Add parsing for disco#info nodes
Change-Id: Icf9a526183650add0b5b42243fb1c78757c960c7
Diffstat (limited to 'Swiften/Parser/PayloadParsers/UnitTest')
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/DiscoInfoParserTest.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/DiscoInfoParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/DiscoInfoParserTest.cpp
index bfbc312..d01abd1 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/DiscoInfoParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/DiscoInfoParserTest.cpp
@@ -15,6 +15,7 @@ using namespace Swift;
class DiscoInfoParserTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(DiscoInfoParserTest);
CPPUNIT_TEST(testParse);
+ CPPUNIT_TEST(testParse_Node);
CPPUNIT_TEST(testParse_Form);
CPPUNIT_TEST_SUITE_END();
@@ -45,6 +46,36 @@ class DiscoInfoParserTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT_EQUAL(std::string("foo-feature"), payload->getFeatures()[0]);
CPPUNIT_ASSERT_EQUAL(std::string("bar-feature"), payload->getFeatures()[1]);
CPPUNIT_ASSERT_EQUAL(std::string("baz-feature"), payload->getFeatures()[2]);
+ CPPUNIT_ASSERT(payload->getNode().empty());
+ }
+
+ void testParse_Node() {
+ PayloadsParserTester parser;
+
+ CPPUNIT_ASSERT(parser.parse(
+ "<query xmlns=\"http://jabber.org/protocol/disco#info\" node=\"blahblah\">"
+ "<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::ref payload = boost::dynamic_pointer_cast<DiscoInfo>(parser.getPayload());
+ CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(payload->getIdentities().size()));
+ CPPUNIT_ASSERT_EQUAL(std::string("Swift"), payload->getIdentities()[0].getName());
+ CPPUNIT_ASSERT_EQUAL(std::string("pc"), payload->getIdentities()[0].getType());
+ CPPUNIT_ASSERT_EQUAL(std::string("client"), payload->getIdentities()[0].getCategory());
+ CPPUNIT_ASSERT_EQUAL(std::string("en"), payload->getIdentities()[0].getLanguage());
+ CPPUNIT_ASSERT_EQUAL(std::string("Vlug"), payload->getIdentities()[1].getName());
+ CPPUNIT_ASSERT_EQUAL(std::string("pc"), payload->getIdentities()[1].getType());
+ CPPUNIT_ASSERT_EQUAL(std::string("client"), payload->getIdentities()[1].getCategory());
+ CPPUNIT_ASSERT_EQUAL(std::string("nl"), payload->getIdentities()[1].getLanguage());
+ CPPUNIT_ASSERT_EQUAL(3, static_cast<int>(payload->getFeatures().size()));
+ CPPUNIT_ASSERT_EQUAL(std::string("foo-feature"), payload->getFeatures()[0]);
+ CPPUNIT_ASSERT_EQUAL(std::string("bar-feature"), payload->getFeatures()[1]);
+ CPPUNIT_ASSERT_EQUAL(std::string("baz-feature"), payload->getFeatures()[2]);
+ CPPUNIT_ASSERT_EQUAL(std::string("blahblah"), payload->getNode());
}
void testParse_Form() {