[Cppunit-cvs] cppunit2/include/cpput assert.h,1.11,1.12 forwards.h,1.17,1.18 testinfo.h,1.12,1.13
Brought to you by:
blep
From: Baptiste L. <bl...@us...> - 2005-08-10 21:34:49
|
Update of /cvsroot/cppunit/cppunit2/include/cpput In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27815/include/cpput Modified Files: assert.h forwards.h testinfo.h Log Message: * Replaced function in namespace TestInfo by exposing the TestInfoData class and renaming it TestInfo. TestInfo in now an exposed per thread singleton. * startNewTest() is now called from TestCase::runTest() instead of being the test runner responsability. There still a few call to this method in cpput bootstrap test (which use assertion without run a test case). Index: testinfo.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpput/testinfo.h,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** testinfo.h 10 Aug 2005 07:42:52 -0000 1.12 --- testinfo.h 10 Aug 2005 21:34:29 -0000 1.13 *************** *** 4,7 **** --- 4,8 ---- # include <cpput/forwards.h> # include <cpput/message.h> + # include <cpptl/intrusiveptr.h> # include <opentest/properties.h> *************** *** 122,126 **** ! class CPPUT_API TestResultUpdater { public: --- 123,127 ---- ! class CPPUT_API TestResultUpdater : public CppTL::IntrusiveCount { public: *************** *** 148,152 **** }; ! namespace TestInfo { class CPPUT_API ScopedContextOverride { --- 149,155 ---- }; ! class TestInfo : public CppTL::IntrusiveCount ! { ! public: class CPPUT_API ScopedContextOverride { *************** *** 157,192 **** private: ! TestInfoDataPtr context_; }; ! void CPPUT_API setTestResultUpdater( TestResultUpdater &updater ); ! ! void CPPUT_API startNewTest(); ! TestStatus &CPPUT_API getUpdatedTestStatus(); ! void CPPUT_API newAssertion( AssertionType type, ! const char *fileName, ! unsigned int lineNumber, ! const char *functionName = 0 ); ! Assertion &CPPUT_API currentAssertion(); ! /// Realize the current assertion. ! /// Add data about the current assertion to the test result. ! /// @exception AbortingAssertionException If assertionType was set to ! /// abortingAssertion. ! void CPPUT_API realizeAssertion(); ! void CPPUT_API handleUnexpectedException( const Assertion &fault ); ! void CPPUT_API log( const OpenTest::Value &log ); - /// Only for using for unit test of the framework itself void setAbortingAssertionMode( AbortingAssertionMode mode ); ! } // namespace TestInfo } // namespace CppUT --- 160,217 ---- private: ! TestInfoPtr context_; }; + static TestInfo &threadInstance(); ! TestInfo(); ! void setTestResultUpdater( TestResultUpdater &updater ); ! void startNewTest(); ! TestStatus &getUpdatedTestStatus(); ! void newAssertion( AssertionType type, ! const char *fileName, ! unsigned int lineNumber, ! const char *functionName = 0 ); ! ! Assertion ¤tAssertion(); ! void realizeAssertion(); ! void handleUnexpectedException( const Assertion &fault ); void setAbortingAssertionMode( AbortingAssertionMode mode ); ! void log( const OpenTest::Value &log ); ! ! private: ! TestResultUpdater *updater_; ! TestStatus testStatus_; ! Assertion currentAssertion_; ! AssertionType assertionType_; ! AbortingAssertionMode abortingAssertionMode_; ! unsigned int assertionCount_; ! unsigned int failedAssertionCount_; ! }; ! ! ! //void CPPUT_API newAssertion( AssertionType type, ! // const char *fileName, ! // unsigned int lineNumber, ! // const char *functionName = 0 ); ! ! Assertion &CPPUT_API currentAssertion(); ! ! /// Realize the current assertion. ! /// Add data about the current assertion to the test result. ! /// @exception AbortingAssertionException If assertionType was set to ! /// abortingAssertion. ! void CPPUT_API realizeAssertion(); ! ! void CPPUT_API log( const OpenTest::Value &log ); } // namespace CppUT Index: assert.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpput/assert.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** assert.h 8 Aug 2005 22:10:20 -0000 1.11 --- assert.h 10 Aug 2005 21:34:29 -0000 1.12 *************** *** 116,121 **** // Available if __C99__FUNC__ is defined: // http://publib.boulder.ibm.com/infocenter/pseries/index.jsp?topic=/com.ibm.vacpp7a.doc/language/ref/clrapxaix_macros.htm ! # define CPPUT_CHECK_POINT( assertionType ) \ ! ::CppUT::TestInfo::newAssertion( ::CppUT::assertionType, __FILE__, __LINE__) # define CPPUT_BEGIN_ASSERTION_MACRO() \ --- 116,123 ---- // Available if __C99__FUNC__ is defined: // http://publib.boulder.ibm.com/infocenter/pseries/index.jsp?topic=/com.ibm.vacpp7a.doc/language/ref/clrapxaix_macros.htm ! # define CPPUT_CHECK_POINT( assertionType ) \ ! ::CppUT::TestInfo::threadInstance().newAssertion( ::CppUT::assertionType, \ ! __FILE__, \ ! __LINE__ ) # define CPPUT_BEGIN_ASSERTION_MACRO() \ *************** *** 227,243 **** // 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 ); \ ! bool assertionFailed = false; \ ! { \ ! ::CppUT::TestInfo::ScopedContextOverride contextSwitch; \ ! try { \ ! assertion; \ ! } catch ( const ::CppUT::AbortingAssertionException & ) { \ ! } \ ! assertionFailed = ::CppUT::TestInfo::getUpdatedTestStatus().hasFailed(); \ ! } \ ! ::CppUT::checkAssertionFail( assertionFailed, message ); \ } --- 229,245 ---- // 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 ); \ ! bool assertionFailed = false; \ ! { \ ! ::CppUT::TestInfo::ScopedContextOverride contextSwitch; \ ! try { \ ! assertion; \ ! } catch ( const ::CppUT::AbortingAssertionException & ) { \ ! } \ ! assertionFailed = ::CppUT::TestInfo::threadInstance().getUpdatedTestStatus().hasFailed(); \ ! } \ ! ::CppUT::checkAssertionFail( assertionFailed, message ); \ } *************** *** 254,270 **** CPPUT_CHECK_ASSERTION_FAIL_MESSAGE( assertion, ::CppUT::Message() ) ! # define _CPPUT_ASSERT_ASSERTION_PASS_MESSAGE_IMPL( assertionType, assertion, message ) \ ! { \ ! CPPUT_CHECK_POINT( assertionType ); \ ! bool assertionFailed = false; \ ! { \ ! ::CppUT::TestInfo::ScopedContextOverride contextSwitch; \ ! try { \ ! assertion; \ ! } catch ( const ::CppUT::AbortingAssertionException & ) { \ ! } \ ! assertionFailed = ::CppUT::TestInfo::getUpdatedTestStatus().hasFailed(); \ ! } \ ! ::CppUT::checkAssertionPass( assertionFailed, message ); \ } --- 256,272 ---- CPPUT_CHECK_ASSERTION_FAIL_MESSAGE( assertion, ::CppUT::Message() ) ! # define _CPPUT_ASSERT_ASSERTION_PASS_MESSAGE_IMPL( assertionType, assertion, message ) \ ! { \ ! 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 ); \ } Index: forwards.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpput/forwards.h,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** forwards.h 6 Aug 2005 22:24:53 -0000 1.17 --- forwards.h 10 Aug 2005 21:34:29 -0000 1.18 *************** *** 18,22 **** class ExceptionGuardElement; class ExceptionGuard; ! class TestInfoData; class TestResultUpdater; class TestSuite; --- 18,22 ---- class ExceptionGuardElement; class ExceptionGuard; ! class TestInfo; class TestResultUpdater; class TestSuite; *************** *** 27,33 **** typedef CppTL::SharedPtr<ExceptionGuardElement> ExceptionGuardElementPtr; typedef CppTL::IntrusivePtr<Test> TestPtr; ! typedef CppTL::SharedPtr<TestInfoData> TestInfoDataPtr; typedef CppTL::IntrusivePtr<TestSuite> TestSuitePtr; ! typedef CppTL::SharedPtr<TestResultUpdater> TestResultUpdaterPtr; --- 27,33 ---- typedef CppTL::SharedPtr<ExceptionGuardElement> ExceptionGuardElementPtr; typedef CppTL::IntrusivePtr<Test> TestPtr; ! typedef CppTL::IntrusivePtr<TestInfo> TestInfoPtr; typedef CppTL::IntrusivePtr<TestSuite> TestSuitePtr; ! typedef CppTL::IntrusivePtr<TestResultUpdater> TestResultUpdaterPtr; |