summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '3rdParty/CppUnit/src/include/cppunit/TestCaller.h')
-rw-r--r--3rdParty/CppUnit/src/include/cppunit/TestCaller.h31
1 files changed, 17 insertions, 14 deletions
diff --git a/3rdParty/CppUnit/src/include/cppunit/TestCaller.h b/3rdParty/CppUnit/src/include/cppunit/TestCaller.h
index dc4d82e..fbf3902 100644
--- a/3rdParty/CppUnit/src/include/cppunit/TestCaller.h
+++ b/3rdParty/CppUnit/src/include/cppunit/TestCaller.h
@@ -1,14 +1,16 @@
#ifndef CPPUNIT_TESTCALLER_H // -*- C++ -*-
#define CPPUNIT_TESTCALLER_H
#include <cppunit/Exception.h>
#include <cppunit/TestCase.h>
+#include <functional>
-#if CPPUNIT_USE_TYPEINFO_NAME
+
+#if defined(CPPUNIT_USE_TYPEINFO_NAME)
# include <cppunit/extensions/TypeInfoHelper.h>
#endif
CPPUNIT_NS_BEGIN
@@ -30,13 +32,13 @@ private:
*/
template<class ExceptionType>
struct ExpectedExceptionTraits
{
static void expectedException()
{
-#if CPPUNIT_USE_TYPEINFO_NAME
+#if defined(CPPUNIT_USE_TYPEINFO_NAME)
throw Exception( Message(
"expected exception not thrown",
"Expected exception type: " +
TypeInfoHelper::getClassName( typeid( ExceptionType ) ) ) );
#else
throw Exception( "expected exception not thrown" );
@@ -113,13 +115,13 @@ public:
* \param test the method this TestCaller calls in runTest()
*/
TestCaller( std::string name, TestMethod test ) :
TestCase( name ),
m_ownFixture( true ),
m_fixture( new Fixture() ),
- m_test( test )
+ m_test_function( std::bind(test, m_fixture) )
{
}
/*!
* Constructor for TestCaller.
* This constructor does not create a new Fixture instance but accepts
@@ -130,13 +132,13 @@ public:
* \param fixture the Fixture to invoke the test method on.
*/
TestCaller(std::string name, TestMethod test, Fixture& fixture) :
TestCase( name ),
m_ownFixture( false ),
m_fixture( &fixture ),
- m_test( test )
+ m_test_function( std::bind(test, &fixture) )
{
}
/*!
* Constructor for TestCaller.
* This constructor does not create a new Fixture instance but accepts
@@ -147,32 +149,33 @@ public:
* \param fixture the Fixture to invoke the test method on.
*/
TestCaller(std::string name, TestMethod test, Fixture* fixture) :
TestCase( name ),
m_ownFixture( true ),
m_fixture( fixture ),
- m_test( test )
+ m_test_function( std::bind(test, fixture) )
{
}
+
+ TestCaller(std::string name, std::function<void()> test_function, Fixture* fixture):
+ TestCase(name),
+ m_ownFixture(true),
+ m_fixture(fixture),
+ m_test_function(test_function)
+ {
+ }
~TestCaller()
{
if (m_ownFixture)
delete m_fixture;
}
void runTest()
{
-// try {
- (m_fixture->*m_test)();
-// }
-// catch ( ExpectedException & ) {
-// return;
-// }
-
-// ExpectedExceptionTraits<ExpectedException>::expectedException();
+ m_test_function();
}
void setUp()
{
m_fixture->setUp ();
}
@@ -191,13 +194,13 @@ private:
TestCaller( const TestCaller &other );
TestCaller &operator =( const TestCaller &other );
private:
bool m_ownFixture;
Fixture *m_fixture;
- TestMethod m_test;
+ std::function<void()> m_test_function;
};
CPPUNIT_NS_END