diff options
| author | Baptiste Lepilleur <gaiacrtn@free.fr> | 2002-05-25 08:29:07 +0000 |
|---|---|---|
| committer | Baptiste Lepilleur <gaiacrtn@free.fr> | 2002-05-25 08:29:07 +0000 |
| commit | b87cde884d03091d81e4d3fa2199155e152dda80 (patch) | |
| tree | 3a604be990b308ff85e2071116c4e1cc9fae74e1 /include/cppunit/extensions/TestNamer.h | |
| parent | 5ad4640702a80078748b38ebaeda37e69dce1189 (diff) | |
| download | cppunit-b87cde884d03091d81e4d3fa2199155e152dda80.tar.gz | |
Include/cppunit/extensions/TestSuiteBuilder.
include/cppunit/extensions/TestSuiteBuilder.h: updated to use TestNamer. Removed
template method addTestCallerForException() which should solve the compilation
issue with Sun 5.0/6.0 compiler.
* include/cppunit/extensions/HelperMacros.h: updated against TestSuiteBuilder
change. Added CPPUNIT_TEST_CUSTOM and CPPUNIT_TEST_CUSTOMS to add custom
tests to the fixture suite.
* include/cppunit/extensions/TestNamer.h:
* src/cppunit/TestNamer.cpp: added, TestNamer to name test case and fixture.
Diffstat (limited to 'include/cppunit/extensions/TestNamer.h')
| -rw-r--r-- | include/cppunit/extensions/TestNamer.h | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/include/cppunit/extensions/TestNamer.h b/include/cppunit/extensions/TestNamer.h new file mode 100644 index 0000000..91262b9 --- /dev/null +++ b/include/cppunit/extensions/TestNamer.h @@ -0,0 +1,86 @@ +#ifndef CPPUNIT_EXTENSIONS_TESTNAMER_H +#define CPPUNIT_EXTENSIONS_TESTNAMER_H + +#include <cppunit/Portability.h> +#include <string> + + + + +/*! \def CPPUNIT_TESTNAMER_DECL( variableName, FixtureType ) + * \brief Declares a TestNamer. + * + * Declares a TestNamer for the specified type, using RTTI if enabled, otherwise + * using macro string expansion. + * + * RTTI is used if CPPUNIT_USE_TYPEINFO_NAME is defined and not null. + * + * \code + * void someMethod() + * { + * CPPUNIT_TESTNAMER_DECL( namer, AFixtureType ); + * std::string fixtureName = namer.getFixtureName(); + * ... + * \endcode + * + * \relates TestNamer + * \see TestNamer + */ +#if CPPUNIT_USE_TYPEINFO_NAME +# define CPPUNIT_TESTNAMER_DECL( variableName, FixtureType ) \ + CppUnit::TestNamer variableName( typeid(FixtureType) ) +#else +# define CPPUNIT_TESTNAMER_DECL( variableName, FixtureType ) \ + CppUnit::TestNamer variableName( std::string(#FixtureType) ) +#endif + + + +namespace CppUnit +{ + +/*! \brief Names a test or a fixture suite. + * + * TestNamer is usually instantiated using CPPUNIT_TESTNAMER_DECL. + * + */ +class CPPUNIT_API TestNamer +{ +public: +#if CPPUNIT_HAVE_RTTI + /*! Constructs a namer using the fixture's type-info. + * \param typeInfo Type-info of the fixture type. Use to name the fixture suite. + */ + TestNamer( const std::type_info &typeInfo ); +#endif + + /*! Constructs a namer using the specified fixture name. + * \param fixtureName Name of the fixture suite. Usually extracted using a macro. + */ + TestNamer( const std::string &fixtureName ); + + /*! Returns the name of the fixture. + * \return Name of the fixture. + */ + virtual std::string getFixtureName() const; + + /*! Returns the name of the test for the specified method. + * \param testMethodName Name of the method that implements a test. + * \return A string that is the concatenation of the test fixture name + * (returned by getFixtureName()) and\a testMethodName, + * separated using '::'. This provides a fairly unique name for a given + * test. + */ + virtual std::string getTestNameFor( const std::string &testMethodName ) const; + +protected: + std::string m_fixtureName; +}; + + + +} // namespace CppUnit + + + +#endif // CPPUNIT_EXTENSIONS_TESTNAMER_H
\ No newline at end of file |
