summaryrefslogtreecommitdiff
path: root/include/cppunit
diff options
context:
space:
mode:
authorBaptiste Lepilleur <gaiacrtn@free.fr>2002-04-15 14:33:11 +0000
committerBaptiste Lepilleur <gaiacrtn@free.fr>2002-04-15 14:33:11 +0000
commit1b4bcf6f703248cb397587fe08635a1491d460ec (patch)
treee0ae81d803807027d7b4a6f14d9c39da2321dd47 /include/cppunit
parent5f5af41d52c01c8320baffea21cd60ebbb16380b (diff)
downloadcppunit-1b4bcf6f703248cb397587fe08635a1491d460ec.tar.gz
NEWS: updated.
NEWS: updated. * configure.in: added include/cppunit/config/Makefile and include/cppunit/plugin/Makefile to the list of target. * doc/CppUnit-win.dox: enabled generation of HTML Help documentation. * include/cppunit/config/Makefile.am: * include/cppunit/plugin/Makefile.am: added. * include/cppunit/config-bcb5.h: * include/cppunit/config-msvc6.h: * include/cppunit/config-mac.h: moved to include/cppunit/config/. * include/cppunit/Portability.h: updated config files location. Added macros CPPUNIT_STRINGIZE and CPPUNIT_JOIN (implementation adapted from boost.org). Added macro CPPUNIT_MAKE_UNIQUE_NAME. * include/cppunit/Test.h: modified methods order. * include/cppunit/extensions/HelperMacros.h: renamed macro __CPPUNIT_MAKE_UNIQUE_NAME to CPPUNIT_MAKE_UNIQUE_NAME and moved its definition to include/cppunit/Portability.h. * include/cppunit/extensions/TestDecorator.h: Inherits Test instead of TestLeaf. * include/cppunit/plugin/DynamicLibraryManager.h: * src/cppunit/DynamicLibraryManager.cpp: added. DLL manager (load & lookup symbol). * src/cppunit/BeOsDynamicLibraryManager.cpp: * src/cppunit/UnixDynamicLibraryManager.cpp: * src/cppunit/Win32DynamicLibraryManager.cpp: added. Implementation of platform dependent methods of DynamicLibraryManager. * include/cppunit/plugin/DynamicLibraryManagerException.h: * src/cppunit/DynamicLibraryManagerException.cpp: added. Exception thrown by DynamicLibraryManager. * include/cppunit/plugin/TestPlugIn.h: added. CppUnitTestPlugIn interface definition. Helper macros to implements plug-in. * include/cppunit/plugin/TestPlugInSuite.h: * src/cppunit/plugin/TestPlugInSuite.cpp: added. A suite to wrap a test plug-in. * include/cppunit/plugin/TestPlugInDefaultImpl.h: * src/cppunit/TestPlugInDefaultImpl.cpp: added. A default implementation of the test plug-in interface. * src/msvc6/DllPlugInTester/DllPlugInTester.cpp: updated to use the new TestPlugIn. * examples/cppunittest/TestResultCollectorTest.cpp: fixed typo.
Diffstat (limited to 'include/cppunit')
-rw-r--r--include/cppunit/Makefile.am2
-rw-r--r--include/cppunit/Portability.h56
-rw-r--r--include/cppunit/Test.h14
-rw-r--r--include/cppunit/config/Makefile.am7
-rw-r--r--include/cppunit/config/SelectDllLoader.h72
-rw-r--r--include/cppunit/config/config-bcb5.h (renamed from include/cppunit/config-bcb5.h)0
-rw-r--r--include/cppunit/config/config-mac.h (renamed from include/cppunit/config-mac.h)0
-rw-r--r--include/cppunit/config/config-msvc6.h (renamed from include/cppunit/config-msvc6.h)0
-rw-r--r--include/cppunit/extensions/HelperMacros.h14
-rw-r--r--include/cppunit/extensions/TestDecorator.h24
-rw-r--r--include/cppunit/plugin/DynamicLibraryManager.h114
-rw-r--r--include/cppunit/plugin/DynamicLibraryManagerException.h49
-rw-r--r--include/cppunit/plugin/Makefile.am8
-rw-r--r--include/cppunit/plugin/TestPlugIn.h153
-rw-r--r--include/cppunit/plugin/TestPlugInDefaultImpl.h50
-rw-r--r--include/cppunit/plugin/TestPlugInSuite.h54
16 files changed, 594 insertions, 23 deletions
diff --git a/include/cppunit/Makefile.am b/include/cppunit/Makefile.am
index ef1e8a3..5d4901a 100644
--- a/include/cppunit/Makefile.am
+++ b/include/cppunit/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = extensions ui
+SUBDIRS = extensions ui plugin config
DISTCLEANFILES = config-auto.h
diff --git a/include/cppunit/Portability.h b/include/cppunit/Portability.h
index 1661da0..2584934 100644
--- a/include/cppunit/Portability.h
+++ b/include/cppunit/Portability.h
@@ -3,13 +3,15 @@
/* include platform specific config */
#if defined(__BORLANDC__)
-# include <cppunit/config-bcb5.h>
+# include <cppunit/config/config-bcb5.h>
#elif defined (_MSC_VER)
-# include <cppunit/config-msvc6.h>
+# include <cppunit/config/config-msvc6.h>
#else
# include <cppunit/config-auto.h>
#endif
+#include <cppunit/config/SelectDllLoader.h>
+
/* Options that the library user may switch on or off.
* If the user has not done so, we chose default values.
@@ -49,6 +51,55 @@
#define CPPUNIT_COMPILER_LOCATION_FORMAT "%f:%l:"
#endif
+
+/*! Stringize a symbol.
+ *
+ * Use this macro to convert a preprocessor symbol to a string.
+ *
+ * Example of usage:
+ * \code
+ * #define CPPUNIT_PLUGIN_EXPORTED_NAME cppunitTestPlugIn
+ * const char *name = CPPUNIT_STRINGIZE( CPPUNIT_PLUGIN_EXPORTED_NAME );
+ * \endcode
+ */
+#define CPPUNIT_STRINGIZE( symbol ) _CPPUNIT_DO_STRINGIZE( symbol )
+
+/// \internal
+#define _CPPUNIT_DO_STRINGIZE( symbol ) #symbol
+
+/*! Joins to symbol after expanding them into string.
+ *
+ * Use this macro to join two symbols. Example of usage:
+ *
+ * \code
+ * #define MAKE_UNIQUE_NAME(prefix) CPPUNIT_JOIN( prefix, __LINE__ )
+ * \endcode
+ *
+ * The macro defined in the example concatenate a given prefix with the line number
+ * to obtain a 'unique' identifier.
+ *
+ * \internal From boost documentation:
+ * The following piece of macro magic joins the two
+ * arguments together, even when one of the arguments is
+ * itself a macro (see 16.3.1 in C++ standard). The key
+ * is that macro expansion of macro arguments does not
+ * occur in CPPUNIT_JOIN2 but does in CPPUNIT_JOIN.
+ */
+#define CPPUNIT_JOIN( symbol1, symbol2 ) _CPPUNIT_DO_JOIN( symbol1, symbol2 )
+
+/// \internal
+#define _CPPUNIT_DO_JOIN( symbol1, symbol2 ) _CPPUNIT_DO_JOIN2( symbol1, symbol2 )
+
+/// \internal
+#define _CPPUNIT_DO_JOIN2( symbol1, symbol2 ) symbol1##symbol2
+
+/*! Adds the line number to the specified string to create a unique identifier.
+ * \param prefix Prefix added to the line number to create a unique identifier.
+ * \see CPPUNIT_TEST_SUITE_REGISTRATION for an example of usage.
+ */
+#define CPPUNIT_MAKE_UNIQUE_NAME( prefix ) CPPUNIT_JOIN( prefix, __LINE__ )
+
+
/* perform portability hacks */
@@ -89,4 +140,5 @@
#endif
#endif
+
#endif // CPPUNIT_PORTABILITY_H
diff --git a/include/cppunit/Test.h b/include/cppunit/Test.h
index 0ed98f9..e457ca1 100644
--- a/include/cppunit/Test.h
+++ b/include/cppunit/Test.h
@@ -42,13 +42,6 @@ public:
*/
virtual int getChildTestCount() const =0;
- /*! \brief Returns the test name.
- *
- * Each test has a name. This name may be used to find the
- * test in a suite or registry of tests.
- */
- virtual std::string getName () const =0;
-
/*! \brief Returns the child test of the specified index.
*
* This method test if the index is valid, then call doGetChildTestAt() if
@@ -62,6 +55,13 @@ public:
*/
virtual Test *getChildTestAt( int index ) const;
+ /*! \brief Returns the test name.
+ *
+ * Each test has a name. This name may be used to find the
+ * test in a suite or registry of tests.
+ */
+ virtual std::string getName () const =0;
+
/*! \brief Finds the test with the specified name and its parents test.
* \param testName Name of the test to find.
* \param testPath If the test is found, then all the tests traversed to access
diff --git a/include/cppunit/config/Makefile.am b/include/cppunit/config/Makefile.am
new file mode 100644
index 0000000..10c3608
--- /dev/null
+++ b/include/cppunit/config/Makefile.am
@@ -0,0 +1,7 @@
+libcppunitincludedir = $(includedir)/cppunit/config
+
+libcppunitinclude_HEADERS = \
+ config-bcb5.h \
+ config-mac.h \
+ config-msvc6.h \
+ SelectDllLoader.h
diff --git a/include/cppunit/config/SelectDllLoader.h b/include/cppunit/config/SelectDllLoader.h
new file mode 100644
index 0000000..74d5fbb
--- /dev/null
+++ b/include/cppunit/config/SelectDllLoader.h
@@ -0,0 +1,72 @@
+#ifndef CPPUNIT_CONFIG_SELECTDLLLOADER_H
+#define CPPUNIT_CONFIG_SELECTDLLLOADER_H
+
+/*! \file
+ * Selects DynamicLibraryManager implementation.
+ *
+ * Don't include this file directly. Include Portability.h instead.
+ */
+
+/*!
+ * \def CPPUNIT_NO_TESTPLUGIN
+ * \brief If defined, then plug-in related classes and functions will not be compiled.
+ *
+ * \internal
+ * CPPUNIT_HAVE_WIN32_DLL_LOADER
+ * If defined, Win32 implementation of DynamicLibraryManager will be used.
+ *
+ * CPPUNIT_HAVE_BEOS_DLL_LOADER
+ * If defined, BeOs implementation of DynamicLibraryManager will be used.
+ *
+ * CPPUNIT_HAVE_UNIX_DLL_LOADER
+ * If defined, Unix implementation (dlfcn.h) of DynamicLibraryManager will be used.
+ */
+
+/*!
+ * \def CPPUNIT_PLUGIN_EXPORT
+ * \ingroup WritingTestPlugIn
+ * \brief A macro to export a function from a dynamic library
+ *
+ * This macro export the C function following it from a dynamic library.
+ * Exporting the function makes it accessible to the DynamicLibraryManager.
+ *
+ * Example of usage:
+ * \code
+ * #include <cppunit/include/plugin/TestPlugIn.h>
+ *
+ * CPPUNIT_PLUGIN_EXPORT CppUnitTestPlugIn *CPPUNIT_PLUGIN_EXPORTED_NAME(void)
+ * {
+ * ...
+ * return &myPlugInInterface;
+ * }
+ * \endcode
+ */
+
+#if !defined(CPPUNIT_NO_TESTPLUGIN)
+
+// Is WIN32 platform ?
+#if defined(WIN32)
+#define CPPUNIT_HAVE_WIN32_DLL_LOADER 1
+#undef CPPUNIT_PLUGIN_EXPORT
+#define CPPUNIT_PLUGIN_EXPORT extern "C" __declspec(dllexport)
+
+// Is BeOS platform ?
+#elif defined(__BEOS__)
+#define CPPUNIT_HAVE_BEOS_DLL_LOADER 1
+
+// Is Unix platform and have include <dlfcn.h>
+#elif defined(CPPUNIT_HAVE_DLFCN_H)
+#define CPPUNIT_HAVE_UNIX_DLL_LOADER 1
+
+// Otherwise, disable support for DllLoader
+#else
+#define CPPUNIT_NO_TESTPLUGIN
+#endif
+
+#if !defined(CPPUNIT_PLUGIN_EXPORT)
+#define CPPUNIT_PLUGIN_EXPORT extern "C"
+#endif // !defined(CPPUNIT_PLUGIN_EXPORT)
+
+#endif // !defined(CPPUNIT_NO_TESTPLUGIN)
+
+#endif // CPPUNIT_CONFIG_SELECTDLLLOADER_H \ No newline at end of file
diff --git a/include/cppunit/config-bcb5.h b/include/cppunit/config/config-bcb5.h
index 7e62b02..7e62b02 100644
--- a/include/cppunit/config-bcb5.h
+++ b/include/cppunit/config/config-bcb5.h
diff --git a/include/cppunit/config-mac.h b/include/cppunit/config/config-mac.h
index 990163a..990163a 100644
--- a/include/cppunit/config-mac.h
+++ b/include/cppunit/config/config-mac.h
diff --git a/include/cppunit/config-msvc6.h b/include/cppunit/config/config-msvc6.h
index 7047851..7047851 100644
--- a/include/cppunit/config-msvc6.h
+++ b/include/cppunit/config/config-msvc6.h
diff --git a/include/cppunit/extensions/HelperMacros.h b/include/cppunit/extensions/HelperMacros.h
index 142cd1d..c7be1aa 100644
--- a/include/cppunit/extensions/HelperMacros.h
+++ b/include/cppunit/extensions/HelperMacros.h
@@ -259,16 +259,8 @@ namespace CppUnit
/** @}
*/
-#define __CPPUNIT_CONCATENATE_DIRECT( s1, s2 ) s1##s2
-#define __CPPUNIT_CONCATENATE( s1, s2 ) __CPPUNIT_CONCATENATE_DIRECT( s1, s2 )
-/** Decorates the specified string with the line number to obtain a unique name;
- * @param str String to decorate.
- */
-#define __CPPUNIT_MAKE_UNIQUE_NAME( str ) __CPPUNIT_CONCATENATE( str, __LINE__ )
-
-
-/** Adds the specified fixture suite to the unnamed registry.
+/*! Adds the specified fixture suite to the unnamed registry.
* \ingroup CreatingTestSuite
*
* This macro declares a static variable whose construction
@@ -285,7 +277,7 @@ namespace CppUnit
*/
#define CPPUNIT_TEST_SUITE_REGISTRATION( ATestFixtureType ) \
static CppUnit::AutoRegisterSuite< ATestFixtureType > \
- __CPPUNIT_MAKE_UNIQUE_NAME(__autoRegisterSuite )
+ CPPUNIT_MAKE_UNIQUE_NAME(__autoRegisterSuite )
/** Adds the specified fixture suite to the specified registry suite.
@@ -325,7 +317,7 @@ namespace CppUnit
*/
#define CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ATestFixtureType, suiteName ) \
static CppUnit::AutoRegisterSuite< ATestFixtureType > \
- __CPPUNIT_MAKE_UNIQUE_NAME(__autoRegisterSuite )(suiteName)
+ CPPUNIT_MAKE_UNIQUE_NAME(__autoRegisterSuite )(suiteName)
// Backwards compatibility
diff --git a/include/cppunit/extensions/TestDecorator.h b/include/cppunit/extensions/TestDecorator.h
index 9777540..bceca07 100644
--- a/include/cppunit/extensions/TestDecorator.h
+++ b/include/cppunit/extensions/TestDecorator.h
@@ -2,7 +2,7 @@
#define CPPUNIT_EXTENSIONS_TESTDECORATOR_H
#include <cppunit/Portability.h>
-#include <cppunit/TestLeaf.h>
+#include <cppunit/Test.h>
namespace CppUnit {
@@ -17,17 +17,23 @@ class TestResult;
*
* Does not assume ownership of the test it decorates
*/
-class CPPUNIT_API TestDecorator : public TestLeaf
+class CPPUNIT_API TestDecorator : public Test
{
public:
TestDecorator( Test *test );
~TestDecorator();
int countTestCases() const;
+
std::string getName() const;
+
void run( TestResult *result );
+ int getChildTestCount() const;
+
protected:
+ Test *doGetChildTestAt( int index ) const;
+
Test *m_test;
private:
@@ -69,6 +75,20 @@ TestDecorator::getName() const
return m_test->getName();
}
+
+inline int
+TestDecorator::getChildTestCount() const
+{
+ return m_test->getChildTestCount();
+}
+
+
+inline Test *
+TestDecorator::doGetChildTestAt( int index ) const
+{
+ return m_test->getChildTestAt( index );
+}
+
} // namespace CppUnit
#endif
diff --git a/include/cppunit/plugin/DynamicLibraryManager.h b/include/cppunit/plugin/DynamicLibraryManager.h
new file mode 100644
index 0000000..93ce583
--- /dev/null
+++ b/include/cppunit/plugin/DynamicLibraryManager.h
@@ -0,0 +1,114 @@
+#ifndef CPPUNIT_PLUGIN_DYNAMICLIBRARYMANAGER_H
+#define CPPUNIT_PLUGIN_DYNAMICLIBRARYMANAGER_H
+
+#include <cppunit/Portability.h>
+
+#if !defined(CPPUNIT_NO_TESTPLUGIN)
+#include <string>
+
+
+namespace CppUnit
+{
+
+
+/*! \brief Manages dynamic libraries.
+ *
+ * The Dynamic Library Manager provides a platform independent way to work with
+ * dynamic library. It load a specific dynamic library, and can returns specific
+ * symbol exported by the dynamic library.
+ *
+ * If an error occurs, a DynamicLibraryManagerException is thrown.
+ *
+ * \internal Implementation of the OS independent methods is in
+ * DynamicLibraryManager.cpp.
+ *
+ * \internal Porting to a new platform:
+ * - Adds platform detection in config/SelectDllLoader.h. Should define a specific
+ * macro for that platform of the form: CPPUNIT_HAVE_XYZ_DLL_LOADER, where
+ * XYZ is the platform.
+ * - Makes a copy of UnixDynamicLibraryManager.cpp and named it after the platform.
+ * - Updated the 'guard' in your file (CPPUNIT_HAVE_XYZ_DLL_LOADER) so that it is
+ * only processed if the matching platform has been detected.
+ * - Change the implementation of methods doLoadLibrary(), doReleaseLibrary(),
+ * doFindSymbol() in your copy. Those methods usually maps directly to OS calls.
+ * - Adds the file to the project.
+ */
+class DynamicLibraryManager
+{
+public:
+ typedef void *Symbol;
+ typedef void *LibraryHandle;
+
+ /*! Loads the specified library.
+ * \param libraryFileName Name of the library to load.
+ * \exception DynamicLibraryManagerException if a failure occurs while loading
+ * the library (fail to found or load the library).
+ */
+ DynamicLibraryManager( const std::string &libraryFileName );
+
+ /// Releases the loaded library..
+ ~DynamicLibraryManager();
+
+ /*! Returns a pointer on the specified symbol exported by the library.
+ * \param symbol Name of the symbol exported by the library.
+ * \return Pointer on the symbol. Should be casted to the actual type. Never \c NULL.
+ * \exception DynamicLibraryManagerException if the symbol is not found.
+ */
+ Symbol findSymbol( const std::string &symbol );
+
+private:
+ /*! Loads the specified library.
+ * \param libraryName Name of the library to load.
+ * \exception DynamicLibraryManagerException if a failure occurs while loading
+ * the library (fail to found or load the library).
+ */
+ void loadLibrary( const std::string &libraryName );
+
+ /*! Releases the loaded library.
+ *
+ * \warning Must NOT throw any exceptions (called from destructor).
+ */
+ void releaseLibrary();
+
+ /*! Loads the specified library.
+ *
+ * May throw any exceptions (indicates failure).
+ * \param libraryName Name of the library to load.
+ * \return Handle of the loaded library. \c NULL indicates failure.
+ */
+ LibraryHandle doLoadLibrary( const std::string &libraryName );
+
+ /*! Releases the loaded library.
+ *
+ * The handle of the library to free is in \c m_libraryHandle. It is never
+ * \c NULL.
+ * \warning Must NOT throw any exceptions (called from destructor).
+ */
+ void doReleaseLibrary();
+
+ /*! Returns a pointer on the specified symbol exported by the library.
+ *
+ * May throw any exceptions (indicates failure).
+ * \param symbol Name of the symbol exported by the library.
+ * \return Pointer on the symbol. \c NULL indicates failure.
+ */
+ Symbol doFindSymbol( const std::string &symbol );
+
+ /// Prevents the use of the copy constructor.
+ DynamicLibraryManager( const DynamicLibraryManager &copy );
+
+ /// Prevents the use of the copy operator.
+ void operator =( const DynamicLibraryManager &copy );
+
+private:
+ LibraryHandle m_libraryHandle;
+ std::string m_libraryName;
+};
+
+
+} // namespace CppUnit
+
+
+#endif // !defined(CPPUNIT_NO_TESTPLUGIN)
+
+#endif // CPPUNIT_PLUGIN_DYNAMICLIBRARYMANAGER_H
diff --git a/include/cppunit/plugin/DynamicLibraryManagerException.h b/include/cppunit/plugin/DynamicLibraryManagerException.h
new file mode 100644
index 0000000..c6b956a
--- /dev/null
+++ b/include/cppunit/plugin/DynamicLibraryManagerException.h
@@ -0,0 +1,49 @@
+#ifndef CPPUNIT_PLUGIN_DYNAMICLIBRARYMANAGEREXCEPTION_H
+#define CPPUNIT_PLUGIN_DYNAMICLIBRARYMANAGEREXCEPTION_H
+
+#include <cppunit/Portability.h>
+
+#if !defined(CPPUNIT_NO_TESTPLUGIN)
+#include <stdexcept>
+#include <string>
+
+
+namespace CppUnit
+{
+
+/*! \brief Exception thrown by DynamicLibraryManager when a failure occurs.
+ *
+ * Use getCause() to know what function caused the failure.
+ *
+ */
+class DynamicLibraryManagerException : public std::runtime_error
+{
+public:
+ enum Cause
+ {
+ /// Failed to load the dynamic library
+ loadingFailed =0,
+ /// Symbol not found in the dynamic library
+ symbolNotFound,
+ };
+
+ /// Failed to load the dynamic library
+ DynamicLibraryManagerException( const std::string &libraryName );
+
+ /// Symbol not found in the dynamic library
+ DynamicLibraryManagerException( const std::string &libraryName,
+ const std::string &symbol );
+
+ Cause getCause() const;
+
+private:
+ Cause m_cause;
+};
+
+
+} // namespace CppUnit
+
+
+#endif // !defined(CPPUNIT_NO_TESTPLUGIN)
+
+#endif // CPPUNIT_PLUGIN_DYNAMICLIBRARYMANAGEREXCEPTION_H
diff --git a/include/cppunit/plugin/Makefile.am b/include/cppunit/plugin/Makefile.am
new file mode 100644
index 0000000..4ea36e9
--- /dev/null
+++ b/include/cppunit/plugin/Makefile.am
@@ -0,0 +1,8 @@
+libcppunitincludedir = $(includedir)/cppunit/plugin
+
+libcppunitinclude_HEADERS = \
+ DynamicLibraryManager.h \
+ DynamicLibraryManagerException.h \
+ TestPlugIn.h \
+ TestPlugInDefaultImpl.h \
+ TestPlugInSuite.h
diff --git a/include/cppunit/plugin/TestPlugIn.h b/include/cppunit/plugin/TestPlugIn.h
new file mode 100644
index 0000000..78ab4a6
--- /dev/null
+++ b/include/cppunit/plugin/TestPlugIn.h
@@ -0,0 +1,153 @@
+#ifndef CPPUNIT_PLUGIN_TESTPLUGIN
+#define CPPUNIT_PLUGIN_TESTPLUGIN
+
+#include <cppunit/Portability.h>
+
+#if !defined(CPPUNIT_NO_TESTPLUGIN)
+
+namespace CppUnit
+{
+class Test;
+}
+
+/*! \file
+ */
+
+
+/*! Test plug-in interface.
+ * \ingroup WritingTestPlugIn
+ *
+ * This class define the interface implemented by test plug-in. A pointer to that
+ * interface is returned by the function exported by the test plug-in.
+ * \see CPPUNIT_PLUGIN_IMPLEMENT, CPPUNIT_PLUGIN_EXPORTED_FUNCTION_IMPL
+ * \see TestPlugInDefaultImpl.
+ */
+struct CppUnitTestPlugIn
+{
+ /*! Called just after loading the dynamic library.
+ *
+ * Initializes the plug-in.
+ */
+ virtual void initialize() = 0;
+
+ /*! Returns the root test of the plug-in.
+ *
+ * Caller does not assume ownership of the test.
+ * \return Pointer on a Test. Must never be \c NULL. The caller does not assume
+ * ownership of the returned Test. The Test must remain valid until
+ * uninitialize() is called.
+ */
+ virtual CppUnit::Test *getTestSuite() =0;
+
+ /*! Called just before unloading the dynamic library.
+ * Unitializes the plug-in.
+ */
+ virtual void uninitialize() = 0;
+};
+
+
+
+/*! Name of the function exported by a test plug-in.
+ * \ingroup WritingTestPlugIn
+ *
+ * The signature of the exported function is:
+ * \code
+ * CppUnitTestPlugIn *CPPUNIT_PLUGIN_EXPORTED_NAME(void);
+ * \endif
+ */
+#define CPPUNIT_PLUGIN_EXPORTED_NAME cppunitTestPlugIn
+
+/*! Type of the function exported by a plug-in.
+ * \ingroup WritingTestPlugIn
+ */
+typedef CppUnitTestPlugIn *(*CppUnitTestPlugInSignature)();
+
+
+/*! Implements the function exported by the test plug-in
+ * \ingroup WritingTestPlugIn
+ */
+#define CPPUNIT_PLUGIN_EXPORTED_FUNCTION_IMPL( TestPlugInInterfaceType ) \
+ CPPUNIT_PLUGIN_EXPORT CppUnitTestPlugIn *CPPUNIT_PLUGIN_EXPORTED_NAME(void) \
+ { \
+ static TestPlugInInterfaceType plugIn; \
+ return &plugIn; \
+ } \
+ typedef char __CppUnitPlugInExportFunctionDummyTypeDef // dummy typedef so it can end with ';'
+
+
+// Note: This include should remain after definition of CppUnitTestPlugIn
+#include <cppunit/plugin/TestPlugInDefaultImpl.h>
+
+
+/*! \def CPPUNIT_PLUGIN_IMPLEMENT_MAIN()
+ * \brief Implements the 'main' function for the plug-in.
+ *
+ * This macros implements the main() function for dynamic library.
+ * For example, WIN32 requires a DllMain function, while some Unix
+ * requires a main() function. This macros takes care of the implementation.
+ */
+
+// Win32
+#if defined(CPPUNIT_HAVE_WIN32_DLL_LOADER)
+#if !defined(APIENTRY)
+#define WIN32_LEAN_AND_MEAN
+#define NOGDI
+#define NOUSER
+#define NOKERNEL
+#define NOSOUND
+#define NOMINMAX
+#include <windows.h>
+#endif
+#define CPPUNIT_PLUGIN_IMPLEMENT_MAIN() \
+ BOOL APIENTRY DllMain( HANDLE hModule, \
+ DWORD ul_reason_for_call, \
+ LPVOID lpReserved ) \
+ { \
+ return TRUE; \
+ } \
+ typedef char __CppUnitPlugInImplementMainDummyTypeDef
+
+// Unix
+#elif defined(CPPUNIT_HAVE_UNIX_DLL_LOADER)
+#define CPPUNIT_PLUGIN_IMPLEMENT_MAIN() \
+ int main( int argc, char *argv[] ) \
+ { \
+ (void)argc; (void)argv; \
+ return 0; \
+ } \
+ typedef char __CppUnitPlugInImplementMainDummyTypeDef
+
+// Other
+#else // other platforms don't require anything specifics
+#endif
+
+
+
+/*! Implements and exports the test plug-in interface.
+ * \ingroup WritingTestPlugIn
+ *
+ * This macro creates a subclass of CppUnitTestPlugInDefaultImpl to specify set
+ * the name of the suite returned by CppUnitTestPlugIn::getTestSuite(), exports
+ * the test plug-in function using the subclass, and implements the 'main'
+ * function for the plug-in using CPPUNIT_PLUGIN_IMPLEMENT_MAIN().
+ *
+ * \see CppUnitTestPlugIn, CppUnitTestPlugInDefaultImpl
+ * \see CPPUNIT_PLUGIN_EXPORTED_FUNCTION_IMPL(), CPPUNIT_PLUGIN_IMPLEMENT_MAIN().
+ */
+#define CPPUNIT_PLUGIN_IMPLEMENT( suiteName ) \
+ class __CppUnitTestPlugInNamedDefaultImpl : public CppUnit::TestPlugInDefaultImpl \
+ { \
+ virtual std::string getSuiteName() \
+ { \
+ return suiteName; \
+ } \
+ }; \
+ \
+ CPPUNIT_PLUGIN_EXPORTED_FUNCTION_IMPL( __CppUnitTestPlugInNamedDefaultImpl ); \
+ CPPUNIT_PLUGIN_IMPLEMENT_MAIN()
+
+
+#endif // !defined(CPPUNIT_NO_TESTPLUGIN)
+
+
+#endif // CPPUNIT_PLUGIN_TESTPLUGIN
diff --git a/include/cppunit/plugin/TestPlugInDefaultImpl.h b/include/cppunit/plugin/TestPlugInDefaultImpl.h
new file mode 100644
index 0000000..06f1bb3
--- /dev/null
+++ b/include/cppunit/plugin/TestPlugInDefaultImpl.h
@@ -0,0 +1,50 @@
+#ifndef CPPUNIT_PLUGIN_TESTPLUGINDEFAULTIMPL
+#define CPPUNIT_PLUGIN_TESTPLUGINDEFAULTIMPL
+
+#include <cppunit/Portability.h>
+
+#if !defined(CPPUNIT_NO_TESTPLUGIN)
+
+#include <cppunit/plugin/TestPlugIn.h>
+
+namespace CppUnit
+{
+
+class TestSuite;
+
+
+/*! Default implementation of test plug-in interface.
+ * \ingroup WritingTestPlugIn
+ *
+ * Override getSuiteName() to specify the suite name. Default is "All Tests".
+ *
+ * CppUnitTestPlugIn::::getTestSuite() returns a suite that contains
+ * all the test registered to the default test factory registry
+ * ( TestFactoryRegistry::getRegistry() ).
+ *
+ */
+class CPPUNIT_API TestPlugInDefaultImpl : public CppUnitTestPlugIn
+{
+public:
+ TestPlugInDefaultImpl();
+
+ virtual ~TestPlugInDefaultImpl();
+
+ void initialize();
+
+ CppUnit::Test *getTestSuite();
+
+ void uninitialize();
+
+protected:
+ virtual std::string getSuiteName();
+
+ TestSuite *m_suite;
+};
+
+
+} // namespace CppUnit
+
+#endif // !defined(CPPUNIT_NO_TESTPLUGIN)
+
+#endif // CPPUNIT_PLUGIN_TESTPLUGINDEFAULTIMPL
diff --git a/include/cppunit/plugin/TestPlugInSuite.h b/include/cppunit/plugin/TestPlugInSuite.h
new file mode 100644
index 0000000..19dc65d
--- /dev/null
+++ b/include/cppunit/plugin/TestPlugInSuite.h
@@ -0,0 +1,54 @@
+#ifndef CPPUNIT_EXTENSIONS_TESTPLUGINSUITE_H
+#define CPPUNIT_EXTENSIONS_TESTPLUGINSUITE_H
+
+#include <cppunit/TestComposite.h>
+#if !defined(CPPUNIT_NO_TESTPLUGIN)
+
+#include <cppunit/plugin/TestPlugIn.h>
+
+namespace CppUnit
+{
+
+class DynamicLibraryManager;
+
+
+/*! \brief A suite that wrap a test plug-in.
+ * \ingroup WritingTestPlugIn
+ */
+class TestPlugInSuite : public TestComposite
+{
+public:
+ /*! Constructs a TestPlugInSuite object.
+ */
+ TestPlugInSuite( const std::string &libraryFileName );
+
+ /// Destructor.
+ virtual ~TestPlugInSuite();
+
+ int getChildTestCount() const;
+
+protected:
+ Test *doGetChildTestAt( int index ) const;
+
+ /// Prevents the use of the copy constructor.
+ TestPlugInSuite( const TestPlugInSuite &copy );
+
+ /// Prevents the use of the copy operator.
+ void operator =( const TestPlugInSuite &copy );
+
+private:
+ /// Manager for the dynamic library.
+ DynamicLibraryManager *m_library;
+ /// Interface returned by the plug-in.
+ CppUnitTestPlugIn *m_interface;
+ /// Suite returned by the plug-in.
+ Test *m_librarySuite;
+};
+
+
+} // namespace CppUnit
+
+
+#endif // !defined(CPPUNIT_NO_TESTPLUGIN)
+
+#endif // CPPUNIT_EXTENSIONS_TESTPLUGINSUITE_H