summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2016-03-31 14:57:35 (GMT)
committerTobias Markmann <tm@ayena.de>2016-03-31 14:57:35 (GMT)
commitcfbdb43d2cadd40aa87338d41548e4bf89e146e6 (patch)
tree18d94153a302445196fc0c18586abf44a1ce4a38 /Swiften/Parser/UnitTest
parent1d545a4a7fb877f021508094b88c1f17b30d8b4e (diff)
downloadswift-cfbdb43d2cadd40aa87338d41548e4bf89e146e6.zip
swift-cfbdb43d2cadd40aa87338d41548e4bf89e146e6.tar.bz2
Convert tabs to 4 spaces for all source files
Removed trailing spaces and whitespace on empty lines in the process. Changed CheckTabs.py tool to disallow hard tabs in source files. Test-Information: Manually checked 30 random files that the conversion worked as expected. Change-Id: I874f99d617bd3d2bb55f02d58f22f58f9b094480
Diffstat (limited to 'Swiften/Parser/UnitTest')
-rw-r--r--Swiften/Parser/UnitTest/AttributeMapTest.cpp102
-rw-r--r--Swiften/Parser/UnitTest/BOSHBodyExtractorTest.cpp172
-rw-r--r--Swiften/Parser/UnitTest/ElementParserTester.h2
-rw-r--r--Swiften/Parser/UnitTest/EnumParserTest.cpp38
-rw-r--r--Swiften/Parser/UnitTest/GenericPayloadTreeParserTest.cpp76
-rw-r--r--Swiften/Parser/UnitTest/IQParserTest.cpp78
-rw-r--r--Swiften/Parser/UnitTest/MessageParserTest.cpp92
-rw-r--r--Swiften/Parser/UnitTest/ParserTester.h66
-rw-r--r--Swiften/Parser/UnitTest/PayloadParserFactoryCollectionTest.cpp168
-rw-r--r--Swiften/Parser/UnitTest/PresenceParserTest.cpp134
-rw-r--r--Swiften/Parser/UnitTest/SerializingParserTest.cpp74
-rw-r--r--Swiften/Parser/UnitTest/StanzaAckParserTest.cpp50
-rw-r--r--Swiften/Parser/UnitTest/StanzaParserTest.cpp380
-rw-r--r--Swiften/Parser/UnitTest/StanzaParserTester.h2
-rw-r--r--Swiften/Parser/UnitTest/StreamFeaturesParserTest.cpp180
-rw-r--r--Swiften/Parser/UnitTest/StreamManagementEnabledParserTest.cpp32
-rw-r--r--Swiften/Parser/UnitTest/XMLParserTest.cpp548
-rw-r--r--Swiften/Parser/UnitTest/XMPPParserTest.cpp324
18 files changed, 1259 insertions, 1259 deletions
diff --git a/Swiften/Parser/UnitTest/AttributeMapTest.cpp b/Swiften/Parser/UnitTest/AttributeMapTest.cpp
index 55fa964..4529eac 100644
--- a/Swiften/Parser/UnitTest/AttributeMapTest.cpp
+++ b/Swiften/Parser/UnitTest/AttributeMapTest.cpp
@@ -13,73 +13,73 @@ using namespace Swift;
class AttributeMapTest : public CppUnit::TestFixture
{
- CPPUNIT_TEST_SUITE(AttributeMapTest);
- CPPUNIT_TEST(testGetAttribute_Namespaced);
- CPPUNIT_TEST(testGetBoolAttribute_True);
- CPPUNIT_TEST(testGetBoolAttribute_1);
- CPPUNIT_TEST(testGetBoolAttribute_False);
- CPPUNIT_TEST(testGetBoolAttribute_0);
- CPPUNIT_TEST(testGetBoolAttribute_Invalid);
- CPPUNIT_TEST(testGetBoolAttribute_UnknownWithDefaultTrue);
- CPPUNIT_TEST(testGetBoolAttribute_UnknownWithDefaultFalse);
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE(AttributeMapTest);
+ CPPUNIT_TEST(testGetAttribute_Namespaced);
+ CPPUNIT_TEST(testGetBoolAttribute_True);
+ CPPUNIT_TEST(testGetBoolAttribute_1);
+ CPPUNIT_TEST(testGetBoolAttribute_False);
+ CPPUNIT_TEST(testGetBoolAttribute_0);
+ CPPUNIT_TEST(testGetBoolAttribute_Invalid);
+ CPPUNIT_TEST(testGetBoolAttribute_UnknownWithDefaultTrue);
+ CPPUNIT_TEST(testGetBoolAttribute_UnknownWithDefaultFalse);
+ CPPUNIT_TEST_SUITE_END();
- public:
- void testGetAttribute_Namespaced() {
- AttributeMap testling;
- testling.addAttribute("lang", "", "nl");
- testling.addAttribute("lang", "http://www.w3.org/XML/1998/namespace", "en");
- testling.addAttribute("lang", "", "fr");
+ public:
+ void testGetAttribute_Namespaced() {
+ AttributeMap testling;
+ testling.addAttribute("lang", "", "nl");
+ testling.addAttribute("lang", "http://www.w3.org/XML/1998/namespace", "en");
+ testling.addAttribute("lang", "", "fr");
- CPPUNIT_ASSERT_EQUAL(std::string("en"), testling.getAttribute("lang", "http://www.w3.org/XML/1998/namespace"));
- }
+ CPPUNIT_ASSERT_EQUAL(std::string("en"), testling.getAttribute("lang", "http://www.w3.org/XML/1998/namespace"));
+ }
- void testGetBoolAttribute_True() {
- AttributeMap testling;
- testling.addAttribute("foo", "", "true");
+ void testGetBoolAttribute_True() {
+ AttributeMap testling;
+ testling.addAttribute("foo", "", "true");
- CPPUNIT_ASSERT(testling.getBoolAttribute("foo"));
- }
+ CPPUNIT_ASSERT(testling.getBoolAttribute("foo"));
+ }
- void testGetBoolAttribute_1() {
- AttributeMap testling;
- testling.addAttribute("foo", "", "1");
+ void testGetBoolAttribute_1() {
+ AttributeMap testling;
+ testling.addAttribute("foo", "", "1");
- CPPUNIT_ASSERT(testling.getBoolAttribute("foo"));
- }
+ CPPUNIT_ASSERT(testling.getBoolAttribute("foo"));
+ }
- void testGetBoolAttribute_False() {
- AttributeMap testling;
- testling.addAttribute("foo", "", "false");
+ void testGetBoolAttribute_False() {
+ AttributeMap testling;
+ testling.addAttribute("foo", "", "false");
- CPPUNIT_ASSERT(!testling.getBoolAttribute("foo", true));
- }
+ CPPUNIT_ASSERT(!testling.getBoolAttribute("foo", true));
+ }
- void testGetBoolAttribute_0() {
- AttributeMap testling;
- testling.addAttribute("foo", "", "0");
+ void testGetBoolAttribute_0() {
+ AttributeMap testling;
+ testling.addAttribute("foo", "", "0");
- CPPUNIT_ASSERT(!testling.getBoolAttribute("foo", true));
- }
+ CPPUNIT_ASSERT(!testling.getBoolAttribute("foo", true));
+ }
- void testGetBoolAttribute_Invalid() {
- AttributeMap testling;
- testling.addAttribute("foo", "", "bla");
+ void testGetBoolAttribute_Invalid() {
+ AttributeMap testling;
+ testling.addAttribute("foo", "", "bla");
- CPPUNIT_ASSERT(!testling.getBoolAttribute("foo", true));
- }
+ CPPUNIT_ASSERT(!testling.getBoolAttribute("foo", true));
+ }
- void testGetBoolAttribute_UnknownWithDefaultTrue() {
- AttributeMap testling;
+ void testGetBoolAttribute_UnknownWithDefaultTrue() {
+ AttributeMap testling;
- CPPUNIT_ASSERT(testling.getBoolAttribute("foo", true));
- }
+ CPPUNIT_ASSERT(testling.getBoolAttribute("foo", true));
+ }
- void testGetBoolAttribute_UnknownWithDefaultFalse() {
- AttributeMap testling;
+ void testGetBoolAttribute_UnknownWithDefaultFalse() {
+ AttributeMap testling;
- CPPUNIT_ASSERT(!testling.getBoolAttribute("foo", false));
- }
+ CPPUNIT_ASSERT(!testling.getBoolAttribute("foo", false));
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(AttributeMapTest);
diff --git a/Swiften/Parser/UnitTest/BOSHBodyExtractorTest.cpp b/Swiften/Parser/UnitTest/BOSHBodyExtractorTest.cpp
index a72f5aa..f7ed80f 100644
--- a/Swiften/Parser/UnitTest/BOSHBodyExtractorTest.cpp
+++ b/Swiften/Parser/UnitTest/BOSHBodyExtractorTest.cpp
@@ -13,92 +13,92 @@
using namespace Swift;
class BOSHBodyExtractorTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(BOSHBodyExtractorTest);
- CPPUNIT_TEST(testGetBody);
- CPPUNIT_TEST(testGetBody_EmptyContent);
- CPPUNIT_TEST(testGetBody_EmptyContent2);
- CPPUNIT_TEST(testGetBody_EmptyElementEmptyContent);
- CPPUNIT_TEST(testGetBody_InvalidStartTag);
- CPPUNIT_TEST(testGetBody_InvalidStartTag2);
- CPPUNIT_TEST(testGetBody_IncompleteStartTag);
- CPPUNIT_TEST(testGetBody_InvalidEndTag);
- CPPUNIT_TEST(testGetBody_InvalidEndTag2);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- void testGetBody() {
- BOSHBodyExtractor testling(&parserFactory, createByteArray(
- "<body a1='a\"1' a2=\"a'2\" boo='bar' >"
- "foo <message> <body> bar"
- "</body > "));
-
- CPPUNIT_ASSERT(testling.getBody());
- CPPUNIT_ASSERT_EQUAL(std::string("a\"1"), testling.getBody()->attributes.getAttribute("a1"));
- CPPUNIT_ASSERT_EQUAL(std::string("foo <message> <body> bar"), testling.getBody()->content);
- }
-
- void testGetBody_EmptyContent() {
- BOSHBodyExtractor testling(&parserFactory, createByteArray(
- "<body foo='bar'/>"));
-
- CPPUNIT_ASSERT(testling.getBody());
- CPPUNIT_ASSERT_EQUAL(std::string("bar"), testling.getBody()->attributes.getAttribute("foo"));
- CPPUNIT_ASSERT(testling.getBody()->content.empty());
- }
-
- void testGetBody_EmptyContent2() {
- BOSHBodyExtractor testling(&parserFactory, createByteArray(
- "<body foo='bar'></body>"));
-
- CPPUNIT_ASSERT(testling.getBody());
- CPPUNIT_ASSERT_EQUAL(std::string("bar"), testling.getBody()->attributes.getAttribute("foo"));
- CPPUNIT_ASSERT(testling.getBody()->content.empty());
- }
-
- void testGetBody_EmptyElementEmptyContent() {
- BOSHBodyExtractor testling(&parserFactory, createByteArray(
- "<body/>"));
-
- CPPUNIT_ASSERT(testling.getBody());
- }
-
- void testGetBody_InvalidStartTag() {
- BOSHBodyExtractor testling(&parserFactory, createByteArray(
- "<bodi></body>"));
-
- CPPUNIT_ASSERT(!testling.getBody());
- }
-
- void testGetBody_InvalidStartTag2() {
- BOSHBodyExtractor testling(&parserFactory, createByteArray(
- "<bodyy></body>"));
-
- CPPUNIT_ASSERT(!testling.getBody());
- }
-
- void testGetBody_IncompleteStartTag() {
- BOSHBodyExtractor testling(&parserFactory, createByteArray(
- "<body"));
-
- CPPUNIT_ASSERT(!testling.getBody());
- }
-
- void testGetBody_InvalidEndTag() {
- BOSHBodyExtractor testling(&parserFactory, createByteArray(
- "<body></bodi>"));
-
- CPPUNIT_ASSERT(!testling.getBody());
- }
-
- void testGetBody_InvalidEndTag2() {
- BOSHBodyExtractor testling(&parserFactory, createByteArray(
- "<body><b/body>"));
-
- CPPUNIT_ASSERT(!testling.getBody());
- }
-
- private:
- PlatformXMLParserFactory parserFactory;
+ CPPUNIT_TEST_SUITE(BOSHBodyExtractorTest);
+ CPPUNIT_TEST(testGetBody);
+ CPPUNIT_TEST(testGetBody_EmptyContent);
+ CPPUNIT_TEST(testGetBody_EmptyContent2);
+ CPPUNIT_TEST(testGetBody_EmptyElementEmptyContent);
+ CPPUNIT_TEST(testGetBody_InvalidStartTag);
+ CPPUNIT_TEST(testGetBody_InvalidStartTag2);
+ CPPUNIT_TEST(testGetBody_IncompleteStartTag);
+ CPPUNIT_TEST(testGetBody_InvalidEndTag);
+ CPPUNIT_TEST(testGetBody_InvalidEndTag2);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void testGetBody() {
+ BOSHBodyExtractor testling(&parserFactory, createByteArray(
+ "<body a1='a\"1' a2=\"a'2\" boo='bar' >"
+ "foo <message> <body> bar"
+ "</body > "));
+
+ CPPUNIT_ASSERT(testling.getBody());
+ CPPUNIT_ASSERT_EQUAL(std::string("a\"1"), testling.getBody()->attributes.getAttribute("a1"));
+ CPPUNIT_ASSERT_EQUAL(std::string("foo <message> <body> bar"), testling.getBody()->content);
+ }
+
+ void testGetBody_EmptyContent() {
+ BOSHBodyExtractor testling(&parserFactory, createByteArray(
+ "<body foo='bar'/>"));
+
+ CPPUNIT_ASSERT(testling.getBody());
+ CPPUNIT_ASSERT_EQUAL(std::string("bar"), testling.getBody()->attributes.getAttribute("foo"));
+ CPPUNIT_ASSERT(testling.getBody()->content.empty());
+ }
+
+ void testGetBody_EmptyContent2() {
+ BOSHBodyExtractor testling(&parserFactory, createByteArray(
+ "<body foo='bar'></body>"));
+
+ CPPUNIT_ASSERT(testling.getBody());
+ CPPUNIT_ASSERT_EQUAL(std::string("bar"), testling.getBody()->attributes.getAttribute("foo"));
+ CPPUNIT_ASSERT(testling.getBody()->content.empty());
+ }
+
+ void testGetBody_EmptyElementEmptyContent() {
+ BOSHBodyExtractor testling(&parserFactory, createByteArray(
+ "<body/>"));
+
+ CPPUNIT_ASSERT(testling.getBody());
+ }
+
+ void testGetBody_InvalidStartTag() {
+ BOSHBodyExtractor testling(&parserFactory, createByteArray(
+ "<bodi></body>"));
+
+ CPPUNIT_ASSERT(!testling.getBody());
+ }
+
+ void testGetBody_InvalidStartTag2() {
+ BOSHBodyExtractor testling(&parserFactory, createByteArray(
+ "<bodyy></body>"));
+
+ CPPUNIT_ASSERT(!testling.getBody());
+ }
+
+ void testGetBody_IncompleteStartTag() {
+ BOSHBodyExtractor testling(&parserFactory, createByteArray(
+ "<body"));
+
+ CPPUNIT_ASSERT(!testling.getBody());
+ }
+
+ void testGetBody_InvalidEndTag() {
+ BOSHBodyExtractor testling(&parserFactory, createByteArray(
+ "<body></bodi>"));
+
+ CPPUNIT_ASSERT(!testling.getBody());
+ }
+
+ void testGetBody_InvalidEndTag2() {
+ BOSHBodyExtractor testling(&parserFactory, createByteArray(
+ "<body><b/body>"));
+
+ CPPUNIT_ASSERT(!testling.getBody());
+ }
+
+ private:
+ PlatformXMLParserFactory parserFactory;
};
CPPUNIT_TEST_SUITE_REGISTRATION(BOSHBodyExtractorTest);
diff --git a/Swiften/Parser/UnitTest/ElementParserTester.h b/Swiften/Parser/UnitTest/ElementParserTester.h
index 4ab44bd..299fb50 100644
--- a/Swiften/Parser/UnitTest/ElementParserTester.h
+++ b/Swiften/Parser/UnitTest/ElementParserTester.h
@@ -9,5 +9,5 @@
#include <Swiften/Parser/UnitTest/ParserTester.h>
namespace Swift {
- typedef ParserTester<ElementParser> ElementParserTester;
+ typedef ParserTester<ElementParser> ElementParserTester;
}
diff --git a/Swiften/Parser/UnitTest/EnumParserTest.cpp b/Swiften/Parser/UnitTest/EnumParserTest.cpp
index fcbf0e9..82b3fa1 100644
--- a/Swiften/Parser/UnitTest/EnumParserTest.cpp
+++ b/Swiften/Parser/UnitTest/EnumParserTest.cpp
@@ -12,25 +12,25 @@
using namespace Swift;
class EnumParserTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(EnumParserTest);
- CPPUNIT_TEST(testParse);
- CPPUNIT_TEST(testParse_NoValue);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- enum MyEnum {
- MyValue1,
- MyValue2,
- MyValue3
- };
-
- void testParse() {
- CPPUNIT_ASSERT(MyValue2 == EnumParser<MyEnum>()(MyValue1, "my-value-1")(MyValue2, "my-value-2")(MyValue3, "my-value-3").parse("my-value-2"));
- }
-
- void testParse_NoValue() {
- CPPUNIT_ASSERT(!EnumParser<MyEnum>()(MyValue1, "my-value-1")(MyValue2, "my-value-2")(MyValue3, "my-value-3").parse("my-value-4"));
- }
+ CPPUNIT_TEST_SUITE(EnumParserTest);
+ CPPUNIT_TEST(testParse);
+ CPPUNIT_TEST(testParse_NoValue);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ enum MyEnum {
+ MyValue1,
+ MyValue2,
+ MyValue3
+ };
+
+ void testParse() {
+ CPPUNIT_ASSERT(MyValue2 == EnumParser<MyEnum>()(MyValue1, "my-value-1")(MyValue2, "my-value-2")(MyValue3, "my-value-3").parse("my-value-2"));
+ }
+
+ void testParse_NoValue() {
+ CPPUNIT_ASSERT(!EnumParser<MyEnum>()(MyValue1, "my-value-1")(MyValue2, "my-value-2")(MyValue3, "my-value-3").parse("my-value-4"));
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(EnumParserTest);
diff --git a/Swiften/Parser/UnitTest/GenericPayloadTreeParserTest.cpp b/Swiften/Parser/UnitTest/GenericPayloadTreeParserTest.cpp
index 5413e46..cd94ed8 100644
--- a/Swiften/Parser/UnitTest/GenericPayloadTreeParserTest.cpp
+++ b/Swiften/Parser/UnitTest/GenericPayloadTreeParserTest.cpp
@@ -22,44 +22,44 @@ template class __declspec(dllimport) Swift::GenericPayloadParser<RawXMLPayload>;
#endif
class GenericPayloadTreeParserTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(GenericPayloadTreeParserTest);
- CPPUNIT_TEST(testTree);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- void testTree() {
- MyParser testling;
-
- std::string data = "<topLevel xmlns='urn:test:top'><firstLevelInheritedEmpty/><firstLevelInherited><secondLevelMultiChildren num='1'/><secondLevelMultiChildren num='2'/></firstLevelInherited><firstLevelNS xmlns='urn:test:first'/></topLevel>";
-
- PayloadParserTester tester(&testling);
- tester.parse(data);
-
- ParserElement::ref tree = testling.tree;
-
- CPPUNIT_ASSERT_EQUAL(std::string("topLevel"), tree->getName());
- CPPUNIT_ASSERT_EQUAL(std::string("urn:test:top"), tree->getNamespace());
- CPPUNIT_ASSERT(tree->getChild("firstLevelInheritedEmpty", "urn:test:top"));
- CPPUNIT_ASSERT(!*tree->getChild("firstLevelInheritedEmpty", ""));
- CPPUNIT_ASSERT(tree->getChild("firstLevelInherited", "urn:test:top"));
- CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), tree->getChild("firstLevelInherited", "urn:test:top")->getChildren("secondLevelMultiChildren", "urn:test:top").size());
- CPPUNIT_ASSERT_EQUAL(std::string("1"), tree->getChild("firstLevelInherited", "urn:test:top")->getChildren("secondLevelMultiChildren", "urn:test:top")[0]->getAttributes().getAttribute("num"));
- CPPUNIT_ASSERT_EQUAL(std::string("2"), tree->getChild("firstLevelInherited", "urn:test:top")->getChildren("secondLevelMultiChildren", "urn:test:top")[1]->getAttributes().getAttribute("num"));
- CPPUNIT_ASSERT(tree->getChild("firstLevelNS", "urn:test:first"));
- }
-
- private:
-
-
- class MyParser : public GenericPayloadTreeParser<RawXMLPayload>
- {
- public:
- virtual ~MyParser() {}
- virtual void handleTree(ParserElement::ref root) {
- tree = root;
- }
- ParserElement::ref tree;
- };
+ CPPUNIT_TEST_SUITE(GenericPayloadTreeParserTest);
+ CPPUNIT_TEST(testTree);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void testTree() {
+ MyParser testling;
+
+ std::string data = "<topLevel xmlns='urn:test:top'><firstLevelInheritedEmpty/><firstLevelInherited><secondLevelMultiChildren num='1'/><secondLevelMultiChildren num='2'/></firstLevelInherited><firstLevelNS xmlns='urn:test:first'/></topLevel>";
+
+ PayloadParserTester tester(&testling);
+ tester.parse(data);
+
+ ParserElement::ref tree = testling.tree;
+
+ CPPUNIT_ASSERT_EQUAL(std::string("topLevel"), tree->getName());
+ CPPUNIT_ASSERT_EQUAL(std::string("urn:test:top"), tree->getNamespace());
+ CPPUNIT_ASSERT(tree->getChild("firstLevelInheritedEmpty", "urn:test:top"));
+ CPPUNIT_ASSERT(!*tree->getChild("firstLevelInheritedEmpty", ""));
+ CPPUNIT_ASSERT(tree->getChild("firstLevelInherited", "urn:test:top"));
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), tree->getChild("firstLevelInherited", "urn:test:top")->getChildren("secondLevelMultiChildren", "urn:test:top").size());
+ CPPUNIT_ASSERT_EQUAL(std::string("1"), tree->getChild("firstLevelInherited", "urn:test:top")->getChildren("secondLevelMultiChildren", "urn:test:top")[0]->getAttributes().getAttribute("num"));
+ CPPUNIT_ASSERT_EQUAL(std::string("2"), tree->getChild("firstLevelInherited", "urn:test:top")->getChildren("secondLevelMultiChildren", "urn:test:top")[1]->getAttributes().getAttribute("num"));
+ CPPUNIT_ASSERT(tree->getChild("firstLevelNS", "urn:test:first"));
+ }
+
+ private:
+
+
+ class MyParser : public GenericPayloadTreeParser<RawXMLPayload>
+ {
+ public:
+ virtual ~MyParser() {}
+ virtual void handleTree(ParserElement::ref root) {
+ tree = root;
+ }
+ ParserElement::ref tree;
+ };
};
diff --git a/Swiften/Parser/UnitTest/IQParserTest.cpp b/Swiften/Parser/UnitTest/IQParserTest.cpp
index 95e2d51..5c07757 100644
--- a/Swiften/Parser/UnitTest/IQParserTest.cpp
+++ b/Swiften/Parser/UnitTest/IQParserTest.cpp
@@ -14,60 +14,60 @@
using namespace Swift;
class IQParserTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(IQParserTest);
- CPPUNIT_TEST(testParse_Set);
- CPPUNIT_TEST(testParse_Get);
- CPPUNIT_TEST(testParse_Result);
- CPPUNIT_TEST(testParse_Error);
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE(IQParserTest);
+ CPPUNIT_TEST(testParse_Set);
+ CPPUNIT_TEST(testParse_Get);
+ CPPUNIT_TEST(testParse_Result);
+ CPPUNIT_TEST(testParse_Error);
+ CPPUNIT_TEST_SUITE_END();
- public:
- void setUp() {
- factoryCollection_ = new PayloadParserFactoryCollection();
- }
+ public:
+ void setUp() {
+ factoryCollection_ = new PayloadParserFactoryCollection();
+ }
- void tearDown() {
- delete factoryCollection_;
- }
+ void tearDown() {
+ delete factoryCollection_;
+ }
- void testParse_Set() {
- IQParser testling(factoryCollection_);
- StanzaParserTester parser(&testling);
+ void testParse_Set() {
+ IQParser testling(factoryCollection_);
+ StanzaParserTester parser(&testling);
- CPPUNIT_ASSERT(parser.parse("<iq type=\"set\"/>"));
+ CPPUNIT_ASSERT(parser.parse("<iq type=\"set\"/>"));
- CPPUNIT_ASSERT_EQUAL(IQ::Set, testling.getStanzaGeneric()->getType());
- }
+ CPPUNIT_ASSERT_EQUAL(IQ::Set, testling.getStanzaGeneric()->getType());
+ }
- void testParse_Get() {
- IQParser testling(factoryCollection_);
- StanzaParserTester parser(&testling);
+ void testParse_Get() {
+ IQParser testling(factoryCollection_);
+ StanzaParserTester parser(&testling);
- CPPUNIT_ASSERT(parser.parse("<iq type=\"get\"/>"));
+ CPPUNIT_ASSERT(parser.parse("<iq type=\"get\"/>"));
- CPPUNIT_ASSERT_EQUAL(IQ::Get, testling.getStanzaGeneric()->getType());
- }
+ CPPUNIT_ASSERT_EQUAL(IQ::Get, testling.getStanzaGeneric()->getType());
+ }
- void testParse_Result() {
- IQParser testling(factoryCollection_);
- StanzaParserTester parser(&testling);
+ void testParse_Result() {
+ IQParser testling(factoryCollection_);
+ StanzaParserTester parser(&testling);
- CPPUNIT_ASSERT(parser.parse("<iq type=\"result\"/>"));
+ CPPUNIT_ASSERT(parser.parse("<iq type=\"result\"/>"));
- CPPUNIT_ASSERT_EQUAL(IQ::Result, testling.getStanzaGeneric()->getType());
- }
+ CPPUNIT_ASSERT_EQUAL(IQ::Result, testling.getStanzaGeneric()->getType());
+ }
- void testParse_Error() {
- IQParser testling(factoryCollection_);
- StanzaParserTester parser(&testling);
+ void testParse_Error() {
+ IQParser testling(factoryCollection_);
+ StanzaParserTester parser(&testling);
- CPPUNIT_ASSERT(parser.parse("<iq type=\"error\"/>"));
+ CPPUNIT_ASSERT(parser.parse("<iq type=\"error\"/>"));
- CPPUNIT_ASSERT_EQUAL(IQ::Error, testling.getStanzaGeneric()->getType());
- }
+ CPPUNIT_ASSERT_EQUAL(IQ::Error, testling.getStanzaGeneric()->getType());
+ }
- private:
- PayloadParserFactoryCollection* factoryCollection_;
+ private:
+ PayloadParserFactoryCollection* factoryCollection_;
};
CPPUNIT_TEST_SUITE_REGISTRATION(IQParserTest);
diff --git a/Swiften/Parser/UnitTest/MessageParserTest.cpp b/Swiften/Parser/UnitTest/MessageParserTest.cpp
index 19dafc3..dc55711 100644
--- a/Swiften/Parser/UnitTest/MessageParserTest.cpp
+++ b/Swiften/Parser/UnitTest/MessageParserTest.cpp
@@ -14,70 +14,70 @@
using namespace Swift;
class MessageParserTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(MessageParserTest);
- CPPUNIT_TEST(testParse_Normal);
- CPPUNIT_TEST(testParse_Chat);
- CPPUNIT_TEST(testParse_Error);
- CPPUNIT_TEST(testParse_Groupchat);
- CPPUNIT_TEST(testParse_Headline);
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE(MessageParserTest);
+ CPPUNIT_TEST(testParse_Normal);
+ CPPUNIT_TEST(testParse_Chat);
+ CPPUNIT_TEST(testParse_Error);
+ CPPUNIT_TEST(testParse_Groupchat);
+ CPPUNIT_TEST(testParse_Headline);
+ CPPUNIT_TEST_SUITE_END();
- public:
- void setUp() {
- factoryCollection_ = new PayloadParserFactoryCollection();
- }
+ public:
+ void setUp() {
+ factoryCollection_ = new PayloadParserFactoryCollection();
+ }
- void tearDown() {
- delete factoryCollection_;
- }
+ void tearDown() {
+ delete factoryCollection_;
+ }
- void testParse_Chat() {
- MessageParser testling(factoryCollection_);
- StanzaParserTester parser(&testling);
+ void testParse_Chat() {
+ MessageParser testling(factoryCollection_);
+ StanzaParserTester parser(&testling);
- CPPUNIT_ASSERT(parser.parse("<message type=\"chat\"/>"));
+ CPPUNIT_ASSERT(parser.parse("<message type=\"chat\"/>"));
- CPPUNIT_ASSERT_EQUAL(Message::Chat, testling.getStanzaGeneric()->getType());
- }
+ CPPUNIT_ASSERT_EQUAL(Message::Chat, testling.getStanzaGeneric()->getType());
+ }
- void testParse_Groupchat() {
- MessageParser testling(factoryCollection_);
- StanzaParserTester parser(&testling);
+ void testParse_Groupchat() {
+ MessageParser testling(factoryCollection_);
+ StanzaParserTester parser(&testling);
- CPPUNIT_ASSERT(parser.parse("<message type=\"groupchat\"/>"));
+ CPPUNIT_ASSERT(parser.parse("<message type=\"groupchat\"/>"));
- CPPUNIT_ASSERT_EQUAL(Message::Groupchat, testling.getStanzaGeneric()->getType());
- }
+ CPPUNIT_ASSERT_EQUAL(Message::Groupchat, testling.getStanzaGeneric()->getType());
+ }
- void testParse_Error() {
- MessageParser testling(factoryCollection_);
- StanzaParserTester parser(&testling);
+ void testParse_Error() {
+ MessageParser testling(factoryCollection_);
+ StanzaParserTester parser(&testling);
- CPPUNIT_ASSERT(parser.parse("<message type=\"error\"/>"));
+ CPPUNIT_ASSERT(parser.parse("<message type=\"error\"/>"));
- CPPUNIT_ASSERT_EQUAL(Message::Error, testling.getStanzaGeneric()->getType());
- }
+ CPPUNIT_ASSERT_EQUAL(Message::Error, testling.getStanzaGeneric()->getType());
+ }
- void testParse_Headline() {
- MessageParser testling(factoryCollection_);
- StanzaParserTester parser(&testling);
+ void testParse_Headline() {
+ MessageParser testling(factoryCollection_);
+ StanzaParserTester parser(&testling);
- CPPUNIT_ASSERT(parser.parse("<message type=\"headline\"/>"));
+ CPPUNIT_ASSERT(parser.parse("<message type=\"headline\"/>"));
- CPPUNIT_ASSERT_EQUAL(Message::Headline, testling.getStanzaGeneric()->getType());
- }
+ CPPUNIT_ASSERT_EQUAL(Message::Headline, testling.getStanzaGeneric()->getType());
+ }
- void testParse_Normal() {
- MessageParser testling(factoryCollection_);
- StanzaParserTester parser(&testling);
+ void testParse_Normal() {
+ MessageParser testling(factoryCollection_);
+ StanzaParserTester parser(&testling);
- CPPUNIT_ASSERT(parser.parse("<message/>"));
+ CPPUNIT_ASSERT(parser.parse("<message/>"));
- CPPUNIT_ASSERT_EQUAL(Message::Normal, testling.getStanzaGeneric()->getType());
- }
+ CPPUNIT_ASSERT_EQUAL(Message::Normal, testling.getStanzaGeneric()->getType());
+ }
- private:
- PayloadParserFactoryCollection* factoryCollection_;
+ private:
+ PayloadParserFactoryCollection* factoryCollection_;
};
CPPUNIT_TEST_SUITE_REGISTRATION(MessageParserTest);
diff --git a/Swiften/Parser/UnitTest/ParserTester.h b/Swiften/Parser/UnitTest/ParserTester.h
index b843c29..a98eb51 100644
--- a/Swiften/Parser/UnitTest/ParserTester.h
+++ b/Swiften/Parser/UnitTest/ParserTester.h
@@ -11,37 +11,37 @@
#include <Swiften/Parser/XMLParserClient.h>
namespace Swift {
- class XMLParser;
-
- template<typename ParserType>
- class ParserTester : public XMLParserClient {
- public:
- ParserTester(ParserType* parser) : parser_(parser) {
- xmlParser_ = PlatformXMLParserFactory().createXMLParser(this);
- }
-
- ~ParserTester() {
- delete xmlParser_;
- }
-
- bool parse(const std::string& data) {
- return xmlParser_->parse(data);
- }
-
- virtual void handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) {
- parser_->handleStartElement(element, ns, attributes);
- }
-
- virtual void handleEndElement(const std::string& element, const std::string& ns) {
- parser_->handleEndElement(element, ns);
- }
-
- virtual void handleCharacterData(const std::string& data) {
- parser_->handleCharacterData(data);
- }
-
- private:
- XMLParser* xmlParser_;
- ParserType* parser_;
- };
+ class XMLParser;
+
+ template<typename ParserType>
+ class ParserTester : public XMLParserClient {
+ public:
+ ParserTester(ParserType* parser) : parser_(parser) {
+ xmlParser_ = PlatformXMLParserFactory().createXMLParser(this);
+ }
+
+ ~ParserTester() {
+ delete xmlParser_;
+ }
+
+ bool parse(const std::string& data) {
+ return xmlParser_->parse(data);
+ }
+
+ virtual void handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) {
+ parser_->handleStartElement(element, ns, attributes);
+ }
+
+ virtual void handleEndElement(const std::string& element, const std::string& ns) {
+ parser_->handleEndElement(element, ns);
+ }
+
+ virtual void handleCharacterData(const std::string& data) {
+ parser_->handleCharacterData(data);
+ }
+
+ private:
+ XMLParser* xmlParser_;
+ ParserType* parser_;
+ };
}
diff --git a/Swiften/Parser/UnitTest/PayloadParserFactoryCollectionTest.cpp b/Swiften/Parser/UnitTest/PayloadParserFactoryCollectionTest.cpp
index cb01d6f..b2279f8 100644
--- a/Swiften/Parser/UnitTest/PayloadParserFactoryCollectionTest.cpp
+++ b/Swiften/Parser/UnitTest/PayloadParserFactoryCollectionTest.cpp
@@ -14,90 +14,90 @@ using namespace Swift;
class PayloadParserFactoryCollectionTest : public CppUnit::TestFixture
{
- CPPUNIT_TEST_SUITE(PayloadParserFactoryCollectionTest);
- CPPUNIT_TEST(testGetPayloadParserFactory);
- CPPUNIT_TEST(testGetPayloadParserFactory_NoMatchingFactory);
- CPPUNIT_TEST(testGetPayloadParserFactory_TwoMatchingFactories);
- CPPUNIT_TEST(testGetPayloadParserFactory_MatchWithDefaultFactory);
- CPPUNIT_TEST(testGetPayloadParserFactory_NoMatchWithDefaultFactory);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- PayloadParserFactoryCollectionTest() {}
-
- void setUp() {
- }
-
- void tearDown() {
- }
-
- void testGetPayloadParserFactory() {
- PayloadParserFactoryCollection testling;
- DummyFactory factory1("foo");
- testling.addFactory(&factory1);
- DummyFactory factory2("bar");
- testling.addFactory(&factory2);
- DummyFactory factory3("baz");
- testling.addFactory(&factory3);
-
- PayloadParserFactory* factory = testling.getPayloadParserFactory("bar", "", AttributeMap());
-
- CPPUNIT_ASSERT(factory == &factory2);
- }
-
- void testGetPayloadParserFactory_NoMatchingFactory() {
- PayloadParserFactoryCollection testling;
- DummyFactory factory("foo");
-
- CPPUNIT_ASSERT(!testling.getPayloadParserFactory("bar", "", AttributeMap()));
- }
-
- void testGetPayloadParserFactory_TwoMatchingFactories() {
- PayloadParserFactoryCollection testling;
- DummyFactory factory1("foo");
- testling.addFactory(&factory1);
- DummyFactory factory2("foo");
- testling.addFactory(&factory2);
-
- PayloadParserFactory* factory = testling.getPayloadParserFactory("foo", "", AttributeMap());
-
- CPPUNIT_ASSERT(factory == &factory2);
- }
-
- void testGetPayloadParserFactory_MatchWithDefaultFactory() {
- PayloadParserFactoryCollection testling;
- DummyFactory factory1("foo");
- testling.addFactory(&factory1);
- DummyFactory factory2;
- testling.setDefaultFactory(&factory2);
-
- PayloadParserFactory* factory = testling.getPayloadParserFactory("foo", "", AttributeMap());
-
- CPPUNIT_ASSERT(factory == &factory1);
- }
-
- void testGetPayloadParserFactory_NoMatchWithDefaultFactory() {
- PayloadParserFactoryCollection testling;
- DummyFactory factory1("foo");
- testling.addFactory(&factory1);
- DummyFactory factory2;
- testling.setDefaultFactory(&factory2);
-
- PayloadParserFactory* factory = testling.getPayloadParserFactory("baz", "", AttributeMap());
-
- CPPUNIT_ASSERT(factory == &factory2);
- }
-
-
- private:
- struct DummyFactory : public PayloadParserFactory {
- DummyFactory(const std::string& element = "") : element(element) {}
- virtual bool canParse(const std::string& e, const std::string&, const AttributeMap&) const {
- return element.empty() ? true : element == e;
- }
- virtual PayloadParser* createPayloadParser() { return NULL; }
- std::string element;
- };
+ CPPUNIT_TEST_SUITE(PayloadParserFactoryCollectionTest);
+ CPPUNIT_TEST(testGetPayloadParserFactory);
+ CPPUNIT_TEST(testGetPayloadParserFactory_NoMatchingFactory);
+ CPPUNIT_TEST(testGetPayloadParserFactory_TwoMatchingFactories);
+ CPPUNIT_TEST(testGetPayloadParserFactory_MatchWithDefaultFactory);
+ CPPUNIT_TEST(testGetPayloadParserFactory_NoMatchWithDefaultFactory);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ PayloadParserFactoryCollectionTest() {}
+
+ void setUp() {
+ }
+
+ void tearDown() {
+ }
+
+ void testGetPayloadParserFactory() {
+ PayloadParserFactoryCollection testling;
+ DummyFactory factory1("foo");
+ testling.addFactory(&factory1);
+ DummyFactory factory2("bar");
+ testling.addFactory(&factory2);
+ DummyFactory factory3("baz");
+ testling.addFactory(&factory3);
+
+ PayloadParserFactory* factory = testling.getPayloadParserFactory("bar", "", AttributeMap());
+
+ CPPUNIT_ASSERT(factory == &factory2);
+ }
+
+ void testGetPayloadParserFactory_NoMatchingFactory() {
+ PayloadParserFactoryCollection testling;
+ DummyFactory factory("foo");
+
+ CPPUNIT_ASSERT(!testling.getPayloadParserFactory("bar", "", AttributeMap()));
+ }
+
+ void testGetPayloadParserFactory_TwoMatchingFactories() {
+ PayloadParserFactoryCollection testling;
+ DummyFactory factory1("foo");
+ testling.addFactory(&factory1);
+ DummyFactory factory2("foo");
+ testling.addFactory(&factory2);
+
+ PayloadParserFactory* factory = testling.getPayloadParserFactory("foo", "", AttributeMap());
+
+ CPPUNIT_ASSERT(factory == &factory2);
+ }
+
+ void testGetPayloadParserFactory_MatchWithDefaultFactory() {
+ PayloadParserFactoryCollection testling;
+ DummyFactory factory1("foo");
+ testling.addFactory(&factory1);
+ DummyFactory factory2;
+ testling.setDefaultFactory(&factory2);
+
+ PayloadParserFactory* factory = testling.getPayloadParserFactory("foo", "", AttributeMap());
+
+ CPPUNIT_ASSERT(factory == &factory1);
+ }
+
+ void testGetPayloadParserFactory_NoMatchWithDefaultFactory() {
+ PayloadParserFactoryCollection testling;
+ DummyFactory factory1("foo");
+ testling.addFactory(&factory1);
+ DummyFactory factory2;
+ testling.setDefaultFactory(&factory2);
+
+ PayloadParserFactory* factory = testling.getPayloadParserFactory("baz", "", AttributeMap());
+
+ CPPUNIT_ASSERT(factory == &factory2);
+ }
+
+
+ private:
+ struct DummyFactory : public PayloadParserFactory {
+ DummyFactory(const std::string& element = "") : element(element) {}
+ virtual bool canParse(const std::string& e, const std::string&, const AttributeMap&) const {
+ return element.empty() ? true : element == e;
+ }
+ virtual PayloadParser* createPayloadParser() { return NULL; }
+ std::string element;
+ };
};
CPPUNIT_TEST_SUITE_REGISTRATION(PayloadParserFactoryCollectionTest);
diff --git a/Swiften/Parser/UnitTest/PresenceParserTest.cpp b/Swiften/Parser/UnitTest/PresenceParserTest.cpp
index 6dfbefd..2b2c242 100644
--- a/Swiften/Parser/UnitTest/PresenceParserTest.cpp
+++ b/Swiften/Parser/UnitTest/PresenceParserTest.cpp
@@ -14,100 +14,100 @@
using namespace Swift;
class PresenceParserTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(PresenceParserTest);
- CPPUNIT_TEST(testParse_Available);
- CPPUNIT_TEST(testParse_Unavailable);
- CPPUNIT_TEST(testParse_Subscribe);
- CPPUNIT_TEST(testParse_Subscribed);
- CPPUNIT_TEST(testParse_Unsubscribe);
- CPPUNIT_TEST(testParse_Unsubscribed);
- CPPUNIT_TEST(testParse_Probe);
- CPPUNIT_TEST(testParse_Error);
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE(PresenceParserTest);
+ CPPUNIT_TEST(testParse_Available);
+ CPPUNIT_TEST(testParse_Unavailable);
+ CPPUNIT_TEST(testParse_Subscribe);
+ CPPUNIT_TEST(testParse_Subscribed);
+ CPPUNIT_TEST(testParse_Unsubscribe);
+ CPPUNIT_TEST(testParse_Unsubscribed);
+ CPPUNIT_TEST(testParse_Probe);
+ CPPUNIT_TEST(testParse_Error);
+ CPPUNIT_TEST_SUITE_END();
- public:
- void setUp() {
- factoryCollection_ = new PayloadParserFactoryCollection();
- }
+ public:
+ void setUp() {
+ factoryCollection_ = new PayloadParserFactoryCollection();
+ }
- void tearDown() {
- delete factoryCollection_;
- }
+ void tearDown() {
+ delete factoryCollection_;
+ }
- void testParse_Available() {
- PresenceParser testling(factoryCollection_);
- StanzaParserTester parser(&testling);
+ void testParse_Available() {
+ PresenceParser testling(factoryCollection_);
+ StanzaParserTester parser(&testling);
- CPPUNIT_ASSERT(parser.parse("<presence/>"));
+ CPPUNIT_ASSERT(parser.parse("<presence/>"));
- CPPUNIT_ASSERT_EQUAL(Presence::Available, testling.getStanzaGeneric()->getType());
- }
+ CPPUNIT_ASSERT_EQUAL(Presence::Available, testling.getStanzaGeneric()->getType());
+ }
- void testParse_Unavailable() {
- PresenceParser testling(factoryCollection_);
- StanzaParserTester parser(&testling);
+ void testParse_Unavailable() {
+ PresenceParser testling(factoryCollection_);
+ StanzaParserTester parser(&testling);
- CPPUNIT_ASSERT(parser.parse("<presence type=\"unavailable\"/>"));
+ CPPUNIT_ASSERT(parser.parse("<presence type=\"unavailable\"/>"));
- CPPUNIT_ASSERT_EQUAL(Presence::Unavailable, testling.getStanzaGeneric()->getType());
- }
+ CPPUNIT_ASSERT_EQUAL(Presence::Unavailable, testling.getStanzaGeneric()->getType());
+ }
- void testParse_Probe() {
- PresenceParser testling(factoryCollection_);
- StanzaParserTester parser(&testling);
+ void testParse_Probe() {
+ PresenceParser testling(factoryCollection_);
+ StanzaParserTester parser(&testling);
- CPPUNIT_ASSERT(parser.parse("<presence type=\"probe\"/>"));
+ CPPUNIT_ASSERT(parser.parse("<presence type=\"probe\"/>"));
- CPPUNIT_ASSERT_EQUAL(Presence::Probe, testling.getStanzaGeneric()->getType());
- }
+ CPPUNIT_ASSERT_EQUAL(Presence::Probe, testling.getStanzaGeneric()->getType());
+ }
- void testParse_Subscribe() {
- PresenceParser testling(factoryCollection_);
- StanzaParserTester parser(&testling);
+ void testParse_Subscribe() {
+ PresenceParser testling(factoryCollection_);
+ StanzaParserTester parser(&testling);
- CPPUNIT_ASSERT(parser.parse("<presence type=\"subscribe\"/>"));
+ CPPUNIT_ASSERT(parser.parse("<presence type=\"subscribe\"/>"));
- CPPUNIT_ASSERT_EQUAL(Presence::Subscribe, testling.getStanzaGeneric()->getType());
- }
+ CPPUNIT_ASSERT_EQUAL(Presence::Subscribe, testling.getStanzaGeneric()->getType());
+ }
- void testParse_Subscribed() {
- PresenceParser testling(factoryCollection_);
- StanzaParserTester parser(&testling);
+ void testParse_Subscribed() {
+ PresenceParser testling(factoryCollection_);
+ StanzaParserTester parser(&testling);
- CPPUNIT_ASSERT(parser.parse("<presence type=\"subscribed\"/>"));
+ CPPUNIT_ASSERT(parser.parse("<presence type=\"subscribed\"/>"));
- CPPUNIT_ASSERT_EQUAL(Presence::Subscribed, testling.getStanzaGeneric()->getType());
- }
+ CPPUNIT_ASSERT_EQUAL(Presence::Subscribed, testling.getStanzaGeneric()->getType());
+ }
- void testParse_Unsubscribe() {
- PresenceParser testling(factoryCollection_);
- StanzaParserTester parser(&testling);
+ void testParse_Unsubscribe() {
+ PresenceParser testling(factoryCollection_);
+ StanzaParserTester parser(&testling);
- CPPUNIT_ASSERT(parser.parse("<presence type=\"unsubscribe\"/>"));
+ CPPUNIT_ASSERT(parser.parse("<presence type=\"unsubscribe\"/>"));
- CPPUNIT_ASSERT_EQUAL(Presence::Unsubscribe, testling.getStanzaGeneric()->getType());
- }
+ CPPUNIT_ASSERT_EQUAL(Presence::Unsubscribe, testling.getStanzaGeneric()->getType());
+ }
- void testParse_Unsubscribed() {
- PresenceParser testling(factoryCollection_);
- StanzaParserTester parser(&testling);
+ void testParse_Unsubscribed() {
+ PresenceParser testling(factoryCollection_);
+ StanzaParserTester parser(&testling);
- CPPUNIT_ASSERT(parser.parse("<presence type=\"unsubscribed\"/>"));
+ CPPUNIT_ASSERT(parser.parse("<presence type=\"unsubscribed\"/>"));
- CPPUNIT_ASSERT_EQUAL(Presence::Unsubscribed, testling.getStanzaGeneric()->getType());
- }
+ CPPUNIT_ASSERT_EQUAL(Presence::Unsubscribed, testling.getStanzaGeneric()->getType());
+ }
- void testParse_Error() {
- PresenceParser testling(factoryCollection_);
- StanzaParserTester parser(&testling);
+ void testParse_Error() {
+ PresenceParser testling(factoryCollection_);
+ StanzaParserTester parser(&testling);
- CPPUNIT_ASSERT(parser.parse("<presence type=\"error\"/>"));
+ CPPUNIT_ASSERT(parser.parse("<presence type=\"error\"/>"));
- CPPUNIT_ASSERT_EQUAL(Presence::Error, testling.getStanzaGeneric()->getType());
- }
+ CPPUNIT_ASSERT_EQUAL(Presence::Error, testling.getStanzaGeneric()->getType());
+ }
- private:
- PayloadParserFactoryCollection* factoryCollection_;
+ private:
+ PayloadParserFactoryCollection* factoryCollection_;
};
CPPUNIT_TEST_SUITE_REGISTRATION(PresenceParserTest);
diff --git a/Swiften/Parser/UnitTest/SerializingParserTest.cpp b/Swiften/Parser/UnitTest/SerializingParserTest.cpp
index 67567ee..1b4eb57 100644
--- a/Swiften/Parser/UnitTest/SerializingParserTest.cpp
+++ b/Swiften/Parser/UnitTest/SerializingParserTest.cpp
@@ -14,51 +14,51 @@ using namespace Swift;
class SerializingParserTest : public CppUnit::TestFixture
{
- CPPUNIT_TEST_SUITE(SerializingParserTest);
- CPPUNIT_TEST(testParse);
- CPPUNIT_TEST(testParse_Empty);
- CPPUNIT_TEST(testParse_ToplevelCharacterData);
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE(SerializingParserTest);
+ CPPUNIT_TEST(testParse);
+ CPPUNIT_TEST(testParse_Empty);
+ CPPUNIT_TEST(testParse_ToplevelCharacterData);
+ CPPUNIT_TEST_SUITE_END();
- public:
- SerializingParserTest() {}
+ public:
+ SerializingParserTest() {}
- void testParse() {
- SerializingParser testling;
- ParserTester<SerializingParser> parser(&testling);
+ void testParse() {
+ SerializingParser testling;
+ ParserTester<SerializingParser> parser(&testling);
- CPPUNIT_ASSERT(parser.parse(
- "<message type=\"chat\" to=\"me@foo.com\">"
- "<body>Hello&lt;&amp;World</body>"
- "<html xmlns=\"http://www.w3.org/1999/xhtml\">"
- "foo<b>bar</b>baz"
- "</html>"
- "</message>"));
+ CPPUNIT_ASSERT(parser.parse(
+ "<message type=\"chat\" to=\"me@foo.com\">"
+ "<body>Hello&lt;&amp;World</body>"
+ "<html xmlns=\"http://www.w3.org/1999/xhtml\">"
+ "foo<b>bar</b>baz"
+ "</html>"
+ "</message>"));
- CPPUNIT_ASSERT_EQUAL(std::string(
- "<message to=\"me@foo.com\" type=\"chat\">"
- "<body>Hello&lt;&amp;World</body>"
- "<html xmlns=\"http://www.w3.org/1999/xhtml\">foo<b xmlns=\"http://www.w3.org/1999/xhtml\">bar</b>baz</html>"
- "</message>"), testling.getResult());
- }
+ CPPUNIT_ASSERT_EQUAL(std::string(
+ "<message to=\"me@foo.com\" type=\"chat\">"
+ "<body>Hello&lt;&amp;World</body>"
+ "<html xmlns=\"http://www.w3.org/1999/xhtml\">foo<b xmlns=\"http://www.w3.org/1999/xhtml\">bar</b>baz</html>"
+ "</message>"), testling.getResult());
+ }
- void testParse_Empty() {
- SerializingParser testling;
+ void testParse_Empty() {
+ SerializingParser testling;
- CPPUNIT_ASSERT_EQUAL(std::string(""), testling.getResult());
- }
+ CPPUNIT_ASSERT_EQUAL(std::string(""), testling.getResult());
+ }
- void testParse_ToplevelCharacterData() {
- SerializingParser testling;
-
- AttributeMap attributes;
- testling.handleCharacterData("foo");
- testling.handleStartElement("message", "", attributes);
- testling.handleEndElement("message", "");
- testling.handleCharacterData("bar");
+ void testParse_ToplevelCharacterData() {
+ SerializingParser testling;
- CPPUNIT_ASSERT_EQUAL(std::string("<message/>"), testling.getResult());
- }
+ AttributeMap attributes;
+ testling.handleCharacterData("foo");
+ testling.handleStartElement("message", "", attributes);
+ testling.handleEndElement("message", "");
+ testling.handleCharacterData("bar");
+
+ CPPUNIT_ASSERT_EQUAL(std::string("<message/>"), testling.getResult());
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(SerializingParserTest);
diff --git a/Swiften/Parser/UnitTest/StanzaAckParserTest.cpp b/Swiften/Parser/UnitTest/StanzaAckParserTest.cpp
index 9a9d00c..4591640 100644
--- a/Swiften/Parser/UnitTest/StanzaAckParserTest.cpp
+++ b/Swiften/Parser/UnitTest/StanzaAckParserTest.cpp
@@ -14,40 +14,40 @@
using namespace Swift;
class StanzaAckParserTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(StanzaAckParserTest);
- CPPUNIT_TEST(testParse);
- CPPUNIT_TEST(testParse_Invalid);
- CPPUNIT_TEST(testParse_Empty);
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE(StanzaAckParserTest);
+ CPPUNIT_TEST(testParse);
+ CPPUNIT_TEST(testParse_Invalid);
+ CPPUNIT_TEST(testParse_Empty);
+ CPPUNIT_TEST_SUITE_END();
- public:
- void testParse() {
- StanzaAckParser testling;
- ElementParserTester parser(&testling);
+ public:
+ void testParse() {
+ StanzaAckParser testling;
+ ElementParserTester parser(&testling);
- CPPUNIT_ASSERT(parser.parse("<a h=\"12\" xmlns=\"urn:xmpp:sm:2\"/>"));
+ CPPUNIT_ASSERT(parser.parse("<a h=\"12\" xmlns=\"urn:xmpp:sm:2\"/>"));
- CPPUNIT_ASSERT(testling.getElementGeneric()->isValid());
- CPPUNIT_ASSERT_EQUAL(12U, testling.getElementGeneric()->getHandledStanzasCount());
- }
+ CPPUNIT_ASSERT(testling.getElementGeneric()->isValid());
+ CPPUNIT_ASSERT_EQUAL(12U, testling.getElementGeneric()->getHandledStanzasCount());
+ }
- void testParse_Invalid() {
- StanzaAckParser testling;
- ElementParserTester parser(&testling);
+ void testParse_Invalid() {
+ StanzaAckParser testling;
+ ElementParserTester parser(&testling);
- CPPUNIT_ASSERT(parser.parse("<a h=\"invalid\" xmlns=\"urn:xmpp:sm:2\"/>"));
+ CPPUNIT_ASSERT(parser.parse("<a h=\"invalid\" xmlns=\"urn:xmpp:sm:2\"/>"));
- CPPUNIT_ASSERT(!testling.getElementGeneric()->isValid());
- }
+ CPPUNIT_ASSERT(!testling.getElementGeneric()->isValid());
+ }
- void testParse_Empty() {
- StanzaAckParser testling;
- ElementParserTester parser(&testling);
+ void testParse_Empty() {
+ StanzaAckParser testling;
+ ElementParserTester parser(&testling);
- CPPUNIT_ASSERT(parser.parse("<a xmlns=\"urn:xmpp:sm:2\"/>"));
+ CPPUNIT_ASSERT(parser.parse("<a xmlns=\"urn:xmpp:sm:2\"/>"));
- CPPUNIT_ASSERT(!testling.getElementGeneric()->isValid());
- }
+ CPPUNIT_ASSERT(!testling.getElementGeneric()->isValid());
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(StanzaAckParserTest);
diff --git a/Swiften/Parser/UnitTest/StanzaParserTest.cpp b/Swiften/Parser/UnitTest/StanzaParserTest.cpp
index d9f39e7..c081b1b 100644
--- a/Swiften/Parser/UnitTest/StanzaParserTest.cpp
+++ b/Swiften/Parser/UnitTest/StanzaParserTest.cpp
@@ -17,196 +17,196 @@
using namespace Swift;
class StanzaParserTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(StanzaParserTest);
- CPPUNIT_TEST(testHandleEndElement_OnePayload);
- CPPUNIT_TEST(testHandleEndElement_MultiplePayloads);
- CPPUNIT_TEST(testHandleEndElement_StrayCharacterData);
- CPPUNIT_TEST(testHandleEndElement_UnknownPayload);
- CPPUNIT_TEST(testHandleParse_BasicAttributes);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- void setUp() {
- factoryCollection_ = new PayloadParserFactoryCollection();
- factoryCollection_->addFactory(&factory1_);
- factoryCollection_->addFactory(&factory2_);
- }
-
- void tearDown() {
- delete factoryCollection_;
- }
-
- void testHandleEndElement_OnePayload() {
- MyStanzaParser testling(factoryCollection_);
-
- AttributeMap attributes;
- attributes.addAttribute("foo", "", "fum");
- attributes.addAttribute("bar", "", "baz");
- testling.handleStartElement("mystanza", "", attributes);
- testling.handleStartElement("mypayload1", "", attributes);
- testling.handleStartElement("child", "", attributes);
- testling.handleEndElement("child", "");
- testling.handleEndElement("mypayload1", "");
- testling.handleEndElement("mystanza", "");
-
- CPPUNIT_ASSERT(testling.getStanza()->getPayload<MyPayload1>());
- CPPUNIT_ASSERT(testling.getStanza()->getPayload<MyPayload1>()->hasChild);
- }
-
- void testHandleEndElement_MultiplePayloads() {
- MyStanzaParser testling(factoryCollection_);
-
- AttributeMap attributes;
- testling.handleStartElement("mystanza", "", attributes);
- testling.handleStartElement("mypayload1", "", attributes);
- testling.handleEndElement("mypayload1", "");
- testling.handleStartElement("mypayload2", "", attributes);
- testling.handleEndElement("mypayload2", "");
- testling.handleEndElement("mystanza", "");
-
- CPPUNIT_ASSERT(testling.getStanza()->getPayload<MyPayload1>());
- CPPUNIT_ASSERT(testling.getStanza()->getPayload<MyPayload2>());
- }
-
- void testHandleEndElement_StrayCharacterData() {
- MyStanzaParser testling(factoryCollection_);
-
- AttributeMap attributes;
- testling.handleStartElement("mystanza", "", attributes);
- testling.handleStartElement("mypayload1", "", attributes);
- testling.handleEndElement("mypayload1", "");
- testling.handleCharacterData("bla");
- testling.handleStartElement("mypayload2", "", attributes);
- testling.handleEndElement("mypayload2", "");
- testling.handleEndElement("mystanza", "");
-
- CPPUNIT_ASSERT(testling.getStanza()->getPayload<MyPayload1>());
- CPPUNIT_ASSERT(testling.getStanza()->getPayload<MyPayload2>());
- }
-
- void testHandleEndElement_UnknownPayload() {
- MyStanzaParser testling(factoryCollection_);
-
- AttributeMap attributes;
- testling.handleStartElement("mystanza", "", attributes);
- testling.handleStartElement("mypayload1", "", attributes);
- testling.handleEndElement("mypayload1", "");
- testling.handleStartElement("unknown-payload", "", attributes);
- testling.handleStartElement("unknown-payload-child", "", attributes);
- testling.handleEndElement("unknown-payload-child", "");
- testling.handleEndElement("unknown-payload", "");
- testling.handleStartElement("mypayload2", "", attributes);
- testling.handleEndElement("mypayload2", "");
- testling.handleEndElement("mystanza", "");
-
- CPPUNIT_ASSERT(testling.getStanza()->getPayload<MyPayload1>());
- CPPUNIT_ASSERT(testling.getStanza()->getPayload<MyPayload2>());
- }
-
- void testHandleParse_BasicAttributes() {
- MyStanzaParser testling(factoryCollection_);
-
- AttributeMap attributes;
- attributes.addAttribute("to", "", "foo@example.com/blo");
- attributes.addAttribute("from", "", "bar@example.com/baz");
- attributes.addAttribute("id", "", "id-123");
- testling.handleStartElement("mystanza", "", attributes);
- testling.handleEndElement("mypayload1", "");
-
- CPPUNIT_ASSERT_EQUAL(JID("foo@example.com/blo"), testling.getStanza()->getTo());
- CPPUNIT_ASSERT_EQUAL(JID("bar@example.com/baz"), testling.getStanza()->getFrom());
- CPPUNIT_ASSERT_EQUAL(std::string("id-123"), testling.getStanza()->getID());
- }
-
- private:
- class MyPayload1 : public Payload
- {
- public:
- MyPayload1() : hasChild(false) {}
-
- bool hasChild;
- };
-
- class MyPayload1Parser : public GenericPayloadParser<MyPayload1>
- {
- public:
- MyPayload1Parser() {}
-
- virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap&) {
- if (element != "mypayload1") {
- getPayloadInternal()->hasChild = true;
- }
- }
-
- virtual void handleEndElement(const std::string&, const std::string&) {}
- virtual void handleCharacterData(const std::string&) {}
- };
-
- class MyPayload1ParserFactory : public PayloadParserFactory
- {
- public:
- MyPayload1ParserFactory() {}
-
- PayloadParser* createPayloadParser() { return new MyPayload1Parser(); }
-
- bool canParse(const std::string& element, const std::string&, const AttributeMap&) const {
- return element == "mypayload1";
- }
- };
-
- class MyPayload2 : public Payload
- {
- public:
- MyPayload2() {}
- };
-
- class MyPayload2Parser : public GenericPayloadParser<MyPayload2>
- {
- public:
- MyPayload2Parser() {}
-
- virtual void handleStartElement(const std::string&, const std::string&, const AttributeMap&) {}
- virtual void handleEndElement(const std::string&, const std::string&) {}
- virtual void handleCharacterData(const std::string&) {}
- };
-
-
- class MyPayload2ParserFactory : public PayloadParserFactory
- {
- public:
- MyPayload2ParserFactory() {}
-
- PayloadParser* createPayloadParser() { return new MyPayload2Parser(); }
- bool canParse(const std::string& element, const std::string&, const AttributeMap&) const {
- return element == "mypayload2";
- }
- };
-
- class MyStanza : public Stanza
- {
- public:
- MyStanza() {}
- };
-
- class MyStanzaParser : public StanzaParser
- {
- public:
- MyStanzaParser(PayloadParserFactoryCollection* collection) : StanzaParser(collection)
- {
- stanza_ = boost::make_shared<MyStanza>();
- }
-
- virtual boost::shared_ptr<ToplevelElement> getElement() const {
- return stanza_;
- }
-
- private:
- boost::shared_ptr<MyStanza> stanza_;
- };
-
- MyPayload1ParserFactory factory1_;
- MyPayload2ParserFactory factory2_;
- PayloadParserFactoryCollection* factoryCollection_;
+ CPPUNIT_TEST_SUITE(StanzaParserTest);
+ CPPUNIT_TEST(testHandleEndElement_OnePayload);
+ CPPUNIT_TEST(testHandleEndElement_MultiplePayloads);
+ CPPUNIT_TEST(testHandleEndElement_StrayCharacterData);
+ CPPUNIT_TEST(testHandleEndElement_UnknownPayload);
+ CPPUNIT_TEST(testHandleParse_BasicAttributes);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void setUp() {
+ factoryCollection_ = new PayloadParserFactoryCollection();
+ factoryCollection_->addFactory(&factory1_);
+ factoryCollection_->addFactory(&factory2_);
+ }
+
+ void tearDown() {
+ delete factoryCollection_;
+ }
+
+ void testHandleEndElement_OnePayload() {
+ MyStanzaParser testling(factoryCollection_);
+
+ AttributeMap attributes;
+ attributes.addAttribute("foo", "", "fum");
+ attributes.addAttribute("bar", "", "baz");
+ testling.handleStartElement("mystanza", "", attributes);
+ testling.handleStartElement("mypayload1", "", attributes);
+ testling.handleStartElement("child", "", attributes);
+ testling.handleEndElement("child", "");
+ testling.handleEndElement("mypayload1", "");
+ testling.handleEndElement("mystanza", "");
+
+ CPPUNIT_ASSERT(testling.getStanza()->getPayload<MyPayload1>());
+ CPPUNIT_ASSERT(testling.getStanza()->getPayload<MyPayload1>()->hasChild);
+ }
+
+ void testHandleEndElement_MultiplePayloads() {
+ MyStanzaParser testling(factoryCollection_);
+
+ AttributeMap attributes;
+ testling.handleStartElement("mystanza", "", attributes);
+ testling.handleStartElement("mypayload1", "", attributes);
+ testling.handleEndElement("mypayload1", "");
+ testling.handleStartElement("mypayload2", "", attributes);
+ testling.handleEndElement("mypayload2", "");
+ testling.handleEndElement("mystanza", "");
+
+ CPPUNIT_ASSERT(testling.getStanza()->getPayload<MyPayload1>());
+ CPPUNIT_ASSERT(testling.getStanza()->getPayload<MyPayload2>());
+ }
+
+ void testHandleEndElement_StrayCharacterData() {
+ MyStanzaParser testling(factoryCollection_);
+
+ AttributeMap attributes;
+ testling.handleStartElement("mystanza", "", attributes);
+ testling.handleStartElement("mypayload1", "", attributes);
+ testling.handleEndElement("mypayload1", "");
+ testling.handleCharacterData("bla");
+ testling.handleStartElement("mypayload2", "", attributes);
+ testling.handleEndElement("mypayload2", "");
+ testling.handleEndElement("mystanza", "");
+
+ CPPUNIT_ASSERT(testling.getStanza()->getPayload<MyPayload1>());
+ CPPUNIT_ASSERT(testling.getStanza()->getPayload<MyPayload2>());
+ }
+
+ void testHandleEndElement_UnknownPayload() {
+ MyStanzaParser testling(factoryCollection_);
+
+ AttributeMap attributes;
+ testling.handleStartElement("mystanza", "", attributes);
+ testling.handleStartElement("mypayload1", "", attributes);
+ testling.handleEndElement("mypayload1", "");
+ testling.handleStartElement("unknown-payload", "", attributes);
+ testling.handleStartElement("unknown-payload-child", "", attributes);
+ testling.handleEndElement("unknown-payload-child", "");
+ testling.handleEndElement("unknown-payload", "");
+ testling.handleStartElement("mypayload2", "", attributes);
+ testling.handleEndElement("mypayload2", "");
+ testling.handleEndElement("mystanza", "");
+
+ CPPUNIT_ASSERT(testling.getStanza()->getPayload<MyPayload1>());
+ CPPUNIT_ASSERT(testling.getStanza()->getPayload<MyPayload2>());
+ }
+
+ void testHandleParse_BasicAttributes() {
+ MyStanzaParser testling(factoryCollection_);
+
+ AttributeMap attributes;
+ attributes.addAttribute("to", "", "foo@example.com/blo");
+ attributes.addAttribute("from", "", "bar@example.com/baz");
+ attributes.addAttribute("id", "", "id-123");
+ testling.handleStartElement("mystanza", "", attributes);
+ testling.handleEndElement("mypayload1", "");
+
+ CPPUNIT_ASSERT_EQUAL(JID("foo@example.com/blo"), testling.getStanza()->getTo());
+ CPPUNIT_ASSERT_EQUAL(JID("bar@example.com/baz"), testling.getStanza()->getFrom());
+ CPPUNIT_ASSERT_EQUAL(std::string("id-123"), testling.getStanza()->getID());
+ }
+
+ private:
+ class MyPayload1 : public Payload
+ {
+ public:
+ MyPayload1() : hasChild(false) {}
+
+ bool hasChild;
+ };
+
+ class MyPayload1Parser : public GenericPayloadParser<MyPayload1>
+ {
+ public:
+ MyPayload1Parser() {}
+
+ virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap&) {
+ if (element != "mypayload1") {
+ getPayloadInternal()->hasChild = true;
+ }
+ }
+
+ virtual void handleEndElement(const std::string&, const std::string&) {}
+ virtual void handleCharacterData(const std::string&) {}
+ };
+
+ class MyPayload1ParserFactory : public PayloadParserFactory
+ {
+ public:
+ MyPayload1ParserFactory() {}
+
+ PayloadParser* createPayloadParser() { return new MyPayload1Parser(); }
+
+ bool canParse(const std::string& element, const std::string&, const AttributeMap&) const {
+ return element == "mypayload1";
+ }
+ };
+
+ class MyPayload2 : public Payload
+ {
+ public:
+ MyPayload2() {}
+ };
+
+ class MyPayload2Parser : public GenericPayloadParser<MyPayload2>
+ {
+ public:
+ MyPayload2Parser() {}
+
+ virtual void handleStartElement(const std::string&, const std::string&, const AttributeMap&) {}
+ virtual void handleEndElement(const std::string&, const std::string&) {}
+ virtual void handleCharacterData(const std::string&) {}
+ };
+
+
+ class MyPayload2ParserFactory : public PayloadParserFactory
+ {
+ public:
+ MyPayload2ParserFactory() {}
+
+ PayloadParser* createPayloadParser() { return new MyPayload2Parser(); }
+ bool canParse(const std::string& element, const std::string&, const AttributeMap&) const {
+ return element == "mypayload2";
+ }
+ };
+
+ class MyStanza : public Stanza
+ {
+ public:
+ MyStanza() {}
+ };
+
+ class MyStanzaParser : public StanzaParser
+ {
+ public:
+ MyStanzaParser(PayloadParserFactoryCollection* collection) : StanzaParser(collection)
+ {
+ stanza_ = boost::make_shared<MyStanza>();
+ }
+
+ virtual boost::shared_ptr<ToplevelElement> getElement() const {
+ return stanza_;
+ }
+
+ private:
+ boost::shared_ptr<MyStanza> stanza_;
+ };
+
+ MyPayload1ParserFactory factory1_;
+ MyPayload2ParserFactory factory2_;
+ PayloadParserFactoryCollection* factoryCollection_;
};
CPPUNIT_TEST_SUITE_REGISTRATION(StanzaParserTest);
diff --git a/Swiften/Parser/UnitTest/StanzaParserTester.h b/Swiften/Parser/UnitTest/StanzaParserTester.h
index 7d8b22b..36f41c9 100644
--- a/Swiften/Parser/UnitTest/StanzaParserTester.h
+++ b/Swiften/Parser/UnitTest/StanzaParserTester.h
@@ -10,5 +10,5 @@
#include <Swiften/Parser/UnitTest/ParserTester.h>
namespace Swift {
- typedef ParserTester<StanzaParser> StanzaParserTester;
+ typedef ParserTester<StanzaParser> StanzaParserTester;
}
diff --git a/Swiften/Parser/UnitTest/StreamFeaturesParserTest.cpp b/Swiften/Parser/UnitTest/StreamFeaturesParserTest.cpp
index f6c9336..031f2f3 100644
--- a/Swiften/Parser/UnitTest/StreamFeaturesParserTest.cpp
+++ b/Swiften/Parser/UnitTest/StreamFeaturesParserTest.cpp
@@ -13,96 +13,96 @@
using namespace Swift;
class StreamFeaturesParserTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(StreamFeaturesParserTest);
- CPPUNIT_TEST(testParse);
- CPPUNIT_TEST(testParse_Empty);
- CPPUNIT_TEST(testParse_AuthenticationHostname);
- CPPUNIT_TEST(testParse_AuthenticationHostnameEmpty);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- void testParse() {
- StreamFeaturesParser testling;
- ElementParserTester parser(&testling);
-
- CPPUNIT_ASSERT(parser.parse(
- "<stream:features xmlns:stream='http://etherx.jabber.org/streams'>"
- "<starttls xmlns=\"urn:ietf:params:xml:ns:xmpp-tls\"/>"
- "<compression xmlns=\"http://jabber.org/features/compress\">"
- "<method>zlib</method>"
- "<method>lzw</method>"
- "</compression>"
- "<mechanisms xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
- "<mechanism>DIGEST-MD5</mechanism>"
- "<mechanism>PLAIN</mechanism>"
- "</mechanisms>"
- "<bind xmlns=\"urn:ietf:params:xml:ns:xmpp-bind\"/>"
- "<sm xmlns='urn:xmpp:sm:2'/>"
- "<session xmlns=\"urn:ietf:params:xml:ns:xmpp-session\"/>"
- "<ver xmlns=\"urn:xmpp:features:rosterver\"/>"
- "</stream:features>"));
-
- StreamFeatures::ref element = boost::dynamic_pointer_cast<StreamFeatures>(testling.getElement());
- CPPUNIT_ASSERT(element->hasStartTLS());
- CPPUNIT_ASSERT(element->hasSession());
- CPPUNIT_ASSERT(element->hasResourceBind());
- CPPUNIT_ASSERT(element->hasCompressionMethod("zlib"));
- CPPUNIT_ASSERT(element->hasCompressionMethod("lzw"));
- CPPUNIT_ASSERT(element->hasAuthenticationMechanisms());
- CPPUNIT_ASSERT(element->hasAuthenticationMechanism("DIGEST-MD5"));
- CPPUNIT_ASSERT(element->hasAuthenticationMechanism("PLAIN"));
- CPPUNIT_ASSERT(!element->getAuthenticationHostname());
- CPPUNIT_ASSERT(element->hasStreamManagement());
- CPPUNIT_ASSERT(element->hasRosterVersioning());
- }
-
- void testParse_Empty() {
- StreamFeaturesParser testling;
- ElementParserTester parser(&testling);
-
- CPPUNIT_ASSERT(parser.parse("<stream:features xmlns:stream='http://etherx.jabber.org/streams'/>"));
-
- StreamFeatures::ref element = boost::dynamic_pointer_cast<StreamFeatures>(testling.getElement());
- CPPUNIT_ASSERT(!element->hasStartTLS());
- CPPUNIT_ASSERT(!element->hasSession());
- CPPUNIT_ASSERT(!element->hasResourceBind());
- CPPUNIT_ASSERT(!element->hasAuthenticationMechanisms());
- }
-
- void testParse_AuthenticationHostname() {
- StreamFeaturesParser testling;
- ElementParserTester parser(&testling);
- std::string hostname("auth42.us.example.com");
-
- CPPUNIT_ASSERT(parser.parse(
- "<stream:features xmlns:stream='http://etherx.jabber.org/streams'>"
- "<mechanisms xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
- "<mechanism>GSSAPI</mechanism>"
- "<hostname xmlns=\"urn:xmpp:domain-based-name:1\">auth42.us.example.com</hostname>"
- "</mechanisms>"
- "</stream:features>"));
-
- StreamFeatures::ref element = boost::dynamic_pointer_cast<StreamFeatures>(testling.getElement());
- CPPUNIT_ASSERT(element->hasAuthenticationMechanism("GSSAPI"));
- CPPUNIT_ASSERT_EQUAL(*element->getAuthenticationHostname(), hostname);
- }
-
- void testParse_AuthenticationHostnameEmpty() {
- StreamFeaturesParser testling;
- ElementParserTester parser(&testling);
-
- CPPUNIT_ASSERT(parser.parse(
- "<stream:features xmlns:stream='http://etherx.jabber.org/streams'>"
- "<mechanisms xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
- "<mechanism>GSSAPI</mechanism>"
- "<hostname xmlns=\"urn:xmpp:domain-based-name:1\"></hostname>"
- "</mechanisms>"
- "</stream:features>"));
-
- StreamFeatures::ref element = boost::dynamic_pointer_cast<StreamFeatures>(testling.getElement());
- CPPUNIT_ASSERT(element->hasAuthenticationMechanism("GSSAPI"));
- CPPUNIT_ASSERT(element->getAuthenticationHostname()->empty());
- }
+ CPPUNIT_TEST_SUITE(StreamFeaturesParserTest);
+ CPPUNIT_TEST(testParse);
+ CPPUNIT_TEST(testParse_Empty);
+ CPPUNIT_TEST(testParse_AuthenticationHostname);
+ CPPUNIT_TEST(testParse_AuthenticationHostnameEmpty);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void testParse() {
+ StreamFeaturesParser testling;
+ ElementParserTester parser(&testling);
+
+ CPPUNIT_ASSERT(parser.parse(
+ "<stream:features xmlns:stream='http://etherx.jabber.org/streams'>"
+ "<starttls xmlns=\"urn:ietf:params:xml:ns:xmpp-tls\"/>"
+ "<compression xmlns=\"http://jabber.org/features/compress\">"
+ "<method>zlib</method>"
+ "<method>lzw</method>"
+ "</compression>"
+ "<mechanisms xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
+ "<mechanism>DIGEST-MD5</mechanism>"
+ "<mechanism>PLAIN</mechanism>"
+ "</mechanisms>"
+ "<bind xmlns=\"urn:ietf:params:xml:ns:xmpp-bind\"/>"
+ "<sm xmlns='urn:xmpp:sm:2'/>"
+ "<session xmlns=\"urn:ietf:params:xml:ns:xmpp-session\"/>"
+ "<ver xmlns=\"urn:xmpp:features:rosterver\"/>"
+ "</stream:features>"));
+
+ StreamFeatures::ref element = boost::dynamic_pointer_cast<StreamFeatures>(testling.getElement());
+ CPPUNIT_ASSERT(element->hasStartTLS());
+ CPPUNIT_ASSERT(element->hasSession());
+ CPPUNIT_ASSERT(element->hasResourceBind());
+ CPPUNIT_ASSERT(element->hasCompressionMethod("zlib"));
+ CPPUNIT_ASSERT(element->hasCompressionMethod("lzw"));
+ CPPUNIT_ASSERT(element->hasAuthenticationMechanisms());
+ CPPUNIT_ASSERT(element->hasAuthenticationMechanism("DIGEST-MD5"));
+ CPPUNIT_ASSERT(element->hasAuthenticationMechanism("PLAIN"));
+ CPPUNIT_ASSERT(!element->getAuthenticationHostname());
+ CPPUNIT_ASSERT(element->hasStreamManagement());
+ CPPUNIT_ASSERT(element->hasRosterVersioning());
+ }
+
+ void testParse_Empty() {
+ StreamFeaturesParser testling;
+ ElementParserTester parser(&testling);
+
+ CPPUNIT_ASSERT(parser.parse("<stream:features xmlns:stream='http://etherx.jabber.org/streams'/>"));
+
+ StreamFeatures::ref element = boost::dynamic_pointer_cast<StreamFeatures>(testling.getElement());
+ CPPUNIT_ASSERT(!element->hasStartTLS());
+ CPPUNIT_ASSERT(!element->hasSession());
+ CPPUNIT_ASSERT(!element->hasResourceBind());
+ CPPUNIT_ASSERT(!element->hasAuthenticationMechanisms());
+ }
+
+ void testParse_AuthenticationHostname() {
+ StreamFeaturesParser testling;
+ ElementParserTester parser(&testling);
+ std::string hostname("auth42.us.example.com");
+
+ CPPUNIT_ASSERT(parser.parse(
+ "<stream:features xmlns:stream='http://etherx.jabber.org/streams'>"
+ "<mechanisms xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
+ "<mechanism>GSSAPI</mechanism>"
+ "<hostname xmlns=\"urn:xmpp:domain-based-name:1\">auth42.us.example.com</hostname>"
+ "</mechanisms>"
+ "</stream:features>"));
+
+ StreamFeatures::ref element = boost::dynamic_pointer_cast<StreamFeatures>(testling.getElement());
+ CPPUNIT_ASSERT(element->hasAuthenticationMechanism("GSSAPI"));
+ CPPUNIT_ASSERT_EQUAL(*element->getAuthenticationHostname(), hostname);
+ }
+
+ void testParse_AuthenticationHostnameEmpty() {
+ StreamFeaturesParser testling;
+ ElementParserTester parser(&testling);
+
+ CPPUNIT_ASSERT(parser.parse(
+ "<stream:features xmlns:stream='http://etherx.jabber.org/streams'>"
+ "<mechanisms xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"
+ "<mechanism>GSSAPI</mechanism>"
+ "<hostname xmlns=\"urn:xmpp:domain-based-name:1\"></hostname>"
+ "</mechanisms>"
+ "</stream:features>"));
+
+ StreamFeatures::ref element = boost::dynamic_pointer_cast<StreamFeatures>(testling.getElement());
+ CPPUNIT_ASSERT(element->hasAuthenticationMechanism("GSSAPI"));
+ CPPUNIT_ASSERT(element->getAuthenticationHostname()->empty());
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(StreamFeaturesParserTest);
diff --git a/Swiften/Parser/UnitTest/StreamManagementEnabledParserTest.cpp b/Swiften/Parser/UnitTest/StreamManagementEnabledParserTest.cpp
index a39dc4b..7b4a9cc 100644
--- a/Swiften/Parser/UnitTest/StreamManagementEnabledParserTest.cpp
+++ b/Swiften/Parser/UnitTest/StreamManagementEnabledParserTest.cpp
@@ -13,22 +13,22 @@
using namespace Swift;
class StreamManagementEnabledParserTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(StreamManagementEnabledParserTest);
- CPPUNIT_TEST(testParse);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- void testParse() {
- StreamManagementEnabledParser testling;
- ElementParserTester parser(&testling);
-
- CPPUNIT_ASSERT(parser.parse(
- "<enabled xmlns=\"urn:xmpp:sm:3\" id=\"some-long-sm-id\" resume=\"true\"/>"));
-
- boost::shared_ptr<StreamManagementEnabled> element = boost::dynamic_pointer_cast<StreamManagementEnabled>(testling.getElement());
- CPPUNIT_ASSERT(element->getResumeSupported());
- CPPUNIT_ASSERT_EQUAL(std::string("some-long-sm-id"), element->getResumeID());
- }
+ CPPUNIT_TEST_SUITE(StreamManagementEnabledParserTest);
+ CPPUNIT_TEST(testParse);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void testParse() {
+ StreamManagementEnabledParser testling;
+ ElementParserTester parser(&testling);
+
+ CPPUNIT_ASSERT(parser.parse(
+ "<enabled xmlns=\"urn:xmpp:sm:3\" id=\"some-long-sm-id\" resume=\"true\"/>"));
+
+ boost::shared_ptr<StreamManagementEnabled> element = boost::dynamic_pointer_cast<StreamManagementEnabled>(testling.getElement());
+ CPPUNIT_ASSERT(element->getResumeSupported());
+ CPPUNIT_ASSERT_EQUAL(std::string("some-long-sm-id"), element->getResumeID());
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(StreamManagementEnabledParserTest);
diff --git a/Swiften/Parser/UnitTest/XMLParserTest.cpp b/Swiften/Parser/UnitTest/XMLParserTest.cpp
index 6b7aa93..b593aa7 100644
--- a/Swiften/Parser/UnitTest/XMLParserTest.cpp
+++ b/Swiften/Parser/UnitTest/XMLParserTest.cpp
@@ -21,337 +21,337 @@ using namespace Swift;
template <typename ParserType>
class XMLParserTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(XMLParserTest);
- CPPUNIT_TEST(testParse_NestedElements);
- CPPUNIT_TEST(testParse_ElementInNamespacedElement);
- CPPUNIT_TEST(testParse_CharacterData);
- CPPUNIT_TEST(testParse_XMLEntity);
- CPPUNIT_TEST(testParse_NamespacePrefix);
- CPPUNIT_TEST(testParse_UnhandledXML);
- CPPUNIT_TEST(testParse_InvalidXML);
- CPPUNIT_TEST(testParse_InErrorState);
- CPPUNIT_TEST(testParse_Incremental);
- CPPUNIT_TEST(testParse_WhitespaceInAttribute);
- CPPUNIT_TEST(testParse_AttributeWithoutNamespace);
- CPPUNIT_TEST(testParse_AttributeWithNamespace);
- CPPUNIT_TEST(testParse_BillionLaughs);
- CPPUNIT_TEST(testParse_InternalEntity);
- //CPPUNIT_TEST(testParse_UndefinedPrefix);
- //CPPUNIT_TEST(testParse_UndefinedAttributePrefix);
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE(XMLParserTest);
+ CPPUNIT_TEST(testParse_NestedElements);
+ CPPUNIT_TEST(testParse_ElementInNamespacedElement);
+ CPPUNIT_TEST(testParse_CharacterData);
+ CPPUNIT_TEST(testParse_XMLEntity);
+ CPPUNIT_TEST(testParse_NamespacePrefix);
+ CPPUNIT_TEST(testParse_UnhandledXML);
+ CPPUNIT_TEST(testParse_InvalidXML);
+ CPPUNIT_TEST(testParse_InErrorState);
+ CPPUNIT_TEST(testParse_Incremental);
+ CPPUNIT_TEST(testParse_WhitespaceInAttribute);
+ CPPUNIT_TEST(testParse_AttributeWithoutNamespace);
+ CPPUNIT_TEST(testParse_AttributeWithNamespace);
+ CPPUNIT_TEST(testParse_BillionLaughs);
+ CPPUNIT_TEST(testParse_InternalEntity);
+ //CPPUNIT_TEST(testParse_UndefinedPrefix);
+ //CPPUNIT_TEST(testParse_UndefinedAttributePrefix);
+ CPPUNIT_TEST_SUITE_END();
- public:
- void testParse_NestedElements() {
- ParserType testling(&client_);
+ public:
+ void testParse_NestedElements() {
+ ParserType testling(&client_);
- CPPUNIT_ASSERT(testling.parse(
- "<iq type=\"get\">"
- "<query xmlns='jabber:iq:version'/>"
- "</iq>"));
+ CPPUNIT_ASSERT(testling.parse(
+ "<iq type=\"get\">"
+ "<query xmlns='jabber:iq:version'/>"
+ "</iq>"));
- CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), client_.events.size());
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), client_.events.size());
- CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[0].type);
- CPPUNIT_ASSERT_EQUAL(std::string("iq"), client_.events[0].data);
- CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), client_.events[0].attributes.getEntries().size());
- CPPUNIT_ASSERT_EQUAL(std::string("get"), client_.events[0].attributes.getAttribute("type"));
- CPPUNIT_ASSERT_EQUAL(std::string(), client_.events[0].ns);
+ CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[0].type);
+ CPPUNIT_ASSERT_EQUAL(std::string("iq"), client_.events[0].data);
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), client_.events[0].attributes.getEntries().size());
+ CPPUNIT_ASSERT_EQUAL(std::string("get"), client_.events[0].attributes.getAttribute("type"));
+ CPPUNIT_ASSERT_EQUAL(std::string(), client_.events[0].ns);
- CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[1].type);
- CPPUNIT_ASSERT_EQUAL(std::string("query"), client_.events[1].data);
- CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), client_.events[1].attributes.getEntries().size());
- CPPUNIT_ASSERT_EQUAL(std::string("jabber:iq:version"), client_.events[1].ns);
+ CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[1].type);
+ CPPUNIT_ASSERT_EQUAL(std::string("query"), client_.events[1].data);
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), client_.events[1].attributes.getEntries().size());
+ CPPUNIT_ASSERT_EQUAL(std::string("jabber:iq:version"), client_.events[1].ns);
- CPPUNIT_ASSERT_EQUAL(Client::EndElement, client_.events[2].type);
- CPPUNIT_ASSERT_EQUAL(std::string("query"), client_.events[2].data);
- CPPUNIT_ASSERT_EQUAL(std::string("jabber:iq:version"), client_.events[2].ns);
+ CPPUNIT_ASSERT_EQUAL(Client::EndElement, client_.events[2].type);
+ CPPUNIT_ASSERT_EQUAL(std::string("query"), client_.events[2].data);
+ CPPUNIT_ASSERT_EQUAL(std::string("jabber:iq:version"), client_.events[2].ns);
- CPPUNIT_ASSERT_EQUAL(Client::EndElement, client_.events[3].type);
- CPPUNIT_ASSERT_EQUAL(std::string("iq"), client_.events[3].data);
- CPPUNIT_ASSERT_EQUAL(std::string(), client_.events[3].ns);
- }
+ CPPUNIT_ASSERT_EQUAL(Client::EndElement, client_.events[3].type);
+ CPPUNIT_ASSERT_EQUAL(std::string("iq"), client_.events[3].data);
+ CPPUNIT_ASSERT_EQUAL(std::string(), client_.events[3].ns);
+ }
- void testParse_ElementInNamespacedElement() {
- ParserType testling(&client_);
+ void testParse_ElementInNamespacedElement() {
+ ParserType testling(&client_);
- CPPUNIT_ASSERT(testling.parse(
- "<query xmlns='jabber:iq:version'>"
- "<name>Swift</name>"
- "</query>"));
+ CPPUNIT_ASSERT(testling.parse(
+ "<query xmlns='jabber:iq:version'>"
+ "<name>Swift</name>"
+ "</query>"));
- CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(5), client_.events.size());
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(5), client_.events.size());
- CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[0].type);
- CPPUNIT_ASSERT_EQUAL(std::string("query"), client_.events[0].data);
- CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), client_.events[0].attributes.getEntries().size());
- CPPUNIT_ASSERT_EQUAL(std::string("jabber:iq:version"), client_.events[0].ns);
+ CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[0].type);
+ CPPUNIT_ASSERT_EQUAL(std::string("query"), client_.events[0].data);
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), client_.events[0].attributes.getEntries().size());
+ CPPUNIT_ASSERT_EQUAL(std::string("jabber:iq:version"), client_.events[0].ns);
- CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[1].type);
- CPPUNIT_ASSERT_EQUAL(std::string("name"), client_.events[1].data);
- CPPUNIT_ASSERT_EQUAL(std::string("jabber:iq:version"), client_.events[1].ns);
+ CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[1].type);
+ CPPUNIT_ASSERT_EQUAL(std::string("name"), client_.events[1].data);
+ CPPUNIT_ASSERT_EQUAL(std::string("jabber:iq:version"), client_.events[1].ns);
- CPPUNIT_ASSERT_EQUAL(Client::CharacterData, client_.events[2].type);
- CPPUNIT_ASSERT_EQUAL(std::string("Swift"), client_.events[2].data);
+ CPPUNIT_ASSERT_EQUAL(Client::CharacterData, client_.events[2].type);
+ CPPUNIT_ASSERT_EQUAL(std::string("Swift"), client_.events[2].data);
- CPPUNIT_ASSERT_EQUAL(Client::EndElement, client_.events[3].type);
- CPPUNIT_ASSERT_EQUAL(std::string("name"), client_.events[3].data);
- CPPUNIT_ASSERT_EQUAL(std::string("jabber:iq:version"), client_.events[3].ns);
+ CPPUNIT_ASSERT_EQUAL(Client::EndElement, client_.events[3].type);
+ CPPUNIT_ASSERT_EQUAL(std::string("name"), client_.events[3].data);
+ CPPUNIT_ASSERT_EQUAL(std::string("jabber:iq:version"), client_.events[3].ns);
- CPPUNIT_ASSERT_EQUAL(Client::EndElement, client_.events[4].type);
- CPPUNIT_ASSERT_EQUAL(std::string("query"), client_.events[4].data);
- CPPUNIT_ASSERT_EQUAL(std::string("jabber:iq:version"), client_.events[4].ns);
- }
+ CPPUNIT_ASSERT_EQUAL(Client::EndElement, client_.events[4].type);
+ CPPUNIT_ASSERT_EQUAL(std::string("query"), client_.events[4].data);
+ CPPUNIT_ASSERT_EQUAL(std::string("jabber:iq:version"), client_.events[4].ns);
+ }
- void testParse_CharacterData() {
- ParserType testling(&client_);
+ void testParse_CharacterData() {
+ ParserType testling(&client_);
- CPPUNIT_ASSERT(testling.parse("<html>bla<i>bli</i>blo</html>"));
+ CPPUNIT_ASSERT(testling.parse("<html>bla<i>bli</i>blo</html>"));
- CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(7), client_.events.size());
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(7), client_.events.size());
- CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[0].type);
- CPPUNIT_ASSERT_EQUAL(std::string("html"), client_.events[0].data);
+ CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[0].type);
+ CPPUNIT_ASSERT_EQUAL(std::string("html"), client_.events[0].data);
- CPPUNIT_ASSERT_EQUAL(Client::CharacterData, client_.events[1].type);
- CPPUNIT_ASSERT_EQUAL(std::string("bla"), client_.events[1].data);
+ CPPUNIT_ASSERT_EQUAL(Client::CharacterData, client_.events[1].type);
+ CPPUNIT_ASSERT_EQUAL(std::string("bla"), client_.events[1].data);
- CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[2].type);
- CPPUNIT_ASSERT_EQUAL(std::string("i"), client_.events[2].data);
+ CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[2].type);
+ CPPUNIT_ASSERT_EQUAL(std::string("i"), client_.events[2].data);
- CPPUNIT_ASSERT_EQUAL(Client::CharacterData, client_.events[3].type);
- CPPUNIT_ASSERT_EQUAL(std::string("bli"), client_.events[3].data);
+ CPPUNIT_ASSERT_EQUAL(Client::CharacterData, client_.events[3].type);
+ CPPUNIT_ASSERT_EQUAL(std::string("bli"), client_.events[3].data);
- CPPUNIT_ASSERT_EQUAL(Client::EndElement, client_.events[4].type);
- CPPUNIT_ASSERT_EQUAL(std::string("i"), client_.events[4].data);
+ CPPUNIT_ASSERT_EQUAL(Client::EndElement, client_.events[4].type);
+ CPPUNIT_ASSERT_EQUAL(std::string("i"), client_.events[4].data);
- CPPUNIT_ASSERT_EQUAL(Client::CharacterData, client_.events[5].type);
- CPPUNIT_ASSERT_EQUAL(std::string("blo"), client_.events[5].data);
+ CPPUNIT_ASSERT_EQUAL(Client::CharacterData, client_.events[5].type);
+ CPPUNIT_ASSERT_EQUAL(std::string("blo"), client_.events[5].data);
- CPPUNIT_ASSERT_EQUAL(Client::EndElement, client_.events[6].type);
- CPPUNIT_ASSERT_EQUAL(std::string("html"), client_.events[6].data);
- }
+ CPPUNIT_ASSERT_EQUAL(Client::EndElement, client_.events[6].type);
+ CPPUNIT_ASSERT_EQUAL(std::string("html"), client_.events[6].data);
+ }
- void testParse_XMLEntity() {
- ParserType testling(&client_);
+ void testParse_XMLEntity() {
+ ParserType testling(&client_);
- CPPUNIT_ASSERT(testling.parse("<html>&lt;&gt;</html>"));
+ CPPUNIT_ASSERT(testling.parse("<html>&lt;&gt;</html>"));
- CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), client_.events.size());
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), client_.events.size());
- CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[0].type);
- CPPUNIT_ASSERT_EQUAL(std::string("html"), client_.events[0].data);
+ CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[0].type);
+ CPPUNIT_ASSERT_EQUAL(std::string("html"), client_.events[0].data);
- CPPUNIT_ASSERT_EQUAL(Client::CharacterData, client_.events[1].type);
- CPPUNIT_ASSERT_EQUAL(std::string("<"), client_.events[1].data);
+ CPPUNIT_ASSERT_EQUAL(Client::CharacterData, client_.events[1].type);
+ CPPUNIT_ASSERT_EQUAL(std::string("<"), client_.events[1].data);
- CPPUNIT_ASSERT_EQUAL(Client::CharacterData, client_.events[2].type);
- CPPUNIT_ASSERT_EQUAL(std::string(">"), client_.events[2].data);
+ CPPUNIT_ASSERT_EQUAL(Client::CharacterData, client_.events[2].type);
+ CPPUNIT_ASSERT_EQUAL(std::string(">"), client_.events[2].data);
- CPPUNIT_ASSERT_EQUAL(Client::EndElement, client_.events[3].type);
- CPPUNIT_ASSERT_EQUAL(std::string("html"), client_.events[3].data);
- }
+ CPPUNIT_ASSERT_EQUAL(Client::EndElement, client_.events[3].type);
+ CPPUNIT_ASSERT_EQUAL(std::string("html"), client_.events[3].data);
+ }
- void testParse_NamespacePrefix() {
- ParserType testling(&client_);
+ void testParse_NamespacePrefix() {
+ ParserType testling(&client_);
- CPPUNIT_ASSERT(testling.parse("<p:x xmlns:p='bla'><p:y/></p:x>"));
+ CPPUNIT_ASSERT(testling.parse("<p:x xmlns:p='bla'><p:y/></p:x>"));
- CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), client_.events.size());
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), client_.events.size());
- CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[0].type);
- CPPUNIT_ASSERT_EQUAL(std::string("x"), client_.events[0].data);
- CPPUNIT_ASSERT_EQUAL(std::string("bla"), client_.events[0].ns);
+ CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[0].type);
+ CPPUNIT_ASSERT_EQUAL(std::string("x"), client_.events[0].data);
+ CPPUNIT_ASSERT_EQUAL(std::string("bla"), client_.events[0].ns);
- CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[1].type);
- CPPUNIT_ASSERT_EQUAL(std::string("y"), client_.events[1].data);
- CPPUNIT_ASSERT_EQUAL(std::string("bla"), client_.events[1].ns);
+ CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[1].type);
+ CPPUNIT_ASSERT_EQUAL(std::string("y"), client_.events[1].data);
+ CPPUNIT_ASSERT_EQUAL(std::string("bla"), client_.events[1].ns);
- CPPUNIT_ASSERT_EQUAL(Client::EndElement, client_.events[2].type);
- CPPUNIT_ASSERT_EQUAL(std::string("y"), client_.events[2].data);
- CPPUNIT_ASSERT_EQUAL(std::string("bla"), client_.events[2].ns);
+ CPPUNIT_ASSERT_EQUAL(Client::EndElement, client_.events[2].type);
+ CPPUNIT_ASSERT_EQUAL(std::string("y"), client_.events[2].data);
+ CPPUNIT_ASSERT_EQUAL(std::string("bla"), client_.events[2].ns);
- CPPUNIT_ASSERT_EQUAL(Client::EndElement, client_.events[3].type);
- CPPUNIT_ASSERT_EQUAL(std::string("x"), client_.events[3].data);
- CPPUNIT_ASSERT_EQUAL(std::string("bla"), client_.events[3].ns);
- }
+ CPPUNIT_ASSERT_EQUAL(Client::EndElement, client_.events[3].type);
+ CPPUNIT_ASSERT_EQUAL(std::string("x"), client_.events[3].data);
+ CPPUNIT_ASSERT_EQUAL(std::string("bla"), client_.events[3].ns);
+ }
- void testParse_UnhandledXML() {
- ParserType testling(&client_);
+ void testParse_UnhandledXML() {
+ ParserType testling(&client_);
- CPPUNIT_ASSERT(testling.parse("<iq><!-- Testing --></iq>"));
+ CPPUNIT_ASSERT(testling.parse("<iq><!-- Testing --></iq>"));
- CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), client_.events.size());
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), client_.events.size());
- CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[0].type);
- CPPUNIT_ASSERT_EQUAL(std::string("iq"), client_.events[0].data);
+ CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[0].type);
+ CPPUNIT_ASSERT_EQUAL(std::string("iq"), client_.events[0].data);
- CPPUNIT_ASSERT_EQUAL(Client::EndElement, client_.events[1].type);
- CPPUNIT_ASSERT_EQUAL(std::string("iq"), client_.events[1].data);
- }
+ CPPUNIT_ASSERT_EQUAL(Client::EndElement, client_.events[1].type);
+ CPPUNIT_ASSERT_EQUAL(std::string("iq"), client_.events[1].data);
+ }
- void testParse_InvalidXML() {
- ParserType testling(&client_);
+ void testParse_InvalidXML() {
+ ParserType testling(&client_);
- CPPUNIT_ASSERT(!testling.parse("<iq><bla></iq>"));
- }
+ CPPUNIT_ASSERT(!testling.parse("<iq><bla></iq>"));
+ }
- void testParse_InErrorState() {
- ParserType testling(&client_);
+ void testParse_InErrorState() {
+ ParserType testling(&client_);
- CPPUNIT_ASSERT(!testling.parse("<iq><bla></iq>"));
- CPPUNIT_ASSERT(!testling.parse("<iq/>"));
- }
+ CPPUNIT_ASSERT(!testling.parse("<iq><bla></iq>"));
+ CPPUNIT_ASSERT(!testling.parse("<iq/>"));
+ }
- void testParse_Incremental() {
- ParserType testling(&client_);
+ void testParse_Incremental() {
+ ParserType testling(&client_);
- CPPUNIT_ASSERT(testling.parse("<iq"));
- CPPUNIT_ASSERT(testling.parse("></iq>"));
+ CPPUNIT_ASSERT(testling.parse("<iq"));
+ CPPUNIT_ASSERT(testling.parse("></iq>"));
- CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), client_.events.size());
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), client_.events.size());
- CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[0].type);
- CPPUNIT_ASSERT_EQUAL(std::string("iq"), client_.events[0].data);
+ CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[0].type);
+ CPPUNIT_ASSERT_EQUAL(std::string("iq"), client_.events[0].data);
- CPPUNIT_ASSERT_EQUAL(Client::EndElement, client_.events[1].type);
- CPPUNIT_ASSERT_EQUAL(std::string("iq"), client_.events[1].data);
- }
+ CPPUNIT_ASSERT_EQUAL(Client::EndElement, client_.events[1].type);
+ CPPUNIT_ASSERT_EQUAL(std::string("iq"), client_.events[1].data);
+ }
- void testParse_WhitespaceInAttribute() {
- ParserType testling(&client_);
+ void testParse_WhitespaceInAttribute() {
+ ParserType testling(&client_);
- CPPUNIT_ASSERT(testling.parse(
- "<query xmlns='http://www.xmpp.org/extensions/xep-0084.html#ns-data '>"));
- CPPUNIT_ASSERT(testling.parse(
- "<presence/>"));
- CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), client_.events.size());
- CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[0].type);
- CPPUNIT_ASSERT_EQUAL(std::string("query"), client_.events[0].data);
- CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[1].type);
- CPPUNIT_ASSERT_EQUAL(std::string("presence"), client_.events[1].data);
- CPPUNIT_ASSERT_EQUAL(Client::EndElement, client_.events[2].type);
- CPPUNIT_ASSERT_EQUAL(std::string("presence"), client_.events[2].data);
- }
+ CPPUNIT_ASSERT(testling.parse(
+ "<query xmlns='http://www.xmpp.org/extensions/xep-0084.html#ns-data '>"));
+ CPPUNIT_ASSERT(testling.parse(
+ "<presence/>"));
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), client_.events.size());
+ CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[0].type);
+ CPPUNIT_ASSERT_EQUAL(std::string("query"), client_.events[0].data);
+ CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[1].type);
+ CPPUNIT_ASSERT_EQUAL(std::string("presence"), client_.events[1].data);
+ CPPUNIT_ASSERT_EQUAL(Client::EndElement, client_.events[2].type);
+ CPPUNIT_ASSERT_EQUAL(std::string("presence"), client_.events[2].data);
+ }
- void testParse_AttributeWithoutNamespace() {
- ParserType testling(&client_);
+ void testParse_AttributeWithoutNamespace() {
+ ParserType testling(&client_);
- CPPUNIT_ASSERT(testling.parse(
- "<query xmlns='http://swift.im' attr='3'/>"));
-
- CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), client_.events[0].attributes.getEntries().size());
- CPPUNIT_ASSERT_EQUAL(std::string("attr"), client_.events[0].attributes.getEntries()[0].getAttribute().getName());
- CPPUNIT_ASSERT_EQUAL(std::string(""), client_.events[0].attributes.getEntries()[0].getAttribute().getNamespace());
- }
-
- void testParse_AttributeWithNamespace() {
- ParserType testling(&client_);
-
- CPPUNIT_ASSERT(testling.parse(
- "<query xmlns='http://swift.im' xmlns:f='http://swift.im/f' f:attr='3'/>"));
-
- CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), client_.events[0].attributes.getEntries().size());
- CPPUNIT_ASSERT_EQUAL(std::string("attr"), client_.events[0].attributes.getEntries()[0].getAttribute().getName());
- CPPUNIT_ASSERT_EQUAL(std::string("http://swift.im/f"), client_.events[0].attributes.getEntries()[0].getAttribute().getNamespace());
- }
-
- void testParse_BillionLaughs() {
- ParserType testling(&client_);
-
- CPPUNIT_ASSERT(!testling.parse(
- "<?xml version=\"1.0\"?>"
- "<!DOCTYPE lolz ["
- " <!ENTITY lol \"lol\">"
- " <!ENTITY lol2 \"&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;\">"
- " <!ENTITY lol3 \"&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;\">"
- " <!ENTITY lol4 \"&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;\">"
- " <!ENTITY lol5 \"&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;\">"
- " <!ENTITY lol6 \"&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;\">"
- " <!ENTITY lol7 \"&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;\">"
- " <!ENTITY lol8 \"&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;\">"
- " <!ENTITY lol9 \"&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;\">"
- "]>"
- "<lolz>&lol9;</lolz>"
- ));
- }
-
- void testParse_InternalEntity() {
- ParserType testling(&client_);
-
- CPPUNIT_ASSERT(!testling.parse("<!DOCTYPE foo [<!ENTITY bar \"Bar\">]><foo>&bar;</foo>"));
- }
-
- void testParse_UndefinedPrefix() {
- ParserType testling(&client_);
-
- CPPUNIT_ASSERT(testling.parse(
- "<foo:bar><bla/></foo:bar>"));
-
- CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), client_.events.size());
-
- CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[0].type);
- CPPUNIT_ASSERT_EQUAL(std::string("foo:bar"), client_.events[0].data);
- CPPUNIT_ASSERT_EQUAL(std::string(""), client_.events[0].ns);
-
- CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[1].type);
- CPPUNIT_ASSERT_EQUAL(std::string("bla"), client_.events[1].data);
- CPPUNIT_ASSERT_EQUAL(std::string(""), client_.events[1].ns);
-
- CPPUNIT_ASSERT_EQUAL(Client::EndElement, client_.events[2].type);
- CPPUNIT_ASSERT_EQUAL(std::string("bla"), client_.events[2].data);
- CPPUNIT_ASSERT_EQUAL(std::string(""), client_.events[2].ns);
-
- CPPUNIT_ASSERT_EQUAL(Client::EndElement, client_.events[3].type);
- CPPUNIT_ASSERT_EQUAL(std::string("foo:bar"), client_.events[3].data);
- CPPUNIT_ASSERT_EQUAL(std::string(""), client_.events[3].ns);
- }
-
- void testParse_UndefinedAttributePrefix() {
- ParserType testling(&client_);
-
- CPPUNIT_ASSERT(testling.parse(
- "<foo bar:baz='bla'/>"));
-
- CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), client_.events[0].attributes.getEntries().size());
- CPPUNIT_ASSERT_EQUAL(std::string("bar:baz"), client_.events[0].attributes.getEntries()[0].getAttribute().getName());
- }
-
- private:
- class Client : public XMLParserClient {
- public:
- enum Type { StartElement, EndElement, CharacterData };
- struct Event {
- Event(
- Type type,
- const std::string& data,
- const std::string& ns,
- const AttributeMap& attributes)
- : type(type), data(data), ns(ns), attributes(attributes) {}
- Event(Type type, const std::string& data, const std::string& ns = std::string())
- : type(type), data(data), ns(ns) {}
-
- Type type;
- std::string data;
- std::string ns;
- AttributeMap attributes;
- };
-
- Client() {}
-
- virtual void handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) {
- events.push_back(Event(StartElement, element, ns, attributes));
- }
-
- virtual void handleEndElement(const std::string& element, const std::string& ns) {
- events.push_back(Event(EndElement, element, ns));
- }
-
- virtual void handleCharacterData(const std::string& data) {
- events.push_back(Event(CharacterData, data));
- }
-
- std::vector<Event> events;
- } client_;
+ CPPUNIT_ASSERT(testling.parse(
+ "<query xmlns='http://swift.im' attr='3'/>"));
+
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), client_.events[0].attributes.getEntries().size());
+ CPPUNIT_ASSERT_EQUAL(std::string("attr"), client_.events[0].attributes.getEntries()[0].getAttribute().getName());
+ CPPUNIT_ASSERT_EQUAL(std::string(""), client_.events[0].attributes.getEntries()[0].getAttribute().getNamespace());
+ }
+
+ void testParse_AttributeWithNamespace() {
+ ParserType testling(&client_);
+
+ CPPUNIT_ASSERT(testling.parse(
+ "<query xmlns='http://swift.im' xmlns:f='http://swift.im/f' f:attr='3'/>"));
+
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), client_.events[0].attributes.getEntries().size());
+ CPPUNIT_ASSERT_EQUAL(std::string("attr"), client_.events[0].attributes.getEntries()[0].getAttribute().getName());
+ CPPUNIT_ASSERT_EQUAL(std::string("http://swift.im/f"), client_.events[0].attributes.getEntries()[0].getAttribute().getNamespace());
+ }
+
+ void testParse_BillionLaughs() {
+ ParserType testling(&client_);
+
+ CPPUNIT_ASSERT(!testling.parse(
+ "<?xml version=\"1.0\"?>"
+ "<!DOCTYPE lolz ["
+ " <!ENTITY lol \"lol\">"
+ " <!ENTITY lol2 \"&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;\">"
+ " <!ENTITY lol3 \"&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;\">"
+ " <!ENTITY lol4 \"&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;\">"
+ " <!ENTITY lol5 \"&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;\">"
+ " <!ENTITY lol6 \"&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;\">"
+ " <!ENTITY lol7 \"&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;\">"
+ " <!ENTITY lol8 \"&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;\">"
+ " <!ENTITY lol9 \"&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;\">"
+ "]>"
+ "<lolz>&lol9;</lolz>"
+ ));
+ }
+
+ void testParse_InternalEntity() {
+ ParserType testling(&client_);
+
+ CPPUNIT_ASSERT(!testling.parse("<!DOCTYPE foo [<!ENTITY bar \"Bar\">]><foo>&bar;</foo>"));
+ }
+
+ void testParse_UndefinedPrefix() {
+ ParserType testling(&client_);
+
+ CPPUNIT_ASSERT(testling.parse(
+ "<foo:bar><bla/></foo:bar>"));
+
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), client_.events.size());
+
+ CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[0].type);
+ CPPUNIT_ASSERT_EQUAL(std::string("foo:bar"), client_.events[0].data);
+ CPPUNIT_ASSERT_EQUAL(std::string(""), client_.events[0].ns);
+
+ CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[1].type);
+ CPPUNIT_ASSERT_EQUAL(std::string("bla"), client_.events[1].data);
+ CPPUNIT_ASSERT_EQUAL(std::string(""), client_.events[1].ns);
+
+ CPPUNIT_ASSERT_EQUAL(Client::EndElement, client_.events[2].type);
+ CPPUNIT_ASSERT_EQUAL(std::string("bla"), client_.events[2].data);
+ CPPUNIT_ASSERT_EQUAL(std::string(""), client_.events[2].ns);
+
+ CPPUNIT_ASSERT_EQUAL(Client::EndElement, client_.events[3].type);
+ CPPUNIT_ASSERT_EQUAL(std::string("foo:bar"), client_.events[3].data);
+ CPPUNIT_ASSERT_EQUAL(std::string(""), client_.events[3].ns);
+ }
+
+ void testParse_UndefinedAttributePrefix() {
+ ParserType testling(&client_);
+
+ CPPUNIT_ASSERT(testling.parse(
+ "<foo bar:baz='bla'/>"));
+
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), client_.events[0].attributes.getEntries().size());
+ CPPUNIT_ASSERT_EQUAL(std::string("bar:baz"), client_.events[0].attributes.getEntries()[0].getAttribute().getName());
+ }
+
+ private:
+ class Client : public XMLParserClient {
+ public:
+ enum Type { StartElement, EndElement, CharacterData };
+ struct Event {
+ Event(
+ Type type,
+ const std::string& data,
+ const std::string& ns,
+ const AttributeMap& attributes)
+ : type(type), data(data), ns(ns), attributes(attributes) {}
+ Event(Type type, const std::string& data, const std::string& ns = std::string())
+ : type(type), data(data), ns(ns) {}
+
+ Type type;
+ std::string data;
+ std::string ns;
+ AttributeMap attributes;
+ };
+
+ Client() {}
+
+ virtual void handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) {
+ events.push_back(Event(StartElement, element, ns, attributes));
+ }
+
+ virtual void handleEndElement(const std::string& element, const std::string& ns) {
+ events.push_back(Event(EndElement, element, ns));
+ }
+
+ virtual void handleCharacterData(const std::string& data) {
+ events.push_back(Event(CharacterData, data));
+ }
+
+ std::vector<Event> events;
+ } client_;
};
#ifdef HAVE_EXPAT
diff --git a/Swiften/Parser/UnitTest/XMPPParserTest.cpp b/Swiften/Parser/UnitTest/XMPPParserTest.cpp
index 1266350..a4cb7b8 100644
--- a/Swiften/Parser/UnitTest/XMPPParserTest.cpp
+++ b/Swiften/Parser/UnitTest/XMPPParserTest.cpp
@@ -25,173 +25,173 @@
using namespace Swift;
class XMPPParserTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(XMPPParserTest);
- CPPUNIT_TEST(testParse_SimpleSession);
- CPPUNIT_TEST(testParse_SimpleClientFromServerSession);
- CPPUNIT_TEST(testParse_Presence);
- CPPUNIT_TEST(testParse_IQ);
- CPPUNIT_TEST(testParse_Message);
- CPPUNIT_TEST(testParse_StreamFeatures);
- CPPUNIT_TEST(testParse_UnknownElement);
- CPPUNIT_TEST(testParse_StrayCharacterData);
- CPPUNIT_TEST(testParse_InvalidStreamStart);
- CPPUNIT_TEST(testParse_ElementEndAfterInvalidStreamStart);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- void testParse_SimpleSession() {
- XMPPParser testling(&client_, &factories_, &xmlParserFactory_);
-
- CPPUNIT_ASSERT(testling.parse("<?xml version='1.0'?>"));
- CPPUNIT_ASSERT(testling.parse("<stream:stream to='example.com' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' >"));
- CPPUNIT_ASSERT(testling.parse("<presence/>"));
- CPPUNIT_ASSERT(testling.parse("<presence/>"));
- CPPUNIT_ASSERT(testling.parse("<iq/>"));
- CPPUNIT_ASSERT(testling.parse("</stream:stream>"));
-
- CPPUNIT_ASSERT_EQUAL(5, static_cast<int>(client_.events.size()));
- CPPUNIT_ASSERT_EQUAL(Client::StreamStart, client_.events[0].type);
- CPPUNIT_ASSERT_EQUAL(std::string("example.com"), client_.events[0].header->getTo());
- CPPUNIT_ASSERT_EQUAL(Client::ElementEvent, client_.events[1].type);
- CPPUNIT_ASSERT_EQUAL(Client::ElementEvent, client_.events[2].type);
- CPPUNIT_ASSERT_EQUAL(Client::ElementEvent, client_.events[3].type);
- CPPUNIT_ASSERT_EQUAL(Client::StreamEnd, client_.events[4].type);
- }
-
- void testParse_SimpleClientFromServerSession() {
- XMPPParser testling(&client_, &factories_, &xmlParserFactory_);
-
- CPPUNIT_ASSERT(testling.parse("<?xml version='1.0'?>"));
- CPPUNIT_ASSERT(testling.parse("<stream:stream from='example.com' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='aeab'>"));
-
- CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(client_.events.size()));
- CPPUNIT_ASSERT_EQUAL(Client::StreamStart, client_.events[0].type);
- CPPUNIT_ASSERT_EQUAL(std::string("example.com"), client_.events[0].header->getFrom());
- CPPUNIT_ASSERT_EQUAL(std::string("aeab"), client_.events[0].header->getID());
- }
-
-
- void testParse_Presence() {
- XMPPParser testling(&client_, &factories_, &xmlParserFactory_);
-
- CPPUNIT_ASSERT(testling.parse("<stream:stream xmlns:stream='http://etherx.jabber.org/streams'>"));
- CPPUNIT_ASSERT(testling.parse("<presence/>"));
-
- CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(client_.events.size()));
- CPPUNIT_ASSERT_EQUAL(Client::ElementEvent, client_.events[1].type);
- CPPUNIT_ASSERT(dynamic_cast<Presence*>(client_.events[1].element.get()));
- }
-
- void testParse_IQ() {
- XMPPParser testling(&client_, &factories_, &xmlParserFactory_);
-
- CPPUNIT_ASSERT(testling.parse("<stream:stream xmlns:stream='http://etherx.jabber.org/streams'>"));
- CPPUNIT_ASSERT(testling.parse("<iq/>"));
-
- CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(client_.events.size()));
- CPPUNIT_ASSERT_EQUAL(Client::ElementEvent, client_.events[1].type);
- CPPUNIT_ASSERT(dynamic_cast<IQ*>(client_.events[1].element.get()));
- }
-
- void testParse_Message() {
- XMPPParser testling(&client_, &factories_, &xmlParserFactory_);
-
- CPPUNIT_ASSERT(testling.parse("<stream:stream xmlns:stream='http://etherx.jabber.org/streams'>"));
- CPPUNIT_ASSERT(testling.parse("<message/>"));
-
- CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(client_.events.size()));
- CPPUNIT_ASSERT_EQUAL(Client::ElementEvent, client_.events[1].type);
- CPPUNIT_ASSERT(dynamic_cast<Message*>(client_.events[1].element.get()));
- }
-
- void testParse_StreamFeatures() {
- XMPPParser testling(&client_, &factories_, &xmlParserFactory_);
-
- CPPUNIT_ASSERT(testling.parse("<stream:stream xmlns:stream='http://etherx.jabber.org/streams'>"));
- CPPUNIT_ASSERT(testling.parse("<stream:features/>"));
-
- CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(client_.events.size()));
- CPPUNIT_ASSERT_EQUAL(Client::ElementEvent, client_.events[1].type);
- CPPUNIT_ASSERT(dynamic_cast<StreamFeatures*>(client_.events[1].element.get()));
- }
-
- void testParse_UnknownElement() {
- XMPPParser testling(&client_, &factories_, &xmlParserFactory_);
-
- CPPUNIT_ASSERT(testling.parse("<stream:stream xmlns:stream='http://etherx.jabber.org/streams'>"));
- CPPUNIT_ASSERT(testling.parse("<presence/>"));
- CPPUNIT_ASSERT(testling.parse("<foo/>"));
- CPPUNIT_ASSERT(testling.parse("<bar/>"));
- CPPUNIT_ASSERT(testling.parse("<presence/>"));
-
- CPPUNIT_ASSERT_EQUAL(5, static_cast<int>(client_.events.size()));
- CPPUNIT_ASSERT_EQUAL(Client::ElementEvent, client_.events[2].type);
- CPPUNIT_ASSERT(dynamic_cast<UnknownElement*>(client_.events[2].element.get()));
- CPPUNIT_ASSERT_EQUAL(Client::ElementEvent, client_.events[3].type);
- CPPUNIT_ASSERT(dynamic_cast<UnknownElement*>(client_.events[3].element.get()));
- CPPUNIT_ASSERT_EQUAL(Client::ElementEvent, client_.events[4].type);
- CPPUNIT_ASSERT(dynamic_cast<Presence*>(client_.events[4].element.get()));
- }
-
- void testParse_StrayCharacterData() {
- XMPPParser testling(&client_, &factories_, &xmlParserFactory_);
-
- CPPUNIT_ASSERT(testling.parse("<stream:stream xmlns:stream='http://etherx.jabber.org/streams'>"));
- CPPUNIT_ASSERT(testling.parse("<presence/>"));
- CPPUNIT_ASSERT(testling.parse("bla"));
- CPPUNIT_ASSERT(testling.parse("<iq/>"));
-
- CPPUNIT_ASSERT_EQUAL(3, static_cast<int>(client_.events.size()));
- CPPUNIT_ASSERT_EQUAL(Client::ElementEvent, client_.events[2].type);
- CPPUNIT_ASSERT(dynamic_cast<IQ*>(client_.events[2].element.get()));
- }
-
- void testParse_InvalidStreamStart() {
- XMPPParser testling(&client_, &factories_, &xmlParserFactory_);
-
- CPPUNIT_ASSERT(!testling.parse("<tream>"));
- }
-
- void testParse_ElementEndAfterInvalidStreamStart() {
- XMPPParser testling(&client_, &factories_, &xmlParserFactory_);
+ CPPUNIT_TEST_SUITE(XMPPParserTest);
+ CPPUNIT_TEST(testParse_SimpleSession);
+ CPPUNIT_TEST(testParse_SimpleClientFromServerSession);
+ CPPUNIT_TEST(testParse_Presence);
+ CPPUNIT_TEST(testParse_IQ);
+ CPPUNIT_TEST(testParse_Message);
+ CPPUNIT_TEST(testParse_StreamFeatures);
+ CPPUNIT_TEST(testParse_UnknownElement);
+ CPPUNIT_TEST(testParse_StrayCharacterData);
+ CPPUNIT_TEST(testParse_InvalidStreamStart);
+ CPPUNIT_TEST(testParse_ElementEndAfterInvalidStreamStart);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void testParse_SimpleSession() {
+ XMPPParser testling(&client_, &factories_, &xmlParserFactory_);
+
+ CPPUNIT_ASSERT(testling.parse("<?xml version='1.0'?>"));
+ CPPUNIT_ASSERT(testling.parse("<stream:stream to='example.com' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' >"));
+ CPPUNIT_ASSERT(testling.parse("<presence/>"));
+ CPPUNIT_ASSERT(testling.parse("<presence/>"));
+ CPPUNIT_ASSERT(testling.parse("<iq/>"));
+ CPPUNIT_ASSERT(testling.parse("</stream:stream>"));
+
+ CPPUNIT_ASSERT_EQUAL(5, static_cast<int>(client_.events.size()));
+ CPPUNIT_ASSERT_EQUAL(Client::StreamStart, client_.events[0].type);
+ CPPUNIT_ASSERT_EQUAL(std::string("example.com"), client_.events[0].header->getTo());
+ CPPUNIT_ASSERT_EQUAL(Client::ElementEvent, client_.events[1].type);
+ CPPUNIT_ASSERT_EQUAL(Client::ElementEvent, client_.events[2].type);
+ CPPUNIT_ASSERT_EQUAL(Client::ElementEvent, client_.events[3].type);
+ CPPUNIT_ASSERT_EQUAL(Client::StreamEnd, client_.events[4].type);
+ }
+
+ void testParse_SimpleClientFromServerSession() {
+ XMPPParser testling(&client_, &factories_, &xmlParserFactory_);
+
+ CPPUNIT_ASSERT(testling.parse("<?xml version='1.0'?>"));
+ CPPUNIT_ASSERT(testling.parse("<stream:stream from='example.com' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='aeab'>"));
+
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(client_.events.size()));
+ CPPUNIT_ASSERT_EQUAL(Client::StreamStart, client_.events[0].type);
+ CPPUNIT_ASSERT_EQUAL(std::string("example.com"), client_.events[0].header->getFrom());
+ CPPUNIT_ASSERT_EQUAL(std::string("aeab"), client_.events[0].header->getID());
+ }
+
+
+ void testParse_Presence() {
+ XMPPParser testling(&client_, &factories_, &xmlParserFactory_);
+
+ CPPUNIT_ASSERT(testling.parse("<stream:stream xmlns:stream='http://etherx.jabber.org/streams'>"));
+ CPPUNIT_ASSERT(testling.parse("<presence/>"));
+
+ CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(client_.events.size()));
+ CPPUNIT_ASSERT_EQUAL(Client::ElementEvent, client_.events[1].type);
+ CPPUNIT_ASSERT(dynamic_cast<Presence*>(client_.events[1].element.get()));
+ }
+
+ void testParse_IQ() {
+ XMPPParser testling(&client_, &factories_, &xmlParserFactory_);
+
+ CPPUNIT_ASSERT(testling.parse("<stream:stream xmlns:stream='http://etherx.jabber.org/streams'>"));
+ CPPUNIT_ASSERT(testling.parse("<iq/>"));
+
+ CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(client_.events.size()));
+ CPPUNIT_ASSERT_EQUAL(Client::ElementEvent, client_.events[1].type);
+ CPPUNIT_ASSERT(dynamic_cast<IQ*>(client_.events[1].element.get()));
+ }
+
+ void testParse_Message() {
+ XMPPParser testling(&client_, &factories_, &xmlParserFactory_);
+
+ CPPUNIT_ASSERT(testling.parse("<stream:stream xmlns:stream='http://etherx.jabber.org/streams'>"));
+ CPPUNIT_ASSERT(testling.parse("<message/>"));
+
+ CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(client_.events.size()));
+ CPPUNIT_ASSERT_EQUAL(Client::ElementEvent, client_.events[1].type);
+ CPPUNIT_ASSERT(dynamic_cast<Message*>(client_.events[1].element.get()));
+ }
+
+ void testParse_StreamFeatures() {
+ XMPPParser testling(&client_, &factories_, &xmlParserFactory_);
+
+ CPPUNIT_ASSERT(testling.parse("<stream:stream xmlns:stream='http://etherx.jabber.org/streams'>"));
+ CPPUNIT_ASSERT(testling.parse("<stream:features/>"));
+
+ CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(client_.events.size()));
+ CPPUNIT_ASSERT_EQUAL(Client::ElementEvent, client_.events[1].type);
+ CPPUNIT_ASSERT(dynamic_cast<StreamFeatures*>(client_.events[1].element.get()));
+ }
+
+ void testParse_UnknownElement() {
+ XMPPParser testling(&client_, &factories_, &xmlParserFactory_);
+
+ CPPUNIT_ASSERT(testling.parse("<stream:stream xmlns:stream='http://etherx.jabber.org/streams'>"));
+ CPPUNIT_ASSERT(testling.parse("<presence/>"));
+ CPPUNIT_ASSERT(testling.parse("<foo/>"));
+ CPPUNIT_ASSERT(testling.parse("<bar/>"));
+ CPPUNIT_ASSERT(testling.parse("<presence/>"));
+
+ CPPUNIT_ASSERT_EQUAL(5, static_cast<int>(client_.events.size()));
+ CPPUNIT_ASSERT_EQUAL(Client::ElementEvent, client_.events[2].type);
+ CPPUNIT_ASSERT(dynamic_cast<UnknownElement*>(client_.events[2].element.get()));
+ CPPUNIT_ASSERT_EQUAL(Client::ElementEvent, client_.events[3].type);
+ CPPUNIT_ASSERT(dynamic_cast<UnknownElement*>(client_.events[3].element.get()));
+ CPPUNIT_ASSERT_EQUAL(Client::ElementEvent, client_.events[4].type);
+ CPPUNIT_ASSERT(dynamic_cast<Presence*>(client_.events[4].element.get()));
+ }
+
+ void testParse_StrayCharacterData() {
+ XMPPParser testling(&client_, &factories_, &xmlParserFactory_);
+
+ CPPUNIT_ASSERT(testling.parse("<stream:stream xmlns:stream='http://etherx.jabber.org/streams'>"));
+ CPPUNIT_ASSERT(testling.parse("<presence/>"));
+ CPPUNIT_ASSERT(testling.parse("bla"));
+ CPPUNIT_ASSERT(testling.parse("<iq/>"));
+
+ CPPUNIT_ASSERT_EQUAL(3, static_cast<int>(client_.events.size()));
+ CPPUNIT_ASSERT_EQUAL(Client::ElementEvent, client_.events[2].type);
+ CPPUNIT_ASSERT(dynamic_cast<IQ*>(client_.events[2].element.get()));
+ }
+
+ void testParse_InvalidStreamStart() {
+ XMPPParser testling(&client_, &factories_, &xmlParserFactory_);
+
+ CPPUNIT_ASSERT(!testling.parse("<tream>"));
+ }
+
+ void testParse_ElementEndAfterInvalidStreamStart() {
+ XMPPParser testling(&client_, &factories_, &xmlParserFactory_);
- CPPUNIT_ASSERT(!testling.parse("<tream/>"));
- }
+ CPPUNIT_ASSERT(!testling.parse("<tream/>"));
+ }
- private:
- class Client : public XMPPParserClient {
- public:
- enum Type { StreamStart, ElementEvent, StreamEnd };
- struct Event {
- Event(Type type, boost::shared_ptr<ToplevelElement> element)
- : type(type), element(element) {}
- Event(Type type, const ProtocolHeader& header) : type(type), header(header) {}
+ private:
+ class Client : public XMPPParserClient {
+ public:
+ enum Type { StreamStart, ElementEvent, StreamEnd };
+ struct Event {
+ Event(Type type, boost::shared_ptr<ToplevelElement> element)
+ : type(type), element(element) {}
+ Event(Type type, const ProtocolHeader& header) : type(type), header(header) {}
- Event(Type type) : type(type) {}
+ Event(Type type) : type(type) {}
- Type type;
- boost::optional<ProtocolHeader> header;
- boost::shared_ptr<ToplevelElement> element;
- };
+ Type type;
+ boost::optional<ProtocolHeader> header;
+ boost::shared_ptr<ToplevelElement> element;
+ };
- Client() {}
-
- void handleStreamStart(const ProtocolHeader& header) {
- events.push_back(Event(StreamStart, header));
- }
-
- void handleElement(boost::shared_ptr<ToplevelElement> element) {
- events.push_back(Event(ElementEvent, element));
- }
-
- void handleStreamEnd() {
- events.push_back(Event(StreamEnd));
- }
-
- std::vector<Event> events;
- } client_;
- PayloadParserFactoryCollection factories_;
- PlatformXMLParserFactory xmlParserFactory_;
+ Client() {}
+
+ void handleStreamStart(const ProtocolHeader& header) {
+ events.push_back(Event(StreamStart, header));
+ }
+
+ void handleElement(boost::shared_ptr<ToplevelElement> element) {
+ events.push_back(Event(ElementEvent, element));
+ }
+
+ void handleStreamEnd() {
+ events.push_back(Event(StreamEnd));
+ }
+
+ std::vector<Event> events;
+ } client_;
+ PayloadParserFactoryCollection factories_;
+ PlatformXMLParserFactory xmlParserFactory_;
};
CPPUNIT_TEST_SUITE_REGISTRATION(XMPPParserTest);