[Cppunit-cvs] cppunit2/include/cpput assert.h,1.14,1.15 testinfo.h,1.16,1.17
Brought to you by:
blep
From: Baptiste L. <bl...@us...> - 2005-11-09 20:04:13
|
Update of /cvsroot/cppunit/cppunit2/include/cpput In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28417/include/cpput Modified Files: assert.h testinfo.h Log Message: - added CPPUT_SKIP_TEST to skip the current test - added CPPUT_IGNORE_FAILURE( assertion ) to ignore a failure caused by an assertion, but count the failed assertion Index: testinfo.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpput/testinfo.h,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** testinfo.h 8 Nov 2005 21:44:54 -0000 1.16 --- testinfo.h 9 Nov 2005 20:04:06 -0000 1.17 *************** *** 6,9 **** --- 6,10 ---- # include <cpptl/intrusiveptr.h> # include <json/value.h> + # include <stdexcept> /// @todo find a away to integrate context with multiple thread. *************** *** 20,23 **** --- 21,33 ---- }; + class CPPUT_API SkipTestException : public std::runtime_error + { + public: + SkipTestException() + : std::runtime_error( "SkipTestException" ) + { + } + }; + class SourceLocation { *************** *** 108,111 **** --- 118,123 ---- bool hasFailed() const; + bool hasPassed() const; + bool wasSkipped() const; void setStatistics( const std::string &name, *************** *** 185,188 **** --- 197,202 ---- void setAbortingAssertionMode( AbortingAssertionMode mode ); + void ignoredFailure(); + void log( const Json::Value &log ); *************** *** 195,198 **** --- 209,213 ---- unsigned int assertionCount_; unsigned int failedAssertionCount_; + unsigned int ignoredAssertionCount_; }; Index: assert.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpput/assert.h,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** assert.h 8 Nov 2005 21:44:54 -0000 1.14 --- assert.h 9 Nov 2005 20:04:06 -0000 1.15 *************** *** 114,117 **** --- 114,119 ---- const Message &message = Message() ); + void CPPUT_API skipCurrentTest(); + } // namespace CppUT *************** *** 132,136 **** CPPUT_CHECK_POINT( checkingAssertion ), - // basic assertions # define CPPUT_FAIL \ --- 134,137 ---- *************** *** 245,258 **** { \ CPPUT_CHECK_POINT( assertionType ); \ ! bool assertionFailed = false; \ { \ ! ::CppUT::TestInfo::ScopedContextOverride contextSwitch; \ try { \ assertion; \ } catch ( const ::CppUT::AbortingAssertionException & ) { \ } \ ! assertionFailed = ::CppUT::TestInfo::threadInstance().getUpdatedTestStatus().hasFailed(); \ } \ ! ::CppUT::checkAssertionFail( assertionFailed, message ); \ } --- 246,259 ---- { \ CPPUT_CHECK_POINT( assertionType ); \ ! bool assertionFailedCppUT_ = false; \ { \ ! ::CppUT::TestInfo::ScopedContextOverride contextSwitchCppUT_; \ try { \ assertion; \ } catch ( const ::CppUT::AbortingAssertionException & ) { \ } \ ! assertionFailedCppUT_ = ::CppUT::TestInfo::threadInstance().getUpdatedTestStatus().hasFailed(); \ } \ ! ::CppUT::checkAssertionFail( assertionFailedCppUT_, message ); \ } *************** *** 272,285 **** { \ CPPUT_CHECK_POINT( assertionType ); \ ! bool assertionFailed = false; \ { \ ! ::CppUT::TestInfo::ScopedContextOverride contextSwitch; \ try { \ assertion; \ } catch ( const ::CppUT::AbortingAssertionException & ) { \ } \ ! assertionFailed = ::CppUT::TestInfo::threadInstance().getUpdatedTestStatus().hasFailed(); \ } \ ! ::CppUT::checkAssertionPass( assertionFailed, message ); \ } --- 273,286 ---- { \ CPPUT_CHECK_POINT( assertionType ); \ ! bool assertionFailedCppUT_ = false; \ { \ ! ::CppUT::TestInfo::ScopedContextOverride contextSwitchCppUT_; \ try { \ assertion; \ } catch ( const ::CppUT::AbortingAssertionException & ) { \ } \ ! assertionFailedCppUT_ = ::CppUT::TestInfo::threadInstance().getUpdatedTestStatus().hasFailed(); \ } \ ! ::CppUT::checkAssertionPass( assertionFailedCppUT_, message ); \ } *************** *** 296,299 **** --- 297,317 ---- CPPUT_CHECK_ASSERTION_PASS_MESSAGE( assertion, ::CppUT::Message() ) + # define CPPUT_SKIP_TEST \ + ::CppUT::skipCurrentTest + + # define CPPUT_IGNORE_FAILURE( assertion ) \ + { \ + bool succeedCppUT_ = false; \ + { \ + ::CppUT::TestInfo::ScopedContextOverride contextSwitchCppUT_; \ + try { \ + assertion; \ + } catch ( const ::CppUT::AbortingAssertionException & ) { \ + } \ + succeedCppUT_ = ::CppUT::TestInfo::threadInstance().getUpdatedTestStatus().hasPassed(); \ + } \ + ::CppUT::checkAssertionFail( !succeedCppUT_, #assertion ); \ + ::CppUT::TestInfo::threadInstance().ignoredFailure(); \ + } #endif // CPPUT_ASSERT_H_INCLUDED |