diff options
| author | Baptiste Lepilleur <gaiacrtn@free.fr> | 2002-07-13 09:33:50 +0000 |
|---|---|---|
| committer | Baptiste Lepilleur <gaiacrtn@free.fr> | 2002-07-13 09:33:50 +0000 |
| commit | f1bf3276752a10a2cdf4e3cf3087399d199c4566 (patch) | |
| tree | 13dc67edcf465f44b9fe835f5e0b201511774d07 /include/cppunit | |
| parent | 570132ec2707c8bac6c27c758254f05e293fe613 (diff) | |
| download | cppunit-f1bf3276752a10a2cdf4e3cf3087399d199c4566.tar.gz | |
Include/cppunit/ui/text/TestRunner.
include/cppunit/ui/text/TestRunner.h:
* src/cppunit/TextTestRunner.cpp: Renamed TextUi::TestRunner
TextTestRunner and moved it to the CppUnit namespace. Added
a deprecated typedef for compatibility with previous version.
* include/cppunit/ui/text/TextTestRunner.h: added.
* include/cppunit/ui/mfc/TestRunner.h:
* src/cppunit/msvc6/testrunner/TestRunner.cpp: Renamed MfcUi::TestRunner
MfcTestRunner. Added deprecated typedef for compatibility. Renamed
TestRunner.cpp to MfcTestRunner.cpp.
* include/cppunit/ui/mfc/MfcTestRunner.h: added.
* include/cppunit/ui/qt/TestRunner.h:
* src/qttestrunner/TestRunner.cpp: renamed QtUi::TestRunner QtTestRunner
and moved it to CppUnit namespace. Added a deprecated typedef for
compatibility. Renamed TestRunner.cpp to QtTestRunner.cpp.
* include/cppunit/ui/qt/TestRunner.h:
* src/qttestrunner/TestRunner.h: Moved TestRunner to CppUnit namespace
and renamed it QtTestRunner. Added deprecated typedef for compatibility.
* include/cppunit/Asserter.h:
* src/cppunit/Asserter.cpp: changed namespace Asserter to a struct and
made all methods static.
* include/cppunit/extensions/HelperMacros.h:
* include/cppunit/extensions/SourceLine.h:
* include/cppunit/extensions/TestAssert.h:
* include/cppunit/extensions/TestPlugIn.h:
* include/cppunit/Portability.h: changed CPPUNIT_NS(symbol) to a
symbol macro that expand either to CppUnit or nothing. The symbol is
no longer a parameter.
* include/cppunit/portability/CppUnitVector.h:
* include/cppunit/portability/CppUnitDeque.h:
* include/cppunit/portability/CppUnitMap.h: added. STL Wrapper for
compilers that do not support template default argumenent and need
the allocator to be passed when instantiating STL container.
* examples/cppunittest/*.h:
* examples/cppunittest/*.cpp:
* src/msvc6/testrunner/*.h:
* src/msvc6/testrunner/*.cpp:
* src/msvc6/testpluginrunner/*.h:
* src/msvc6/testpluginrunner/*.cpp:
* src/qttestrunner/*.h:
* src/qttestrunner/*.cpp: replaced occurence of CppUnit:: by CPPUNIT_NS.
* src/cppunit/TestSuite.h:
replaced occurence of std::vector by CppUnitVector.
Diffstat (limited to 'include/cppunit')
34 files changed, 462 insertions, 385 deletions
diff --git a/include/cppunit/Asserter.h b/include/cppunit/Asserter.h index 5a10236..8ad783d 100644 --- a/include/cppunit/Asserter.h +++ b/include/cppunit/Asserter.h @@ -42,18 +42,18 @@ class Message; * CPPUNIT_SOURCELINE() ) * \endcode */ -namespace Asserter +struct Asserter { /*! Throws a Exception with the specified message and location. */ - void CPPUNIT_API fail( const Message &message, - const SourceLine &sourceLine = SourceLine() ); + static void CPPUNIT_API fail( const Message &message, + const SourceLine &sourceLine = SourceLine() ); /*! Throws a Exception with the specified message and location. * \deprecated Use fail( Message, SourceLine ) instead. */ - void CPPUNIT_API fail( std::string message, - const SourceLine &sourceLine = SourceLine() ); + static void CPPUNIT_API fail( std::string message, + const SourceLine &sourceLine = SourceLine() ); /*! Throws a Exception with the specified message and location. * \param shouldFail if \c true then the exception is thrown. Otherwise @@ -61,9 +61,9 @@ namespace Asserter * \param message Message explaining the assertion failiure. * \param sourceLine Location of the assertion. */ - void CPPUNIT_API failIf( bool shouldFail, - const Message &message, - const SourceLine &sourceLine = SourceLine() ); + static void CPPUNIT_API failIf( bool shouldFail, + const Message &message, + const SourceLine &sourceLine = SourceLine() ); /*! Throws a Exception with the specified message and location. * \deprecated Use failIf( bool, Message, SourceLine ) instead. @@ -72,9 +72,9 @@ namespace Asserter * \param message Message explaining the assertion failiure. * \param sourceLine Location of the assertion. */ - void CPPUNIT_API failIf( bool shouldFail, - std::string message, - const SourceLine &sourceLine = SourceLine() ); + static void CPPUNIT_API failIf( bool shouldFail, + std::string message, + const SourceLine &sourceLine = SourceLine() ); /*! \brief Returns a expected value string for a message. * Typically used to create 'not equal' message, or to check that a message @@ -85,7 +85,7 @@ namespace Asserter * \return \a expectedValue prefixed with "Expected: ". * \see makeActual(). */ - std::string CPPUNIT_API makeExpected( const std::string &expectedValue ); + static std::string CPPUNIT_API makeExpected( const std::string &expectedValue ); /*! \brief Returns an actual value string for a message. * Typically used to create 'not equal' message, or to check that a message @@ -96,12 +96,12 @@ namespace Asserter * \return \a actualValue prefixed with "Actual : ". * \see makeExpected(). */ - std::string CPPUNIT_API makeActual( const std::string &actualValue ); + static std::string CPPUNIT_API makeActual( const std::string &actualValue ); - Message CPPUNIT_API makeNotEqualMessage( const std::string &expectedValue, - const std::string &actualValue, - const AdditionalMessage &additionalMessage = AdditionalMessage(), - const std::string &shortDescription = "equality assertion failed"); + static Message CPPUNIT_API makeNotEqualMessage( const std::string &expectedValue, + const std::string &actualValue, + const AdditionalMessage &additionalMessage = AdditionalMessage(), + const std::string &shortDescription = "equality assertion failed"); /*! Throws an Exception with the specified message and location. * \param expected Text describing the expected value. @@ -110,11 +110,11 @@ namespace Asserter * what are the differences between the expected and actual value. * \param sourceLine Location of the assertion. */ - void CPPUNIT_API failNotEqual( std::string expected, - std::string actual, - const SourceLine &sourceLine, - const AdditionalMessage &additionalMessage = AdditionalMessage(), - std::string shortDescription = "equality assertion failed" ); + static void CPPUNIT_API failNotEqual( std::string expected, + std::string actual, + const SourceLine &sourceLine, + const AdditionalMessage &additionalMessage = AdditionalMessage(), + std::string shortDescription = "equality assertion failed" ); /*! Throws an Exception with the specified message and location. * \param shouldFail if \c true then the exception is thrown. Otherwise @@ -125,14 +125,14 @@ namespace Asserter * where the "difference" is located. * \param sourceLine Location of the assertion. */ - void CPPUNIT_API failNotEqualIf( bool shouldFail, - std::string expected, - std::string actual, - const SourceLine &sourceLine, - const AdditionalMessage &additionalMessage = AdditionalMessage(), - std::string shortDescription = "equality assertion failed" ); - -} // namespace Asserter + static void CPPUNIT_API failNotEqualIf( bool shouldFail, + std::string expected, + std::string actual, + const SourceLine &sourceLine, + const AdditionalMessage &additionalMessage = AdditionalMessage(), + std::string shortDescription = "equality assertion failed" ); + +}; CPPUNIT_NS_END diff --git a/include/cppunit/CompilerOutputter.h b/include/cppunit/CompilerOutputter.h index 1660887..04be58f 100644 --- a/include/cppunit/CompilerOutputter.h +++ b/include/cppunit/CompilerOutputter.h @@ -3,7 +3,6 @@ #include <cppunit/Portability.h> #include <cppunit/Outputter.h> -#include <vector> #include <iostream> CPPUNIT_NS_BEGIN diff --git a/include/cppunit/Message.h b/include/cppunit/Message.h index e3d8639..80c7cdb 100644 --- a/include/cppunit/Message.h +++ b/include/cppunit/Message.h @@ -8,7 +8,7 @@ #pragma warning( disable: 4251 ) // X needs to have dll-interface to be used by clients of class Z #endif -#include <deque> +#include <cppunit/portability/CppUnitDeque.h> #include <string> @@ -137,7 +137,7 @@ public: private: std::string m_shortDescription; - typedef std::deque<std::string> Details; + typedef CppUnitDeque<std::string> Details; Details m_details; }; diff --git a/include/cppunit/Portability.h b/include/cppunit/Portability.h index 70f9e05..ce7ebea 100644 --- a/include/cppunit/Portability.h +++ b/include/cppunit/Portability.h @@ -26,67 +26,81 @@ /* Define to 1 if you wish to have the old-style macros assert(), assertEqual(), assertDoublesEqual(), and assertLongsEqual() */ -#ifndef CPPUNIT_ENABLE_NAKED_ASSERT -#define CPPUNIT_ENABLE_NAKED_ASSERT 0 +#if !defined(CPPUNIT_ENABLE_NAKED_ASSERT) +# define CPPUNIT_ENABLE_NAKED_ASSERT 0 #endif /* Define to 1 if you wish to have the old-style CU_TEST family of macros. */ -#ifndef CPPUNIT_ENABLE_CU_TEST_MACROS -#define CPPUNIT_ENABLE_CU_TEST_MACROS 0 +#if !defined(CPPUNIT_ENABLE_CU_TEST_MACROS) +# define CPPUNIT_ENABLE_CU_TEST_MACROS 0 #endif /* Define to 1 if the preprocessor expands (#foo) to "foo" (quotes incl.) I don't think there is any C preprocess that does NOT support this! */ -#ifndef CPPUNIT_HAVE_CPP_SOURCE_ANNOTATION -#define CPPUNIT_HAVE_CPP_SOURCE_ANNOTATION 1 +#if !defined(CPPUNIT_HAVE_CPP_SOURCE_ANNOTATION) +# define CPPUNIT_HAVE_CPP_SOURCE_ANNOTATION 1 #endif /* Assumes that STL and CppUnit are in global space if the compiler does not support namespace. */ #if !defined(CPPUNIT_HAVE_NAMESPACES) -#ifndef CPPUNIT_NO_NAMESPACE -#define CPPUNIT_NO_NAMESPACE 1 -#endif // CPPUNIT_NO_NAMESPACE -#ifndef CPPUNIT_NO_STD_NAMESPACE -#define CPPUNIT_NO_STD_NAMESPACE 1 -#endif // CPPUNIT_NO_STD_NAMESPACE +# if !defined(CPPUNIT_NO_NAMESPACE) +# define CPPUNIT_NO_NAMESPACE 1 +# endif // !defined(CPPUNIT_NO_NAMESPACE) +# if !defined(CPPUNIT_NO_STD_NAMESPACE) +# define CPPUNIT_NO_STD_NAMESPACE 1 +# endif // !defined(CPPUNIT_NO_STD_NAMESPACE) #endif // !defined(CPPUNIT_HAVE_NAMESPACES) +/* Define CPPUNIT_STD_NEED_ALLOCATOR to 1 if you need to specify + * the allocator you used when instantiating STL container. Typically + * used for compilers that do not support template default parameter. + * CPPUNIT_STD_ALLOCATOR will be used as the allocator. Default is + * std::allocator. On some compilers, you may need to change this to + * std::allocator<T>. + */ +#if CPPUNIT_STD_NEED_ALLOCATOR +# if !defined(CPPUNIT_STD_ALLOCATOR) +# define CPPUNIT_STD_ALLOCATOR std::allocator +# endif // !defined(CPPUNIT_STD_ALLOCATOR) +#endif // defined(CPPUNIT_STD_NEED_ALLOCATOR) + + // Compiler error location format for CompilerOutputter // If not define, assumes that it's gcc // See class CompilerOutputter for format. -#ifndef CPPUNIT_COMPILER_LOCATION_FORMAT -#define CPPUNIT_COMPILER_LOCATION_FORMAT "%f:%l:" +#if !defined(CPPUNIT_COMPILER_LOCATION_FORMAT) +# define CPPUNIT_COMPILER_LOCATION_FORMAT "%f:%l:" #endif // If CPPUNIT_HAVE_CPP_CAST is defined, then c++ style cast will be used, // otherwise, C style cast are used. #if defined( CPPUNIT_HAVE_CPP_CAST ) -#define CPPUNIT_CONST_CAST( TargetType, pointer ) \ +# define CPPUNIT_CONST_CAST( TargetType, pointer ) \ const_cast<TargetType>( pointer ) -#else -#define CPPUNIT_CONST_CAST( TargetType, pointer ) \ +#else // defined( CPPUNIT_HAVE_CPP_CAST ) +# define CPPUNIT_CONST_CAST( TargetType, pointer ) \ ((TargetType)( pointer )) -#endif +#endif // defined( CPPUNIT_HAVE_CPP_CAST ) // If CPPUNIT_NO_STD_NAMESPACE is defined then STL are in the global space. // => Define macro 'std' to nothing #if defined(CPPUNIT_NO_STD_NAMESPACE) -#undef std -#define std +# undef std +# define std #endif // defined(CPPUNIT_NO_STD_NAMESPACE) // If CPPUNIT_NO_NAMESPACE is defined, then put CppUnit classes in the // global namespace: the compiler does not support namespace. #if defined(CPPUNIT_NO_NAMESPACE) -#define CPPUNIT_NS_BEGIN -#define CPPUNIT_NS_END -#define CPPUNIT_NS(symbol) symbol +# define CPPUNIT_NS_BEGIN +# define CPPUNIT_NS_END +# define CPPUNIT_NS #else // defined(CPPUNIT_NO_NAMESPACE) -#define CPPUNIT_NS_BEGIN namespace CppUnit { -#define CPPUNIT_NS_END } -#define CPPUNIT_NS(symbol) ::CppUnit::symbol +# define CPPUNIT_NS_BEGIN namespace CppUnit { +# define CPPUNIT_NS_END } +# define CPPUNIT_NS CppUnit #endif // defined(CPPUNIT_NO_NAMESPACE) /*! Stringize a symbol. @@ -138,8 +152,8 @@ /*! Defines wrap colunm for %CppUnit. Used by CompilerOuputter. */ -#ifndef CPPUNIT_WRAP_COLUMN -#define CPPUNIT_WRAP_COLUMN 79 +#if !defined(CPPUNIT_WRAP_COLUMN) +# define CPPUNIT_WRAP_COLUMN 79 #endif @@ -150,38 +164,41 @@ * method. */ #if CPPUNIT_HAVE_SSTREAM -# include <sstream> - namespace CppUnit { - class OStringStream : public std::ostringstream - { - }; - } -#else -#if CPPUNIT_HAVE_CLASS_STRSTREAM -# include <string> -# if CPPUNIT_HAVE_STRSTREAM -# include <strstream> -# else -# include <strstream.h> -# endif - - namespace CppUnit { +# include <sstream> + CPPUNIT_NS_BEGIN + + typedef std::ostringstream OStringStream; + + CPPUNIT_NS_END +#elif CPPUNIT_HAVE_CLASS_STRSTREAM +# include <string> +# if CPPUNIT_HAVE_STRSTREAM +# include <strstream> +# else // CPPUNIT_HAVE_STRSTREAM +# include <strstream.h> +# endif // CPPUNIT_HAVE_CLASS_STRSTREAM + + CPPUNIT_NS_BEGIN + class OStringStream : public std::ostrstream { public: std::string str() { - (*this) << '\0'; - std::string msg(std::ostrstream::str()); - std::ostrstream::freeze(false); - return msg; +// (*this) << '\0'; +// std::string msg(std::ostrstream::str()); +// std::ostrstream::freeze(false); +// return msg; +// Alternative implementation that don't rely on freeze which is not +// available on some platforms: + return std::string( std::ostrstream::str(), pcount() ); } }; - } -#else + + CPPUNIT_NS_END +#else // CPPUNIT_HAVE_CLASS_STRSTREAM # error Cannot define CppUnit::OStringStream. -#endif -#endif +#endif // CPPUNIT_HAVE_SSTREAM #endif // CPPUNIT_PORTABILITY_H diff --git a/include/cppunit/SourceLine.h b/include/cppunit/SourceLine.h index bb538cc..71eeaed 100644 --- a/include/cppunit/SourceLine.h +++ b/include/cppunit/SourceLine.h @@ -10,7 +10,7 @@ * Used to write your own assertion macros. * \see Asserter for example of usage. */ -#define CPPUNIT_SOURCELINE() CPPUNIT_NS(SourceLine)( __FILE__, __LINE__ ) +#define CPPUNIT_SOURCELINE() CPPUNIT_NS::SourceLine( __FILE__, __LINE__ ) CPPUNIT_NS_BEGIN diff --git a/include/cppunit/TestAssert.h b/include/cppunit/TestAssert.h index e726d40..ba30e9c 100644 --- a/include/cppunit/TestAssert.h +++ b/include/cppunit/TestAssert.h @@ -120,14 +120,14 @@ namespace TestAssert * \ingroup Assertions */ #define CPPUNIT_ASSERT(condition) \ - ( CPPUNIT_NS(Asserter)::failIf( !(condition), \ - CPPUNIT_NS(Message)( "assertion failed", \ + ( CPPUNIT_NS::Asserter::failIf( !(condition), \ + CPPUNIT_NS::Message( "assertion failed", \ "Expression: " #condition), \ CPPUNIT_SOURCELINE() ) ) #else #define CPPUNIT_ASSERT(condition) \ - ( CPPUNIT_NS(Asserter)::failIf( !(condition), \ - CPPUNIT_NS(Message)( "assertion failed" ), \ + ( CPPUNIT_NS::Asserter::failIf( !(condition), \ + CPPUNIT_NS::Message( "assertion failed" ), \ CPPUNIT_SOURCELINE() ) ) #endif @@ -139,7 +139,7 @@ namespace TestAssert * test failed. */ #define CPPUNIT_ASSERT_MESSAGE(message,condition) \ - ( CPPUNIT_NS(Asserter)::failIf( !(condition), \ + ( CPPUNIT_NS::Asserter::failIf( !(condition), \ (message), \ CPPUNIT_SOURCELINE() ) ) @@ -148,14 +148,14 @@ namespace TestAssert * \param message Message reported in diagnostic. */ #define CPPUNIT_FAIL( message ) \ - ( CPPUNIT_NS(Asserter)::fail( CPPUNIT_NS(Message)( "forced failure", \ + ( CPPUNIT_NS::Asserter::fail( CPPUNIT_NS::Message( "forced failure", \ message ), \ CPPUNIT_SOURCELINE() ) ) #ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED /// Generalized macro for primitive value comparisons #define CPPUNIT_ASSERT_EQUAL(expected,actual) \ - ( CPPUNIT_NS(TestAssert)::assertEquals( (expected), \ + ( CPPUNIT_NS::TestAssert::assertEquals( (expected), \ (actual), \ __LINE__, __FILE__ ) ) #else @@ -176,7 +176,7 @@ namespace TestAssert * removed by specializing the CppUnit::assertion_traits. */ #define CPPUNIT_ASSERT_EQUAL(expected,actual) \ - ( CPPUNIT_NS(TestAssert)::assertEquals( (expected), \ + ( CPPUNIT_NS::TestAssert::assertEquals( (expected), \ (actual), \ CPPUNIT_SOURCELINE() ) ) @@ -199,7 +199,7 @@ namespace TestAssert * removed by specializing the CppUnit::assertion_traits. */ #define CPPUNIT_ASSERT_EQUAL_MESSAGE(message,expected,actual) \ - ( CPPUNIT_NS(TestAssert)::assertEquals( (expected), \ + ( CPPUNIT_NS::TestAssert::assertEquals( (expected), \ (actual), \ CPPUNIT_SOURCELINE(), \ (message) ) ) @@ -209,7 +209,7 @@ namespace TestAssert * \ingroup Assertions */ #define CPPUNIT_ASSERT_DOUBLES_EQUAL(expected,actual,delta) \ - ( CPPUNIT_NS(TestAssert)::assertDoubleEquals( (expected), \ + ( CPPUNIT_NS::TestAssert::assertDoubleEquals( (expected), \ (actual), \ (delta), \ CPPUNIT_SOURCELINE() ) ) diff --git a/include/cppunit/TestPath.h b/include/cppunit/TestPath.h index 65f974c..63dbae4 100644 --- a/include/cppunit/TestPath.h +++ b/include/cppunit/TestPath.h @@ -8,7 +8,7 @@ #pragma warning( disable: 4251 ) // X needs to have dll-interface to be used by clients of class Z #endif -#include <deque> +#include <cppunit/portability/CppUnitDeque.h> CPPUNIT_NS_BEGIN @@ -173,7 +173,7 @@ protected: void checkIndexValid( int index ) const; /// A list of test names. - typedef std::deque<std::string> PathTestNames; + typedef CppUnitDeque<std::string> PathTestNames; /*! Splits a path string into its test name components. * \param pathAsString Path string created with toString(). @@ -198,7 +198,7 @@ protected: PathTestNames &testNames ); protected: - typedef std::deque<Test *> Tests; + typedef CppUnitDeque<Test *> Tests; Tests m_tests; }; diff --git a/include/cppunit/TestResult.h b/include/cppunit/TestResult.h index faed1dc..c859001 100644 --- a/include/cppunit/TestResult.h +++ b/include/cppunit/TestResult.h @@ -9,7 +9,7 @@ #endif #include <cppunit/SynchronizedObject.h> -#include <deque> +#include <cppunit/portability/CppUnitDeque.h> CPPUNIT_NS_BEGIN @@ -74,7 +74,7 @@ protected: virtual void endTestRun( Test *test ); protected: - typedef std::deque<TestListener *> TestListeners; + typedef CppUnitDeque<TestListener *> TestListeners; TestListeners m_listeners; bool m_stop; diff --git a/include/cppunit/TestResultCollector.h b/include/cppunit/TestResultCollector.h index 8465297..65b77cd 100644 --- a/include/cppunit/TestResultCollector.h +++ b/include/cppunit/TestResultCollector.h @@ -9,7 +9,7 @@ #endif #include <cppunit/TestSuccessListener.h> -#include <deque> +#include <cppunit/portability/CppUnitDeque.h> CPPUNIT_NS_BEGIN @@ -36,8 +36,8 @@ CPPUNIT_NS_BEGIN class CPPUNIT_API TestResultCollector : public TestSuccessListener { public: - typedef std::deque<TestFailure *> TestFailures; - typedef std::deque<Test *> Tests; + typedef CppUnitDeque<TestFailure *> TestFailures; + typedef CppUnitDeque<Test *> Tests; /*! Constructs a TestResultCollector object. diff --git a/include/cppunit/TestRunner.h b/include/cppunit/TestRunner.h index 3a853e9..50390f0 100644 --- a/include/cppunit/TestRunner.h +++ b/include/cppunit/TestRunner.h @@ -95,6 +95,8 @@ public: const std::string &testPath = "" ); protected: + /*! \brief (INTERNAL) Mutating test suite. + */ class CPPUNIT_API WrappingSuite : public TestSuite { public: diff --git a/include/cppunit/TestSuite.h b/include/cppunit/TestSuite.h index 7abea67..a478b8d 100644 --- a/include/cppunit/TestSuite.h +++ b/include/cppunit/TestSuite.h @@ -9,7 +9,7 @@ #endif #include <cppunit/TestComposite.h> -#include <vector> +#include <cppunit/portability/CppUnitVector.h> CPPUNIT_NS_BEGIN @@ -56,7 +56,7 @@ public: * TestComposite interface instead. * \return Reference on a vector that contains the tests of the suite. */ - const std::vector<Test *> &getTests() const; + const CppUnitVector<Test *> &getTests() const; /*! Destroys all the tests of the suite. */ @@ -67,7 +67,7 @@ public: Test *doGetChildTestAt( int index ) const; private: - std::vector<Test *> m_tests; + CppUnitVector<Test *> m_tests; }; diff --git a/include/cppunit/TextTestRunner.h b/include/cppunit/TextTestRunner.h index 417dfab..28c2513 100644 --- a/include/cppunit/TextTestRunner.h +++ b/include/cppunit/TextTestRunner.h @@ -1,18 +1,20 @@ #ifndef CPPUNIT_TEXTTESTRUNNER_H #define CPPUNIT_TEXTTESTRUNNER_H -#include <cppunit/ui/text/TestRunner.h> +#include <cppunit/ui/text/TextTestRunner.h> -CPPUNIT_NS_BEGIN +#if !defined(CPPUNIT_NO_NAMESPACE) +namespace TextUi +{ -/*! - * \brief A text mode test runner. - * \ingroup ExecutingTest - * \deprecated Use CppUnit::TextUi::TestRunner instead. - */ -typedef CPPUNIT_NS(TextUi::TestRunner) TextTestRunner; + /*! Text TestRunner (DEPRECATED). + * \deprecated Use TextTestRunner instead. + */ + typedef TextTestRunner TestRunner; + +} +#endif -CPPUNIT_NS_END #endif // CPPUNIT_TEXTTESTRUNNER_H diff --git a/include/cppunit/XmlOutputter.h b/include/cppunit/XmlOutputter.h index 3b733ac..b28b727 100644 --- a/include/cppunit/XmlOutputter.h +++ b/include/cppunit/XmlOutputter.h @@ -9,7 +9,7 @@ #endif #include <cppunit/Outputter.h> -#include <deque> +#include <cppunit/portability/CppUnitDeque.h> #include <iostream> #include <map> @@ -128,7 +128,7 @@ protected: virtual void fillFailedTestsMap( FailedTests &failedTests ); protected: - typedef std::deque<XmlOutputterHook *> Hooks; + typedef CppUnitDeque<XmlOutputterHook *> Hooks; TestResultCollector *m_result; std::ostream &m_stream; diff --git a/include/cppunit/config/config-msvc6.h b/include/cppunit/config/config-msvc6.h index 32a9e26..eea5cf6 100644 --- a/include/cppunit/config/config-msvc6.h +++ b/include/cppunit/config/config-msvc6.h @@ -53,6 +53,12 @@ #undef CPPUNIT_COMPILER_LOCATION_FORMAT #define CPPUNIT_COMPILER_LOCATION_FORMAT "%p(%l):" - +// Uncomment to turn on STL wrapping => use this to test compilation. +// This will make CppUnit subclass std::vector & co to provide default +// parameter. +#define CPPUNIT_STD_NEED_ALLOCATOR 1 +#define CPPUNIT_STD_ALLOCATOR std::allocator<T> + + /* _INCLUDE_CPPUNIT_CONFIG_MSVC6_H */ #endif diff --git a/include/cppunit/extensions/AutoRegisterSuite.h b/include/cppunit/extensions/AutoRegisterSuite.h index b690801..e04adb5 100644 --- a/include/cppunit/extensions/AutoRegisterSuite.h +++ b/include/cppunit/extensions/AutoRegisterSuite.h @@ -8,7 +8,7 @@ CPPUNIT_NS_BEGIN -/** Automatically register the test suite of the specified type. (Implementation) +/*! \brief (Implementation) Automatically register the test suite of the specified type. * * You should not use this class directly. Instead, use the following macros: * - CPPUNIT_TEST_SUITE_REGISTRATION() @@ -57,7 +57,7 @@ private: }; -/*! Automatically adds a registry into another registry. (Implementation) +/*! \brief (Implementation) Automatically adds a registry into another registry. * * Don't use this class. Use the macros CPPUNIT_REGISTRY_ADD() and * CPPUNIT_REGISTRY_ADD_TO_DEFAULT() instead. diff --git a/include/cppunit/extensions/HelperMacros.h b/include/cppunit/extensions/HelperMacros.h index 5d63f8b..379187f 100644 --- a/include/cppunit/extensions/HelperMacros.h +++ b/include/cppunit/extensions/HelperMacros.h @@ -22,7 +22,7 @@ CPPUNIT_NS_BEGIN { public: //! Creates a new TestFixture instance. - virtual CPPUNIT_NS(TestFixture) *makeFixture() =0; + virtual CPPUNIT_NS::TestFixture *makeFixture() =0; }; CPPUNIT_NS_END @@ -114,14 +114,14 @@ CPPUNIT_NS_END #define CPPUNIT_TEST_SUITE( ATestFixtureType ) \ private: \ typedef ATestFixtureType ThisTestFixtureType; \ - class __ThisTestFixtureFactory : public CPPUNIT_NS(TestFixtureFactory) \ + class __ThisTestFixtureFactory : public CPPUNIT_NS::TestFixtureFactory \ { \ - virtual CPPUNIT_NS(TestFixture) *makeFixture() \ + virtual CPPUNIT_NS::TestFixture *makeFixture() \ { \ return new ATestFixtureType(); \ } \ }; \ - static const CPPUNIT_NS(TestNamer) &__getTestNamer() \ + static const CPPUNIT_NS::TestNamer &__getTestNamer() \ { \ static CPPUNIT_TESTNAMER_DECL( testNamer, ATestFixtureType ); \ return testNamer; \ @@ -130,7 +130,7 @@ CPPUNIT_NS_END class ThisTestFixtureFactory \ { \ public: \ - ThisTestFixtureFactory( CPPUNIT_NS(TestFixtureFactory) *factory ) \ + ThisTestFixtureFactory( CPPUNIT_NS::TestFixtureFactory *factory ) \ : m_factory( factory ) \ { \ } \ @@ -139,16 +139,16 @@ CPPUNIT_NS_END return (ThisTestFixtureType *)m_factory->makeFixture(); \ } \ private: \ - CPPUNIT_NS(TestFixtureFactory) *m_factory; \ + CPPUNIT_NS::TestFixtureFactory *m_factory; \ }; \ \ static void \ - __registerTests( CPPUNIT_NS(TestSuite) *suite, \ - CPPUNIT_NS(TestFixtureFactory) *fixtureFactory, \ - const CPPUNIT_NS(TestNamer) &namer ) \ + __registerTests( CPPUNIT_NS::TestSuite *suite, \ + CPPUNIT_NS::TestFixtureFactory *fixtureFactory, \ + const CPPUNIT_NS::TestNamer &namer ) \ { \ const ThisTestFixtureFactory factory( fixtureFactory ); \ - CPPUNIT_NS(TestSuiteBuilder)<ThisTestFixtureType> builder( suite, namer ) + CPPUNIT_NS::TestSuiteBuilder<ThisTestFixtureType> builder( suite, namer ) /*! \brief Begin test suite (includes parent suite) @@ -272,7 +272,7 @@ CPPUNIT_NS_END * method. */ #define CPPUNIT_TEST_EXCEPTION( testMethod, ExceptionType ) \ - CPPUNIT_TEST_ADD( (new CPPUNIT_NS(TestCaller)<ThisTestFixtureType, \ + CPPUNIT_TEST_ADD( (new CPPUNIT_NS::TestCaller<ThisTestFixtureType, \ ExceptionType>( \ namer.getTestNameFor( #testMethod ), \ &ThisTestFixtureType::testMethod, \ @@ -294,7 +294,7 @@ CPPUNIT_NS_END * \see CreatingNewAssertions. */ #define CPPUNIT_TEST_FAIL( testMethod ) \ - CPPUNIT_TEST_EXCEPTION( testMethod, CPPUNIT_NS(Exception) ) + CPPUNIT_TEST_EXCEPTION( testMethod, CPPUNIT_NS::Exception ) /*! \brief Adds a custom test case. * @@ -398,10 +398,10 @@ CPPUNIT_NS_END #define CPPUNIT_TEST_SUITE_END() \ builder.takeSuite(); \ } \ - static CPPUNIT_NS(TestSuite) *suite() \ + static CPPUNIT_NS::TestSuite *suite() \ { \ - const CPPUNIT_NS(TestNamer) &namer = __getTestNamer(); \ - CPPUNIT_NS(TestSuiteBuilder)<ThisTestFixtureType> builder( namer ); \ + const CPPUNIT_NS::TestNamer &namer = __getTestNamer(); \ + CPPUNIT_NS::TestSuiteBuilder<ThisTestFixtureType> builder( namer ); \ __ThisTestFixtureFactory factory; \ ThisTestFixtureType::__registerTests( builder.suite(), &factory, namer ); \ return builder.takeSuite(); \ @@ -431,7 +431,7 @@ CPPUNIT_NS_END * CppUnit::TestFactoryRegistry. */ #define CPPUNIT_TEST_SUITE_REGISTRATION( ATestFixtureType ) \ - static CPPUNIT_NS(AutoRegisterSuite)< ATestFixtureType > \ + static CPPUNIT_NS::AutoRegisterSuite< ATestFixtureType > \ CPPUNIT_MAKE_UNIQUE_NAME(__autoRegisterSuite ) @@ -473,7 +473,7 @@ CPPUNIT_NS_END * CppUnit::TestFactoryRegistry.. */ #define CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ATestFixtureType, suiteName ) \ - static CPPUNIT_NS(AutoRegisterSuite)< ATestFixtureType > \ + static CPPUNIT_NS::AutoRegisterSuite< ATestFixtureType > \ CPPUNIT_MAKE_UNIQUE_NAME(__autoRegisterSuite )(suiteName) /*! Adds that the specified registry suite to another registry suite. @@ -504,7 +504,7 @@ CPPUNIT_NS_END * \see CPPUNIT_REGISTRY_ADD_TO_DEFAULT, CPPUNIT_TEST_SUITE_NAMED_REGISTRATION. */ #define CPPUNIT_REGISTRY_ADD( which, to ) \ - static CPPUNIT_NS(AutoRegisterRegistry) \ + static CPPUNIT_NS::AutoRegisterRegistry \ CPPUNIT_MAKE_UNIQUE_NAME( __autoRegisterRegistry )( which, to ) /*! Adds that the specified registry suite to the default registry suite. @@ -517,7 +517,7 @@ CPPUNIT_NS_END * \see CPPUNIT_REGISTRY_ADD. */ #define CPPUNIT_REGISTRY_ADD_TO_DEFAULT( which ) \ - static CPPUNIT_NS(AutoRegisterRegistry) \ + static CPPUNIT_NS::AutoRegisterRegistry \ CPPUNIT_MAKE_UNIQUE_NAME( __autoRegisterRegistry )( which ) // Backwards compatibility diff --git a/include/cppunit/extensions/TestNamer.h b/include/cppunit/extensions/TestNamer.h index 6267604..6d0e7f6 100644 --- a/include/cppunit/extensions/TestNamer.h +++ b/include/cppunit/extensions/TestNamer.h @@ -28,10 +28,10 @@ */ #if CPPUNIT_USE_TYPEINFO_NAME # define CPPUNIT_TESTNAMER_DECL( variableName, FixtureType ) \ - CPPUNIT_NS(TestNamer) variableName( typeid(FixtureType) ) + CPPUNIT_NS::TestNamer variableName( typeid(FixtureType) ) #else # define CPPUNIT_TESTNAMER_DECL( variableName, FixtureType ) \ - CPPUNIT_NS(TestNamer) variableName( std::string(#FixtureType) ) + CPPUNIT_NS::TestNamer variableName( std::string(#FixtureType) ) #endif diff --git a/include/cppunit/extensions/TestSetUp.h b/include/cppunit/extensions/TestSetUp.h index 3561262..f2128ec 100644 --- a/include/cppunit/extensions/TestSetUp.h +++ b/include/cppunit/extensions/TestSetUp.h @@ -9,7 +9,8 @@ CPPUNIT_NS_BEGIN class Test; class TestResult; - +/*! \brief Decorates a test by providing a specific setUp() and tearDown(). + */ class CPPUNIT_API TestSetUp : public TestDecorator { public: diff --git a/include/cppunit/plugin/Parameters.h b/include/cppunit/plugin/Parameters.h index 54a26d2..e914f3f 100644 --- a/include/cppunit/plugin/Parameters.h +++ b/include/cppunit/plugin/Parameters.h @@ -5,13 +5,13 @@ #if !defined(CPPUNIT_NO_TESTPLUGIN) -#include <deque> +#include <cppunit/portability/CppUnitDeque.h> #include <string> CPPUNIT_NS_BEGIN -typedef std::deque<std::string> Parameters; +typedef CppUnitDeque<std::string> Parameters; CPPUNIT_NS_END diff --git a/include/cppunit/plugin/PlugInManager.h b/include/cppunit/plugin/PlugInManager.h index 87455f0..585ac89 100644 --- a/include/cppunit/plugin/PlugInManager.h +++ b/include/cppunit/plugin/PlugInManager.h @@ -74,6 +74,8 @@ public: void removeXmlOutputterHooks(); protected: + /*! \brief (INTERNAL) Information about a specific plug-in. + */ struct PlugInInfo { std::string m_fileName; @@ -94,7 +96,7 @@ private: void operator =( const PlugInManager © ); private: - typedef std::deque<PlugInInfo> PlugIns; + typedef CppUnitDeque<PlugInInfo> PlugIns; PlugIns m_plugIns; }; diff --git a/include/cppunit/plugin/TestPlugIn.h b/include/cppunit/plugin/TestPlugIn.h index 568293e..d206d79 100644 --- a/include/cppunit/plugin/TestPlugIn.h +++ b/include/cppunit/plugin/TestPlugIn.h @@ -20,7 +20,7 @@ class XmlOutputter; */ -/*! Test plug-in interface. +/*! \brief Test plug-in interface. * \ingroup WritingTestPlugIn * * This class define the interface implemented by test plug-in. A pointer to that @@ -54,8 +54,8 @@ struct CppUnitTestPlugIn * N.B.: Parameters interface is not define yet, and the plug-in runner does * not yet support plug-in parameter. */ - virtual void initialize( CPPUNIT_NS(TestFactoryRegistry) *registry, - const CPPUNIT_NS(Parameters) ¶meters ) =0; + virtual void initialize( CPPUNIT_NS::TestFactoryRegistry *registry, + const CPPUNIT_NS::Parameters ¶meters ) =0; /*! Gives a chance to the plug-in to register TestListener. * @@ -64,17 +64,17 @@ struct CppUnitTestPlugIn * setUp some global resource: listen to TestListener::startTestRun(), * and TestListener::endTestRun(). */ - virtual void addListener( CPPUNIT_NS(TestResult) *eventManager ) =0; + virtual void addListener( CPPUNIT_NS::TestResult *eventManager ) =0; /*! Gives a chance to the plug-in to remove its registered TestListener. * * Override this method to remove a TestListener that has been added. */ - virtual void removeListener( CPPUNIT_NS(TestResult) *eventManager ) =0; + virtual void removeListener( CPPUNIT_NS::TestResult *eventManager ) =0; /*! Provides a way for the plug-in to register some XmlOutputterHook. */ - virtual void addXmlOutputterHooks( CPPUNIT_NS(XmlOutputter) *outputter ) =0; + virtual void addXmlOutputterHooks( CPPUNIT_NS::XmlOutputter *outputter ) =0; /*! Called when the XmlOutputter is destroyed. * @@ -90,7 +90,7 @@ struct CppUnitTestPlugIn * reference on test that are no longer available if they are not * unregistered. */ - virtual void uninitialize( CPPUNIT_NS(TestFactoryRegistry) *registry ) =0; + virtual void uninitialize( CPPUNIT_NS::TestFactoryRegistry *registry ) =0; }; @@ -186,7 +186,7 @@ typedef CppUnitTestPlugIn *(*TestPlugInSignature)(); * \see CPPUNIT_PLUGIN_EXPORTED_FUNCTION_IMPL(), CPPUNIT_PLUGIN_IMPLEMENT_MAIN(). */ #define CPPUNIT_PLUGIN_IMPLEMENT() \ - CPPUNIT_PLUGIN_EXPORTED_FUNCTION_IMPL( CPPUNIT_NS(TestPlugInDefaultImpl) ); \ + CPPUNIT_PLUGIN_EXPORTED_FUNCTION_IMPL( CPPUNIT_NS::TestPlugInDefaultImpl ); \ CPPUNIT_PLUGIN_IMPLEMENT_MAIN() diff --git a/include/cppunit/plugin/TestPlugInDefaultImpl.h b/include/cppunit/plugin/TestPlugInDefaultImpl.h index a6cc09e..f1efd81 100644 --- a/include/cppunit/plugin/TestPlugInDefaultImpl.h +++ b/include/cppunit/plugin/TestPlugInDefaultImpl.h @@ -13,7 +13,7 @@ CPPUNIT_NS_BEGIN class TestSuite; -/*! Default implementation of test plug-in interface. +/*! \brief Default implementation of test plug-in interface. * \ingroup WritingTestPlugIn * * Override getSuiteName() to specify the suite name. Default is "All Tests". diff --git a/include/cppunit/tools/StringTools.h b/include/cppunit/tools/StringTools.h index d08c6e0..7a6b6d7 100644 --- a/include/cppunit/tools/StringTools.h +++ b/include/cppunit/tools/StringTools.h @@ -3,7 +3,7 @@ #include <cppunit/Portability.h> #include <string> -#include <vector> +#include <cppunit/portability/CppUnitVector.h> CPPUNIT_NS_BEGIN @@ -14,7 +14,7 @@ CPPUNIT_NS_BEGIN struct StringTools { - typedef std::vector<std::string> Strings; + typedef CppUnitVector<std::string> Strings; static std::string CPPUNIT_API toString( int value ); diff --git a/include/cppunit/tools/XmlDocument.h b/include/cppunit/tools/XmlDocument.h index 005c736..8eba6d1 100644 --- a/include/cppunit/tools/XmlDocument.h +++ b/include/cppunit/tools/XmlDocument.h @@ -17,7 +17,7 @@ CPPUNIT_NS_BEGIN class XmlElement; -/*! A XML Document. +/*! \brief A XML Document. * * A XmlDocument represents a XML file. It holds a pointer on the root XmlElement * of the document. It also holds the encoding and style sheet used. diff --git a/include/cppunit/tools/XmlElement.h b/include/cppunit/tools/XmlElement.h index 8d4d504..62d9e73 100644 --- a/include/cppunit/tools/XmlElement.h +++ b/include/cppunit/tools/XmlElement.h @@ -8,7 +8,7 @@ #pragma warning( disable: 4251 ) // X needs to have dll-interface to be used by clients of class Z #endif -#include <deque> +#include <cppunit/portability/CppUnitDeque.h> #include <string> @@ -131,10 +131,10 @@ private: std::string m_name; std::string m_content; - typedef std::deque<Attribute> Attributes; + typedef CppUnitDeque<Attribute> Attributes; Attributes m_attributes; - typedef std::deque<XmlElement *> Elements; + typedef CppUnitDeque<XmlElement *> Elements; Elements m_elements; }; diff --git a/include/cppunit/ui/mfc/Makefile.am b/include/cppunit/ui/mfc/Makefile.am index 5d84e7b..1ea8b5e 100644 --- a/include/cppunit/ui/mfc/Makefile.am +++ b/include/cppunit/ui/mfc/Makefile.am @@ -1,4 +1,5 @@ libcppunitincludedir = $(includedir)/cppunit/ui/mfc libcppunitinclude_HEADERS = \ - TestRunner.h + TestRunner.h \ + MfcTestRunner.h diff --git a/include/cppunit/ui/mfc/MfcTestRunner.h b/include/cppunit/ui/mfc/MfcTestRunner.h new file mode 100644 index 0000000..6a5f7b7 --- /dev/null +++ b/include/cppunit/ui/mfc/MfcTestRunner.h @@ -0,0 +1,76 @@ +#ifndef CPPUNITUI_MFC_MFCTESTRUNNER_H +#define CPPUNITUI_MFC_MFCTESTRUNNER_H + +#if _MSC_VER >= 1000 +#pragma once +#endif // _MSC_VER >= 1000 + +#include <cppunit/Portability.h> +#include <cppunit/portability/CppUnitVector.h> + +/* Refer to MSDN documentation to know how to write and use MFC extension DLL: + mk:@MSITStore:h:\DevStudio\MSDN\98VSa\1036\vcmfc.chm::/html/_mfcnotes_tn033.htm#_mfcnotes_how_to_write_an_mfc_extension_dll + + This can be found in the index with "mfc extension" + The basic: + Using: + - your application must use MFC DLL + - memory allocation is done using the same heap + - you must define the symbol _AFX_DLL + + Building: + - you must define the symbol _AFX_DLL and _AFX_EXT + - export class using AFX_EXT_CLASS + */ + +CPPUNIT_NS_BEGIN + + class Test; + class TestSuite; + + +/*! \brief MFC test runner. + * \ingroup ExecutingTest + * + * Use this to launch the MFC TestRunner. Usually called from you CWinApp subclass: + * + * \code + * #include <cppunit/ui/mfc/MfcTestRunner.h> + * #include <cppunit/extensions/TestFactoryRegistry.h> + * + * void + * CHostAppApp::RunUnitTests() + * { + * CppUnit::MfcTestRunner runner; + * runner.addTest( CppUnit::TestFactoryRegistry::getRegistry().makeTest() ); + * + * runner.run(); + * } + * \endcode + * \see CppUnit::TextTestRunner, CppUnit::TestFactoryRegistry. + */ +class AFX_EXT_CLASS MfcTestRunner +{ +public: + MfcTestRunner(); + virtual ~MfcTestRunner(); + + void run(); + + void addTest( Test *test ); + + void addTests( const CppUnitVector<Test *> &tests ); + +protected: + Test *getRootTest(); + + TestSuite *m_suite; + + typedef CppUnitVector<Test *> Tests; + Tests m_tests; +}; + + +CPPUNIT_NS_END + +#endif // CPPUNITUI_MFC_MFCTESTRUNNER_H
\ No newline at end of file diff --git a/include/cppunit/ui/mfc/TestRunner.h b/include/cppunit/ui/mfc/TestRunner.h index 7186bf6..c4d6aff 100644 --- a/include/cppunit/ui/mfc/TestRunner.h +++ b/include/cppunit/ui/mfc/TestRunner.h @@ -1,82 +1,19 @@ #ifndef CPPUNITUI_MFC_TESTRUNNER_H #define CPPUNITUI_MFC_TESTRUNNER_H - -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#include <cppunit/Portability.h> -#include <vector> - -/* Refer to MSDN documentation to know how to write and use MFC extension DLL: - mk:@MSITStore:h:\DevStudio\MSDN\98VSa\1036\vcmfc.chm::/html/_mfcnotes_tn033.htm#_mfcnotes_how_to_write_an_mfc_extension_dll - - This can be found in the index with "mfc extension" - The basic: - Using: - - your application must use MFC DLL - - memory allocation is done using the same heap - - you must define the symbol _AFX_DLL - - Building: - - you must define the symbol _AFX_DLL and _AFX_EXT - - export class using AFX_EXT_CLASS - */ +#include <cppunit/ui/mfc/MfcTestRunner.h> CPPUNIT_NS_BEGIN - class Test; - class TestSuite; - +#if defined(CPPUNIT_HAVE_NAMESPACES) namespace MfcUi { - - -/*! \brief MFC test runner. - * \ingroup ExecutingTest - * - * Use this to launch the MFC TestRunner. Usually called from you CWinApp subclass: - * - * \code - * #include <cppunit/ui/mfc/TestRunner.h> - * #include <cppunit/extensions/TestFactoryRegistry.h> - * - * void - * CHostAppApp::RunUnitTests() - * { - * CppUnit::MfcUi::TestRunner runner; - * runner.addTest( CppUnit::TestFactoryRegistry::getRegistry().makeTest() ); - * - * runner.run(); - * } - * \endcode - * \see CppUnit::TextUi::TestRunner, CppUnit::TestFactoryRegistry. - */ -class AFX_EXT_CLASS TestRunner -{ -public: - TestRunner(); - virtual ~TestRunner(); - - void run(); - - void addTest( Test *test ); - - void addTests( const std::vector<Test *> &tests ); - -protected: - Test *getRootTest(); - - TestSuite *m_suite; - - typedef std::vector<Test *> Tests; - Tests m_tests; -}; - - -} // namespace MfcUi - + /*! Mfc TestRunner (DEPRECATED). + * \deprecated Use CppUnit::MfcTestRunner instead. + */ + typedef CPPUNIT_NS::MfcTestRunner TestRunner; +} +#endif // defined(CPPUNIT_HAVE_NAMESPACES) CPPUNIT_NS_END diff --git a/include/cppunit/ui/qt/Makefile.am b/include/cppunit/ui/qt/Makefile.am index eb213f7..7d4fb46 100644 --- a/include/cppunit/ui/qt/Makefile.am +++ b/include/cppunit/ui/qt/Makefile.am @@ -2,4 +2,5 @@ libcppunitincludedir = $(includedir)/cppunit/ui/qt libcppunitinclude_HEADERS = \ TestRunner.h \ + QtTestRunner.h \ Config.h diff --git a/include/cppunit/ui/qt/QtTestRunner.h b/include/cppunit/ui/qt/QtTestRunner.h new file mode 100644 index 0000000..4b6ab4e --- /dev/null +++ b/include/cppunit/ui/qt/QtTestRunner.h @@ -0,0 +1,85 @@ +// ////////////////////////////////////////////////////////////////////////// +// Header file TestRunner.h for class TestRunner +// (c)Copyright 2000, Baptiste Lepilleur. +// Created: 2001/09/19 +// ////////////////////////////////////////////////////////////////////////// +#ifndef CPPUNIT_QTUI_QTTESTRUNNER_H +#define CPPUNIT_QTUI_QTTESTRUNNER_H + +#include <cppunit/portability/CppUnitVector.h> +#include "Config.h" + +CPPUNIT_NS_BEGIN + + + class Test; + class TestSuite; + + +/*! + * \brief QT test runner. + * \ingroup ExecutingTest + * + * Here is an example of usage: + * \code + * #include <cppunit/extensions/TestFactoryRegistry.h> + * #include <cppunit/ui/qt/TestRunner.h> + * + * [...] + * + * void + * QDepWindow::runTests() + * { + * CppUnit::QtUi::TestRunner runner; + * runner.addTest( CppUnit::TestFactoryRegistry::getRegistry().makeTest() ); + * runner.run( true ); + * } + * \endcode + * + */ +class QTTESTRUNNER_API QtTestRunner +{ +public: + /*! Constructs a TestRunner object. + */ + QtTestRunner(); + + /*! Destructor. + */ + virtual ~QtTestRunner(); + + void run( bool autoRun =false ); + + void addTest( Test *test ); + +private: + /// Prevents the use of the copy constructor. + QtTestRunner( const QtTestRunner © ); + + /// Prevents the use of the copy operator. + void operator =( const QtTestRunner © ); + + Test *getRootTest(); + +private: + typedef CppUnitVector<Test *> Tests; + Tests *_tests; + + TestSuite *_suite; +}; + + +#if CPPUNIT_HAVE_NAMESPACES + namespace QtUi + { + /*! Qt TestRunner (DEPRECATED). + * \deprecated Use CppUnit::QtTestRunner instead. + */ + typedef CPPUNIT_NS::QtTestRunner TestRunner; + } +#endif + + +CPPUNIT_NS_END + +#endif // CPPUNIT_QTUI_QTTESTRUNNER_H diff --git a/include/cppunit/ui/qt/TestRunner.h b/include/cppunit/ui/qt/TestRunner.h index d58772b..9c53e4b 100644 --- a/include/cppunit/ui/qt/TestRunner.h +++ b/include/cppunit/ui/qt/TestRunner.h @@ -6,71 +6,6 @@ #ifndef CPPUNIT_QTUI_TESTRUNNER_H #define CPPUNIT_QTUI_TESTRUNNER_H -#include <vector> -#include "Config.h" - -CPPUNIT_NS_BEGIN - - - class Test; - class TestSuite; - - namespace QtUi - { - -/*! - * \brief QT test runner. - * \ingroup ExecutingTest - * - * Here is an example of usage: - * \code - * #include <cppunit/extensions/TestFactoryRegistry.h> - * #include <cppunit/ui/qt/TestRunner.h> - * - * [...] - * - * void - * QDepWindow::runTests() - * { - * CppUnit::QtUi::TestRunner runner; - * runner.addTest( CppUnit::TestFactoryRegistry::getRegistry().makeTest() ); - * runner.run( true ); - * } - * \endcode - * - */ -class QTTESTRUNNER_API TestRunner -{ -public: - /*! Constructs a TestRunner object. - */ - TestRunner(); - - /*! Destructor. - */ - virtual ~TestRunner(); - - void run( bool autoRun =false ); - - void addTest( Test *test ); - -private: - /// Prevents the use of the copy constructor. - TestRunner( const TestRunner © ); - - /// Prevents the use of the copy operator. - void operator =( const TestRunner © ); - - Test *getRootTest(); - -private: - typedef std::vector<Test *> Tests; - Tests *_tests; - - TestSuite *_suite; -}; - - -CPPUNIT_NS_END +#include <cppunit/ui/qt/QtTestRunner.h> #endif // CPPUNIT_QTUI_TESTRUNNER_H diff --git a/include/cppunit/ui/text/Makefile.am b/include/cppunit/ui/text/Makefile.am index 59d5c3e..5f01d81 100644 --- a/include/cppunit/ui/text/Makefile.am +++ b/include/cppunit/ui/text/Makefile.am @@ -1,4 +1,5 @@ libcppunitincludedir = $(includedir)/cppunit/ui/text libcppunitinclude_HEADERS = \ - TestRunner.h + TestRunner.h \ + TextTestRunner.h diff --git a/include/cppunit/ui/text/TestRunner.h b/include/cppunit/ui/text/TestRunner.h index 13bb8b0..c931f66 100644 --- a/include/cppunit/ui/text/TestRunner.h +++ b/include/cppunit/ui/text/TestRunner.h @@ -1,100 +1,18 @@ #ifndef CPPUNIT_UI_TEXT_TESTRUNNER_H #define CPPUNIT_UI_TEXT_TESTRUNNER_H -// Notes: this class is implemented in TextTestRunner.cpp. - -#include <cppunit/Portability.h> -#include <string> -#include <vector> -#include <cppunit/TestRunner.h> +#include <cppunit/ui/text/TextTestRunner.h> CPPUNIT_NS_BEGIN -class Outputter; -class Test; -class TestSuite; -class TextOutputter; -class TestResult; -class TestResultCollector; - -namespace TextUi -{ - /*! * \brief A text mode test runner. - * \ingroup WritingTestResult * \ingroup ExecutingTest - * - * The test runner manage the life cycle of the added tests. - * - * The test runner can run only one of the added tests or all the tests. - * - * TestRunner prints out a trace as the tests are executed followed by a - * summary at the end. The trace and summary print are optional. - * - * Here is an example of use: - * - * \code - * CppUnit::TextUi::TestRunner runner; - * runner.addTest( ExampleTestCase::suite() ); - * runner.run( "", true ); // Run all tests and wait - * \endcode - * - * The trace is printed using a TextTestProgressListener. The summary is printed - * using a TextOutputter. - * - * You can specify an alternate Outputter at construction - * or later with setOutputter(). - * - * After construction, you can register additional TestListener to eventManager(), - * for a custom progress trace, for example. - * - * \code - * CppUnit::TextUi::TestRunner runner; - * runner.addTest( ExampleTestCase::suite() ); - * runner.setOutputter( CppUnit::CompilerOutputter::defaultOutputter( - * &runner.result(), - * std::cerr ) ); - * MyCustomProgressTestListener progress; - * runner.eventManager().addListener( &progress ); - * runner.run( "", true ); // Run all tests and wait - * \endcode - * - * \see CompilerOutputter, XmlOutputter, TextOutputter. + * \deprecated Use CppUnit::TextUi::TestRunner instead. */ -class CPPUNIT_API TestRunner : public CPPUNIT_NS(TestRunner) -{ -public: - // Work around VC++ bug (class has same name as parent) - typedef CPPUNIT_NS(TestRunner) SuperClass; - - TestRunner( Outputter *outputter =NULL ); - - virtual ~TestRunner(); - - bool run( std::string testPath ="", - bool doWait = false, - bool doPrintResult = true, - bool doPrintProgress = true ); - - void setOutputter( Outputter *outputter ); - - TestResultCollector &result() const; - - TestResult &eventManager() const; - -protected: - virtual void wait( bool doWait ); - virtual void printResult( bool doPrintResult ); - - TestResultCollector *m_result; - TestResult *m_eventManager; - Outputter *m_outputter; -}; - +typedef CPPUNIT_NS::TextUi::TestRunner TextTestRunner; -} // namespace TextUi CPPUNIT_NS_END diff --git a/include/cppunit/ui/text/TextTestRunner.h b/include/cppunit/ui/text/TextTestRunner.h new file mode 100644 index 0000000..dee37a7 --- /dev/null +++ b/include/cppunit/ui/text/TextTestRunner.h @@ -0,0 +1,94 @@ +#ifndef CPPUNIT_TEXTTESTRUNNER_H +#define CPPUNIT_TEXTTESTRUNNER_H + + +#include <cppunit/Portability.h> +#include <string> +#include <vector> +#include <cppunit/TestRunner.h> + +CPPUNIT_NS_BEGIN + + +class Outputter; +class Test; +class TestSuite; +class TextOutputter; +class TestResult; +class TestResultCollector; + + + +/*! + * \brief A text mode test runner. + * \ingroup WritingTestResult + * \ingroup ExecutingTest + * + * The test runner manage the life cycle of the added tests. + * + * The test runner can run only one of the added tests or all the tests. + * + * TestRunner prints out a trace as the tests are executed followed by a + * summary at the end. The trace and summary print are optional. + * + * Here is an example of use: + * + * \code + * CppUnit::TextTestRunner runner; + * runner.addTest( ExampleTestCase::suite() ); + * runner.run( "", true ); // Run all tests and wait + * \endcode + * + * The trace is printed using a TextTestProgressListener. The summary is printed + * using a TextOutputter. + * + * You can specify an alternate Outputter at construction + * or later with setOutputter(). + * + * After construction, you can register additional TestListener to eventManager(), + * for a custom progress trace, for example. + * + * \code + * CppUnit::TextTestRunner runner; + * runner.addTest( ExampleTestCase::suite() ); + * runner.setOutputter( CppUnit::CompilerOutputter::defaultOutputter( + * &runner.result(), + * std::cerr ) ); + * MyCustomProgressTestListener progress; + * runner.eventManager().addListener( &progress ); + * runner.run( "", true ); // Run all tests and wait + * \endcode + * + * \see CompilerOutputter, XmlOutputter, TextOutputter. + */ +class CPPUNIT_API TextTestRunner : public CPPUNIT_NS::TestRunner +{ +public: + TextTestRunner( Outputter *outputter =NULL ); + + virtual ~TextTestRunner(); + + bool run( std::string testPath ="", + bool doWait = false, + bool doPrintResult = true, + bool doPrintProgress = true ); + + void setOutputter( Outputter *outputter ); + + TestResultCollector &result() const; + + TestResult &eventManager() const; + +protected: + virtual void wait( bool doWait ); + virtual void printResult( bool doPrintResult ); + + TestResultCollector *m_result; + TestResult *m_eventManager; + Outputter *m_outputter; +}; + + +CPPUNIT_NS_END + +#endif // CPPUNIT_TEXTTESTRUNNER_H |
