diff options
Diffstat (limited to '3rdParty/CppUnit/src/include/cppunit/extensions')
7 files changed, 56 insertions, 42 deletions
diff --git a/3rdParty/CppUnit/src/include/cppunit/extensions/ExceptionTestCaseDecorator.h b/3rdParty/CppUnit/src/include/cppunit/extensions/ExceptionTestCaseDecorator.h index 9c816ad..a3f2b3e 100644 --- a/3rdParty/CppUnit/src/include/cppunit/extensions/ExceptionTestCaseDecorator.h +++ b/3rdParty/CppUnit/src/include/cppunit/extensions/ExceptionTestCaseDecorator.h @@ -78,3 +78,3 @@ public: // expected exception type is Exception (expecting assertion failure). -#if CPPUNIT_USE_TYPEINFO_NAME +#if defined(CPPUNIT_USE_TYPEINFO_NAME) throw Exception( Message( @@ -94,3 +94,3 @@ private: */ - virtual void checkException( ExpectedExceptionType &e ) + virtual void checkException( ExpectedExceptionType & ) { diff --git a/3rdParty/CppUnit/src/include/cppunit/extensions/HelperMacros.h b/3rdParty/CppUnit/src/include/cppunit/extensions/HelperMacros.h index 12431e4..4c30319 100644 --- a/3rdParty/CppUnit/src/include/cppunit/extensions/HelperMacros.h +++ b/3rdParty/CppUnit/src/include/cppunit/extensions/HelperMacros.h @@ -168,2 +168,3 @@ \ +public: \ static CPPUNIT_NS::TestSuite *suite() \ @@ -171,6 +172,6 @@ const CPPUNIT_NS::TestNamer &namer = getTestNamer__(); \ - std::auto_ptr<CPPUNIT_NS::TestSuite> suite( \ - new CPPUNIT_NS::TestSuite( namer.getFixtureName() )); \ + std::unique_ptr<CPPUNIT_NS::TestSuite> guard( \ + new CPPUNIT_NS::TestSuite( namer.getFixtureName() )); \ CPPUNIT_NS::ConcretTestFixtureFactory<TestFixtureType> factory; \ - CPPUNIT_NS::TestSuiteBuilderContextBase context( *suite.get(), \ + CPPUNIT_NS::TestSuiteBuilderContextBase context( *guard.get(), \ namer, \ @@ -178,3 +179,3 @@ TestFixtureType::addTestsToSuite( context ); \ - return suite.release(); \ + return guard.release(); \ } \ @@ -302,2 +303,13 @@ +#define CPPUNIT_TEST_PARAMETERIZED( testMethod, ... ) \ + for (auto& i : __VA_ARGS__) \ + { \ + TestFixtureType* fixture = context.makeFixture(); \ + CPPUNIT_TEST_SUITE_ADD_TEST( \ + ( new CPPUNIT_NS::TestCaller<TestFixtureType>( \ + context.getTestNameFor(#testMethod, i), \ + std::bind(&TestFixtureType::testMethod, fixture, i), \ + fixture))); \ + } + /*! \brief Add a test which fail if the specified exception is not caught. @@ -310,3 +322,3 @@ * CPPUNIT_TEST_SUITE( MyTest ); - * CPPUNIT_TEST_EXCEPTION( testVectorAtThrow, std::invalid_argument ); + * CPPUNIT_TEST_EXCEPTION( testVectorAtThrow, std::out_of_range ); * CPPUNIT_TEST_SUITE_END(); @@ -316,3 +328,3 @@ * std::vector<int> v; - * v.at( 1 ); // must throw exception std::invalid_argument + * v.at( 1 ); // must throw exception std::out_of_range * } diff --git a/3rdParty/CppUnit/src/include/cppunit/extensions/TestCaseDecorator.h b/3rdParty/CppUnit/src/include/cppunit/extensions/TestCaseDecorator.h index 3a15ba9..effde25 100644 --- a/3rdParty/CppUnit/src/include/cppunit/extensions/TestCaseDecorator.h +++ b/3rdParty/CppUnit/src/include/cppunit/extensions/TestCaseDecorator.h @@ -15,3 +15,3 @@ CPPUNIT_NS_BEGIN * - * Does not assume ownership of the test it decorates + * Assumes ownership of the test it decorates */ @@ -33,2 +33,9 @@ protected: TestCase *m_test; + +private: + + //prevent the creation of copy c'tor and operator= + TestCaseDecorator( const TestCaseDecorator& ); + TestCaseDecorator& operator=( const TestCaseDecorator& ); + }; diff --git a/3rdParty/CppUnit/src/include/cppunit/extensions/TestFactoryRegistry.h b/3rdParty/CppUnit/src/include/cppunit/extensions/TestFactoryRegistry.h index fc8723e..9d10c94 100644 --- a/3rdParty/CppUnit/src/include/cppunit/extensions/TestFactoryRegistry.h +++ b/3rdParty/CppUnit/src/include/cppunit/extensions/TestFactoryRegistry.h @@ -10,3 +10,3 @@ -#include <cppunit/portability/CppUnitSet.h> +#include <set> #include <cppunit/extensions/TestFactory.h> @@ -19,7 +19,2 @@ class TestSuite; -#if CPPUNIT_NEED_DLL_DECL -// template class CPPUNIT_API std::set<TestFactory *>; -#endif - - /*! \brief Registry for TestFactory. @@ -167,3 +162,3 @@ private: private: - typedef CppUnitSet<TestFactory *, std::less<TestFactory*> > Factories; + typedef std::set<TestFactory *, std::less<TestFactory*> > Factories; Factories m_factories; diff --git a/3rdParty/CppUnit/src/include/cppunit/extensions/TestNamer.h b/3rdParty/CppUnit/src/include/cppunit/extensions/TestNamer.h index 5a6471c..0c8fb31 100644 --- a/3rdParty/CppUnit/src/include/cppunit/extensions/TestNamer.h +++ b/3rdParty/CppUnit/src/include/cppunit/extensions/TestNamer.h @@ -5,6 +5,5 @@ #include <string> +#include <cppunit/tools/StringHelper.h> -#if CPPUNIT_HAVE_RTTI -# include <typeinfo> -#endif +#include <typeinfo> @@ -15,6 +14,3 @@ * - * 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. + * Declares a TestNamer for the specified type * @@ -31,11 +27,4 @@ */ -#if CPPUNIT_USE_TYPEINFO_NAME # define CPPUNIT_TESTNAMER_DECL( variableName, FixtureType ) \ CPPUNIT_NS::TestNamer variableName( typeid(FixtureType) ) -#else -# define CPPUNIT_TESTNAMER_DECL( variableName, FixtureType ) \ - CPPUNIT_NS::TestNamer variableName( std::string(#FixtureType) ) -#endif - - @@ -43,3 +32,2 @@ CPPUNIT_NS_BEGIN - /*! \brief Names a test or a fixture suite. @@ -52,3 +40,2 @@ class CPPUNIT_API TestNamer public: -#if CPPUNIT_HAVE_RTTI /*! \brief Constructs a namer using the fixture's type-info. @@ -57,3 +44,2 @@ public: TestNamer( const std::type_info &typeInfo ); -#endif @@ -80,2 +66,8 @@ public: + template<typename E> + std::string getTestNameFor( const std::string& testMethodName, const E& val) const + { + return getTestNameFor(testMethodName) + " with parameter: " + CPPUNIT_NS::StringHelper::toString(val); + } + protected: @@ -84,3 +76,2 @@ protected: - CPPUNIT_NS_END diff --git a/3rdParty/CppUnit/src/include/cppunit/extensions/TestSuiteBuilderContext.h b/3rdParty/CppUnit/src/include/cppunit/extensions/TestSuiteBuilderContext.h index db26926..72bfa70 100644 --- a/3rdParty/CppUnit/src/include/cppunit/extensions/TestSuiteBuilderContext.h +++ b/3rdParty/CppUnit/src/include/cppunit/extensions/TestSuiteBuilderContext.h @@ -4,3 +4,3 @@ #include <cppunit/Portability.h> -#include <cppunit/portability/CppUnitMap.h> +#include <map> #include <string> @@ -64,2 +64,17 @@ public: + /*! \brief Returns the name of the test for the specified method with the corresponding parameter. + * + * \param testMethodName Name (including a parameter) of the method that implements a test. + * \return A string that is the concatenation of the test fixture name + * (returned by getFixtureName()), \a testMethodName, + * separated using '::' and the parameter. This provides a fairly unique name for a given + * test. The parameter must be convertable to std::string through operator<< + * or a specialization of CPPUNIT_NS::StringHelper::toString needs to exist. + */ + template<typename T> + std::string getTestNameFor( const std::string &testMethodName, const T& value ) const + { + return m_namer.getTestNameFor(testMethodName, value); + } + /*! \brief Adds property pair. @@ -83,3 +98,3 @@ protected: typedef std::pair<std::string,std::string> Property; - typedef CppUnitVector<Property> Properties; + typedef std::vector<Property> Properties; diff --git a/3rdParty/CppUnit/src/include/cppunit/extensions/TypeInfoHelper.h b/3rdParty/CppUnit/src/include/cppunit/extensions/TypeInfoHelper.h index c0ecdbc..1adec83 100644 --- a/3rdParty/CppUnit/src/include/cppunit/extensions/TypeInfoHelper.h +++ b/3rdParty/CppUnit/src/include/cppunit/extensions/TypeInfoHelper.h @@ -5,4 +5,2 @@ -#if CPPUNIT_HAVE_RTTI - #include <typeinfo> @@ -12,3 +10,2 @@ CPPUNIT_NS_BEGIN - /**! \brief Helper to use type_info. @@ -27,7 +24,4 @@ CPPUNIT_NS_BEGIN - CPPUNIT_NS_END -#endif // CPPUNIT_HAVE_RTTI - #endif // CPPUNIT_TYPEINFOHELPER_H |