summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Parser/UnitTest/PayloadParserFactoryCollectionTest.cpp')
m---------Swiften0
-rw-r--r--Swiften/Parser/UnitTest/PayloadParserFactoryCollectionTest.cpp97
2 files changed, 0 insertions, 97 deletions
diff --git a/Swiften b/Swiften
new file mode 160000
+Subproject 8213ba16d0043d2461f4b031c881d61dda5a38c
diff --git a/Swiften/Parser/UnitTest/PayloadParserFactoryCollectionTest.cpp b/Swiften/Parser/UnitTest/PayloadParserFactoryCollectionTest.cpp
deleted file mode 100644
index bfd2c2c..0000000
--- a/Swiften/Parser/UnitTest/PayloadParserFactoryCollectionTest.cpp
+++ /dev/null
@@ -1,97 +0,0 @@
-#include <cppunit/extensions/HelperMacros.h>
-#include <cppunit/extensions/TestFactoryRegistry.h>
-
-#include "Swiften/Parser/PayloadParserFactoryCollection.h"
-#include "Swiften/Parser/PayloadParserFactory.h"
-
-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 String& element = "") : element(element) {}
- virtual bool canParse(const String& e, const String&, const AttributeMap&) const {
- return element.isEmpty() ? true : element == e;
- }
- virtual PayloadParser* createPayloadParser() { return NULL; }
- String element;
- };
-};
-
-CPPUNIT_TEST_SUITE_REGISTRATION(PayloadParserFactoryCollectionTest);