[Cppunit-cvs] cppunit2/include/cpput assert.h,1.8,1.9 testinfo.h,1.8,1.9
Brought to you by:
blep
From: Baptiste L. <bl...@us...> - 2005-03-01 19:37:16
|
Update of /cvsroot/cppunit/cppunit2/include/cpput In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28913/include/cpput Modified Files: assert.h testinfo.h Log Message: * newAssertion() now takes the assertion type and location as parameter * added checking assertion macros Index: testinfo.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpput/testinfo.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** testinfo.h 27 Feb 2005 10:15:41 -0000 1.8 --- testinfo.h 1 Mar 2005 19:36:51 -0000 1.9 *************** *** 67,71 **** OpenTest::PropertiesAccessor CPPUT_API result(); ! void CPPUT_API newAssertion(); void CPPUT_API setAssertionType( AssertionType type ); --- 67,74 ---- OpenTest::PropertiesAccessor CPPUT_API result(); ! void CPPUT_API newAssertion( AssertionType type, ! const char *fileName, ! unsigned int lineNumber, ! const char *functionName = 0 ); void CPPUT_API setAssertionType( AssertionType type ); *************** *** 73,80 **** AssertionType CPPUT_API assertionType(); - void CPPUT_API setAssertionLocation( const char *fileName, - unsigned int lineNumber, - const char *functionName = 0 ); - OpenTest::Properties &CPPUT_API currentAssertion(); OpenTest::Properties &CPPUT_API currentAssertionActual(); --- 76,79 ---- Index: assert.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpput/assert.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** assert.h 28 Feb 2005 21:36:19 -0000 1.8 --- assert.h 1 Mar 2005 19:36:51 -0000 1.9 *************** *** 112,121 **** ! # define CPPUT_CHECK_POINT() \ ! ::CppUT::TestInfo::newAssertion(), \ ! ::CppUT::TestInfo::setAssertionLocation( __FILE__, __LINE__ ) # define CPPUT_BEGIN_ASSERTION_MACRO() \ ! CPPUT_CHECK_POINT(), --- 112,123 ---- ! # define CPPUT_CHECK_POINT( assertionType ) \ ! ::CppUT::TestInfo::newAssertion( ::CppUT::assertionType, __FILE__, __LINE__) # define CPPUT_BEGIN_ASSERTION_MACRO() \ ! CPPUT_CHECK_POINT( abortingAssertion ), ! ! # define CPPUT_BEGIN_CHECKING_MACRO() \ ! CPPUT_CHECK_POINT( checkingAssertion ), *************** *** 129,153 **** ::CppUT::checkTrue # define CPPUT_ASSERT_EXPR( expression ) \ CPPUT_ASSERT( (expression), #expression ) # define CPPUT_ASSERT_FALSE \ CPPUT_BEGIN_ASSERTION_MACRO() \ ::CppUT::checkFalse # define CPPUT_ASSERT_EXPR_FALSE( expression ) \ CPPUT_ASSERT_FALSE( (expression), #expression ) # define CPPUT_ASSERT_EQUAL \ CPPUT_BEGIN_ASSERTION_MACRO() \ ::CppUT::checkEquals # define CPPUT_ASSERT_NOT_EQUAL \ CPPUT_BEGIN_ASSERTION_MACRO() \ ::CppUT::checkNotEquals ! # define CPPUT_ASSERT_THROW( expression, ExceptionType ) \ do { \ ! CPPUT_CHECK_POINT(); \ bool cpputExceptionThrown_ = false; \ try { \ --- 131,177 ---- ::CppUT::checkTrue + # define CPPUT_CHECK \ + CPPUT_BEGIN_CHECKING_MACRO() \ + ::CppUT::checkTrue + # define CPPUT_ASSERT_EXPR( expression ) \ CPPUT_ASSERT( (expression), #expression ) + # define CPPUT_CHECK_EXPR( expression ) \ + CPPUT_CHECK( (expression), #expression ) + # define CPPUT_ASSERT_FALSE \ CPPUT_BEGIN_ASSERTION_MACRO() \ ::CppUT::checkFalse + # define CPPUT_CHECK_FALSE \ + CPPUT_BEGIN_CHECKING_MACRO() \ + ::CppUT::checkFalse + # define CPPUT_ASSERT_EXPR_FALSE( expression ) \ CPPUT_ASSERT_FALSE( (expression), #expression ) + # define CPPUT_CHECK_EXPR_FALSE( expression ) \ + CPPUT_CHECK_FALSE( (expression), #expression ) + # define CPPUT_ASSERT_EQUAL \ CPPUT_BEGIN_ASSERTION_MACRO() \ ::CppUT::checkEquals + # define CPPUT_CHECK_EQUAL \ + CPPUT_BEGIN_CHECKING_MACRO() \ + ::CppUT::checkEquals + # define CPPUT_ASSERT_NOT_EQUAL \ CPPUT_BEGIN_ASSERTION_MACRO() \ ::CppUT::checkNotEquals ! # define CPPUT_CHECK_NOT_EQUAL \ ! CPPUT_BEGIN_CHECKING_MACRO() \ ! ::CppUT::checkNotEquals ! ! # define _CPPUT_ASSERT_THROW_IMPL( assertionType, expression, ExceptionType ) \ do { \ ! CPPUT_CHECK_POINT( assertionType ); \ bool cpputExceptionThrown_ = false; \ try { \ *************** *** 164,169 **** } while ( false ) ! # define CPPUT_ASSERT_NO_THROW( expression ) \ try { \ expression; \ } catch ( const std::exception &e ) { \ --- 188,200 ---- } while ( false ) ! # define CPPUT_ASSERT_THROW( expression, ExceptionType ) \ ! _CPPUT_ASSERT_THROW_IMPL( abortingAssertion, expression, ExceptionType ) ! ! # define CPPUT_CHECK_THROW( expression, ExceptionType ) \ ! _CPPUT_CHECK_THROW_IMPL( checkingAssertion, expression, ExceptionType ) ! ! # define _CPPUT_ASSERT_NO_THROW_IMPL( assertionType, expression ) \ try { \ + CPPUT_CHECK_POINT( assertionType ); \ expression; \ } catch ( const std::exception &e ) { \ *************** *** 177,180 **** --- 208,218 ---- } + # define CPPUT_ASSERT_NO_THROW( expression ) \ + _CPPUT_ASSERT_NO_THROW_IMPL( abortingAssertion, expression ) + + # define CPPUT_CHECK_NO_THROW( expression ) \ + _CPPUT_ASSERT_NO_THROW_IMPL( checkingAssertion, expression ) + + // Notes: implementing that assertion checking is a bit tricky since all the state // about the current test/assertions is stored in a "static" and *************** *** 184,191 **** // context for the tested assertion. After the assertion, the // result of the assertion (did it failed), and the test result ! // properties are captured for later introspection. ! # define CPPUT_ASSERT_ASSERTION_FAIL_MESSAGE( assertion, message ) \ { \ ! CPPUT_CHECK_POINT(); \ OpenTest::Properties result; \ bool assertionFailed = false; \ --- 222,229 ---- // context for the tested assertion. After the assertion, the // result of the assertion (did it failed), and the test result ! // properties are captured for later inspection. ! # define _CPPUT_ASSERT_ASSERTION_FAIL_MESSAGE_IMPL( assertionType, assertion, message ) \ { \ ! CPPUT_CHECK_POINT( assertionType ); \ OpenTest::Properties result; \ bool assertionFailed = false; \ *************** *** 203,212 **** } ! # define CPPUT_ASSERT_ASSERTION_FAIL( assertion ) \ CPPUT_ASSERT_ASSERTION_FAIL_MESSAGE( assertion, ::CppUT::Message() ) ! # define CPPUT_ASSERT_ASSERTION_PASS_MESSAGE( assertion, message ) \ { \ ! CPPUT_CHECK_POINT(); \ OpenTest::Properties result; \ bool assertionFailed = false; \ --- 241,259 ---- } ! # define CPPUT_ASSERT_ASSERTION_FAIL_MESSAGE( assertion, message ) \ ! _CPPUT_ASSERT_ASSERTION_FAIL_MESSAGE_IMPL( abortingAssertion, assertion, message ) ! ! # define CPPUT_CHECK_ASSERTION_FAIL_MESSAGE( assertion, message ) \ ! _CPPUT_CHECK_ASSERTION_FAIL_MESSAGE_IMPL( checkingAssertion, assertion, message ) ! ! # define CPPUT_ASSERT_ASSERTION_FAIL( assertion ) \ CPPUT_ASSERT_ASSERTION_FAIL_MESSAGE( assertion, ::CppUT::Message() ) ! # define CPPUT_CHECK_ASSERTION_FAIL( assertion ) \ ! CPPUT_CHECK_ASSERTION_FAIL_MESSAGE( assertion, ::CppUT::Message() ) ! ! # define _CPPUT_ASSERT_ASSERTION_PASS_MESSAGE_IMPL( assertionType, assertion, message ) \ { \ ! CPPUT_CHECK_POINT( assertionType ); \ OpenTest::Properties result; \ bool assertionFailed = false; \ *************** *** 224,230 **** --- 271,286 ---- } + # define CPPUT_ASSERT_ASSERTION_PASS_MESSAGE( assertion, message ) \ + _CPPUT_ASSERT_ASSERTION_PASS_MESSAGE_IMPL( abortingAssertion, assertion, message ) + + # define CPPUT_CHECK_ASSERTION_PASS_MESSAGE( assertion, message ) \ + _CPPUT_CHECK_ASSERTION_PASS_MESSAGE_IMPL( checkingAssertion, assertion, message ) + # define CPPUT_ASSERT_ASSERTION_PASS( assertion ) \ CPPUT_ASSERT_ASSERTION_PASS_MESSAGE( assertion, ::CppUT::Message() ) + # define CPPUT_CHECK_ASSERTION_PASS( assertion ) \ + CPPUT_CHECK_ASSERTION_PASS_MESSAGE( assertion, ::CppUT::Message() ) + #endif // CPPUT_ASSERT_H_INCLUDED |