summaryrefslogtreecommitdiff
path: root/include/cppunit/extensions/TestFactoryRegistry.h
diff options
context:
space:
mode:
authorBastiaan Bakker <bastiaan.bakker@lifeline.nl>2001-04-29 13:09:16 +0000
committerBastiaan Bakker <bastiaan.bakker@lifeline.nl>2001-04-29 13:09:16 +0000
commitb08ecaecc1e39b7b01e02b7b73559d8b34ff46a5 (patch)
treebf1ed1e3680cb0256e73336e22fb70c692524fcb /include/cppunit/extensions/TestFactoryRegistry.h
parent5ce1a68589aa3ea4f9ee255cfecc94cc1730c6fa (diff)
downloadcppunit-b08ecaecc1e39b7b01e02b7b73559d8b34ff46a5.tar.gz
Merged Baptiste Lepilleurs CppUnitW 1.2.
Some differences: TypeInfo stuff (in TestSuite) compiled in only if USE_TYPEINFO is set. TestSuite.getTests now returns a const ref instead of taking a ref as param. Removed auto_ptr stuff from TestFactoryRegistry: auto_ptr cannot be used in containers.
Diffstat (limited to 'include/cppunit/extensions/TestFactoryRegistry.h')
-rw-r--r--include/cppunit/extensions/TestFactoryRegistry.h80
1 files changed, 80 insertions, 0 deletions
diff --git a/include/cppunit/extensions/TestFactoryRegistry.h b/include/cppunit/extensions/TestFactoryRegistry.h
new file mode 100644
index 0000000..fac97ec
--- /dev/null
+++ b/include/cppunit/extensions/TestFactoryRegistry.h
@@ -0,0 +1,80 @@
+#ifndef CPPUNIT_TESTFACTORYREGISTRY_H
+#define CPPUNIT_TESTFACTORYREGISTRY_H
+
+#include <map>
+#include <string>
+#include "cppunit/extensions/AbstractTestFactory.h"
+
+namespace CppUnit {
+
+ class TestSuite;
+
+ /** This class implements a registry for test factory.
+ *
+ * Note that the registry assume lifetime control for any registered test.
+ */
+ class TestFactoryRegistry : public AbstractTestFactory
+ {
+ public:
+ /** Constructs the registry with the specified name.
+ * \param name Name of the registry.
+ */
+ TestFactoryRegistry( std::string name = "All Tests" );
+
+ /// Destructor.
+ virtual ~TestFactoryRegistry();
+
+ /** Makes a suite containing all the registered test.
+ * \return A new suite containing all the registered test.
+ */
+ virtual Test *makeTest();
+
+ /** Returns the registry.
+ * \return Registry.
+ */
+ static TestFactoryRegistry &getRegistry();
+
+ /** Returns a named registry.
+ * \param name Name of the registry to return.
+ * \return Registry. If the registry does not exist, it is created.
+ */
+ static TestFactoryRegistry &getRegistry( const std::string &name );
+
+ /** Adds the registered test to the specified suite.
+ * \param suite Suite the test are added to.
+ */
+ void addTestToSuite( TestSuite *suite );
+
+ /** Registers a test factory with the specified name.
+ * \param name Name associated to the factory.
+ * \param factory Factory to register.
+ */
+ void registerFactory( const std::string &name,
+ AbstractTestFactory *factory );
+
+#ifdef USE_TYPEINFO
+ /** Registers a test factory using its class name.
+ * \param factory Factory to register.
+ */
+ void registerFactory( AbstractTestFactory *factory );
+#endif // USE_TYPEINFO
+
+ private:
+ TestFactoryRegistry( const TestFactoryRegistry &copy );
+ void operator =( const TestFactoryRegistry &copy );
+
+ private:
+ typedef std::map<std::string, AbstractTestFactory*> Factories;
+ Factories m_factories;
+
+ typedef std::map<std::string, TestFactoryRegistry*> NamedRegistries;
+
+ std::string m_name;
+ };
+
+
+
+} // namespace CppUnit
+
+
+#endif // CPPUNIT_TESTFACTORYREGISTRY_H