summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Parser/UnitTest')
-rw-r--r--Swiften/Parser/UnitTest/EnumParserTest.cpp36
-rw-r--r--Swiften/Parser/UnitTest/GenericPayloadTreeParserTest.cpp8
-rw-r--r--Swiften/Parser/UnitTest/StanzaParserTest.cpp4
-rw-r--r--Swiften/Parser/UnitTest/XMLParserTest.cpp7
-rw-r--r--Swiften/Parser/UnitTest/XMPPParserTest.cpp8
5 files changed, 57 insertions, 6 deletions
diff --git a/Swiften/Parser/UnitTest/EnumParserTest.cpp b/Swiften/Parser/UnitTest/EnumParserTest.cpp
new file mode 100644
index 0000000..44a30c0
--- /dev/null
+++ b/Swiften/Parser/UnitTest/EnumParserTest.cpp
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2013 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+
+#include <Swiften/Parser/EnumParser.h>
+
+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_REGISTRATION(EnumParserTest);
diff --git a/Swiften/Parser/UnitTest/GenericPayloadTreeParserTest.cpp b/Swiften/Parser/UnitTest/GenericPayloadTreeParserTest.cpp
index d095afc..93d4e7f 100644
--- a/Swiften/Parser/UnitTest/GenericPayloadTreeParserTest.cpp
+++ b/Swiften/Parser/UnitTest/GenericPayloadTreeParserTest.cpp
@@ -8,4 +8,5 @@
#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <Swiften/Base/Platform.h>
#include <Swiften/Parser/GenericPayloadTreeParser.h>
#include <Swiften/Parser/PayloadParsers/UnitTest/PayloadParserTester.h>
@@ -14,4 +15,11 @@
using namespace Swift;
+
+#if !SWIFTEN_STATIC && defined(SWIFTEN_PLATFORM_WINDOWS)
+// This base class of a class used in this file is already exported, so need to
+// explicitly import it.
+template class __declspec(dllimport) Swift::GenericPayloadParser<RawXMLPayload>;
+#endif
+
class GenericPayloadTreeParserTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(GenericPayloadTreeParserTest);
diff --git a/Swiften/Parser/UnitTest/StanzaParserTest.cpp b/Swiften/Parser/UnitTest/StanzaParserTest.cpp
index 88e6dec..020f0ca 100644
--- a/Swiften/Parser/UnitTest/StanzaParserTest.cpp
+++ b/Swiften/Parser/UnitTest/StanzaParserTest.cpp
@@ -1,4 +1,4 @@
/*
- * Copyright (c) 2010 Remko Tronçon
+ * Copyright (c) 2010-2014 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
@@ -197,5 +197,5 @@ class StanzaParserTest : public CppUnit::TestFixture {
}
- virtual boost::shared_ptr<Element> getElement() const {
+ virtual boost::shared_ptr<ToplevelElement> getElement() const {
return stanza_;
}
diff --git a/Swiften/Parser/UnitTest/XMLParserTest.cpp b/Swiften/Parser/UnitTest/XMLParserTest.cpp
index 3c84220..4bdeb54 100644
--- a/Swiften/Parser/UnitTest/XMLParserTest.cpp
+++ b/Swiften/Parser/UnitTest/XMLParserTest.cpp
@@ -36,4 +36,5 @@ class XMLParserTest : public CppUnit::TestFixture {
CPPUNIT_TEST(testParse_AttributeWithNamespace);
CPPUNIT_TEST(testParse_BillionLaughs);
+ CPPUNIT_TEST(testParse_InternalEntity);
//CPPUNIT_TEST(testParse_UndefinedPrefix);
//CPPUNIT_TEST(testParse_UndefinedAttributePrefix);
@@ -275,4 +276,10 @@ class XMLParserTest : public CppUnit::TestFixture {
}
+ void testParse_InternalEntity() {
+ ParserType testling(&client_);
+
+ CPPUNIT_ASSERT(!testling.parse("<!DOCTYPE foo [<!ENTITY bar \"Bar\">]><foo>&bar;</foo>"));
+ }
+
void testParse_UndefinedPrefix() {
ParserType testling(&client_);
diff --git a/Swiften/Parser/UnitTest/XMPPParserTest.cpp b/Swiften/Parser/UnitTest/XMPPParserTest.cpp
index f8d60f2..7d2d3fa 100644
--- a/Swiften/Parser/UnitTest/XMPPParserTest.cpp
+++ b/Swiften/Parser/UnitTest/XMPPParserTest.cpp
@@ -1,4 +1,4 @@
/*
- * Copyright (c) 2010 Remko Tronçon
+ * Copyright (c) 2010-2014 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
@@ -163,5 +163,5 @@ class XMPPParserTest : public CppUnit::TestFixture {
enum Type { StreamStart, ElementEvent, StreamEnd };
struct Event {
- Event(Type type, boost::shared_ptr<Element> element)
+ Event(Type type, boost::shared_ptr<ToplevelElement> element)
: type(type), element(element) {}
Event(Type type, const ProtocolHeader& header) : type(type), header(header) {}
@@ -171,5 +171,5 @@ class XMPPParserTest : public CppUnit::TestFixture {
Type type;
boost::optional<ProtocolHeader> header;
- boost::shared_ptr<Element> element;
+ boost::shared_ptr<ToplevelElement> element;
};
@@ -180,5 +180,5 @@ class XMPPParserTest : public CppUnit::TestFixture {
}
- void handleElement(boost::shared_ptr<Element> element) {
+ void handleElement(boost::shared_ptr<ToplevelElement> element) {
events.push_back(Event(ElementEvent, element));
}