diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2021-10-01 02:41:11 +0800 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2021-10-01 02:41:49 +0800 |
commit | 40fd60a4743a9e587b197a3991bb5f7e451e6b8a (patch) | |
tree | 6c2741434a6912648d4b3529b538a13631bd2945 | |
parent | 6e077ed0705d9bf67f1b643eec367d5815a589b2 (diff) | |
download | cppunit-40fd60a4743a9e587b197a3991bb5f7e451e6b8a.tar.gz |
get rid of old casting macros
-rw-r--r-- | examples/cppunittest/MockFunctor.h | 2 | ||||
-rw-r--r-- | examples/cppunittest/MockTestCase.cpp | 2 | ||||
-rw-r--r-- | include/cppunit/Portability.h | 15 | ||||
-rw-r--r-- | include/cppunit/config/config-msvc6.h | 3 | ||||
-rw-r--r-- | include/cppunit/extensions/TestSuiteBuilderContext.h | 2 | ||||
-rw-r--r-- | src/cppunit/Exception.cpp | 2 | ||||
-rw-r--r-- | src/cppunit/Test.cpp | 8 |
7 files changed, 8 insertions, 26 deletions
diff --git a/examples/cppunittest/MockFunctor.h b/examples/cppunittest/MockFunctor.h index 888273b..d739d74 100644 --- a/examples/cppunittest/MockFunctor.h +++ b/examples/cppunittest/MockFunctor.h @@ -23,7 +23,7 @@ public: bool operator()() const { - ++CPPUNIT_CONST_CAST(MockFunctor *,this)->m_actualCallCount; + ++const_cast<MockFunctor*>( this )->m_actualCallCount; if ( m_shouldThrow ) { diff --git a/examples/cppunittest/MockTestCase.cpp b/examples/cppunittest/MockTestCase.cpp index 033bba5..ae01193 100644 --- a/examples/cppunittest/MockTestCase.cpp +++ b/examples/cppunittest/MockTestCase.cpp @@ -33,7 +33,7 @@ MockTestCase::~MockTestCase() int MockTestCase::countTestCases() const { - MockTestCase *mutableThis = CPPUNIT_CONST_CAST(MockTestCase *, this ); + MockTestCase *mutableThis = const_cast<MockTestCase*>( this ); ++mutableThis->m_actualCountTestCasesCallCount; if ( m_expectCountTestCasesCall ) { diff --git a/include/cppunit/Portability.h b/include/cppunit/Portability.h index c2e3bd0..4efa9af 100644 --- a/include/cppunit/Portability.h +++ b/include/cppunit/Portability.h @@ -73,21 +73,6 @@ #endif #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 ) \ - const_cast<TargetType>( pointer ) - -# define CPPUNIT_STATIC_CAST( TargetType, pointer ) \ - static_cast<TargetType>( pointer ) -#else // defined( CPPUNIT_HAVE_CPP_CAST ) -# define CPPUNIT_CONST_CAST( TargetType, pointer ) \ - ((TargetType)( pointer )) -# define CPPUNIT_STATIC_CAST( TargetType, pointer ) \ - ((TargetType)( pointer )) -#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) diff --git a/include/cppunit/config/config-msvc6.h b/include/cppunit/config/config-msvc6.h index 0edc059..ac03c89 100644 --- a/include/cppunit/config/config-msvc6.h +++ b/include/cppunit/config/config-msvc6.h @@ -47,9 +47,6 @@ # define CPPUNIT_COMPILER_LOCATION_FORMAT "%p(%l):" #endif -// Define to 1 if the compiler support C++ style cast. -#define CPPUNIT_HAVE_CPP_CAST 1 - /* define to 1 if the compiler has _finite() */ #ifndef CPPUNIT_HAVE__FINITE #define CPPUNIT_HAVE__FINITE 1 diff --git a/include/cppunit/extensions/TestSuiteBuilderContext.h b/include/cppunit/extensions/TestSuiteBuilderContext.h index f66a203..acea374 100644 --- a/include/cppunit/extensions/TestSuiteBuilderContext.h +++ b/include/cppunit/extensions/TestSuiteBuilderContext.h @@ -135,7 +135,7 @@ public: */ FixtureType *makeFixture() const { - return CPPUNIT_STATIC_CAST( FixtureType *, + return static_cast<FixtureType*>( TestSuiteBuilderContextBase::makeTestFixture() ); } }; diff --git a/src/cppunit/Exception.cpp b/src/cppunit/Exception.cpp index 9401fbc..969e716 100644 --- a/src/cppunit/Exception.cpp +++ b/src/cppunit/Exception.cpp @@ -70,7 +70,7 @@ Exception::operator =( const Exception& other ) const char* Exception::what() const noexcept { - Exception *mutableThis = CPPUNIT_CONST_CAST( Exception *, this ); + Exception *mutableThis = const_cast<Exception*>( this ); mutableThis->m_whatMessage = m_message.shortDescription() + "\n" + m_message.details(); return m_whatMessage.c_str(); diff --git a/src/cppunit/Test.cpp b/src/cppunit/Test.cpp index fef8be7..010ea15 100644 --- a/src/cppunit/Test.cpp +++ b/src/cppunit/Test.cpp @@ -19,7 +19,7 @@ Test * Test::findTest( const std::string &testName ) const { TestPath path; - Test *mutableThis = CPPUNIT_CONST_CAST( Test *, this ); + Test *mutableThis = const_cast<Test*>( this ); mutableThis->findTestPath( testName, path ); if ( !path.isValid() ) throw std::invalid_argument( "No test named <" + testName + "> found in test <" @@ -32,7 +32,7 @@ bool Test::findTestPath( const std::string &testName, TestPath &testPath ) const { - Test *mutableThis = CPPUNIT_CONST_CAST( Test *, this ); + Test *mutableThis = const_cast<Test*>( this ); if ( getName() == testName ) { testPath.add( mutableThis ); @@ -57,7 +57,7 @@ bool Test::findTestPath( const Test *test, TestPath &testPath ) const { - Test *mutableThis = CPPUNIT_CONST_CAST( Test *, this ); + Test *mutableThis = const_cast<Test*>( this ); if ( this == test ) { testPath.add( mutableThis ); @@ -81,7 +81,7 @@ Test::findTestPath( const Test *test, TestPath Test::resolveTestPath( const std::string &testPath ) const { - Test *mutableThis = CPPUNIT_CONST_CAST( Test *, this ); + Test *mutableThis = const_cast<Test*>( this ); return TestPath( mutableThis, testPath ); } |