diff options
| author | Phil Nash | 2012-02-10 08:30:13 +0000 |
|---|---|---|
| committer | Phil Nash | 2012-02-10 08:30:13 +0000 |
| commit | a162e22fa3080faa7c3051677ef24a14b9f8daf4 (patch) | |
| tree | c63e72a22cd308f29604a27dd707568410b60a3a /include/internal | |
| parent | 6abf702895c5433f0790845b76eb6554d6cc7445 (diff) | |
| download | catch3-a162e22fa3080faa7c3051677ef24a14b9f8daf4.tar.gz | |
Added CHECKED_IF and CHECKED_ELSE
Diffstat (limited to 'include/internal')
| -rw-r--r-- | include/internal/catch_capture.hpp | 10 | ||||
| -rw-r--r-- | include/internal/catch_interfaces_capture.h | 3 | ||||
| -rw-r--r-- | include/internal/catch_resultinfo.hpp | 7 | ||||
| -rw-r--r-- | include/internal/catch_runner_impl.hpp | 13 |
4 files changed, 28 insertions, 5 deletions
diff --git a/include/internal/catch_capture.hpp b/include/internal/catch_capture.hpp index 738b8214..2449f60b 100644 --- a/include/internal/catch_capture.hpp +++ b/include/internal/catch_capture.hpp @@ -688,6 +688,16 @@ inline bool isTrue if( Catch::isTrue( false ) ){ bool internal_catch_dummyResult = ( expr ); Catch::isTrue( internal_catch_dummyResult ); } /////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_IF( expr, isNot, stopOnFailure, macroName ) \ + INTERNAL_CATCH_TEST( expr, isNot, stopOnFailure, macroName ); \ + if( Catch::Hub::getResultCapture().getLastResult()->ok() ) + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_ELSE( expr, isNot, stopOnFailure, macroName ) \ + INTERNAL_CATCH_TEST( expr, isNot, stopOnFailure, macroName ); \ + if( !Catch::Hub::getResultCapture().getLastResult()->ok() ) + +/////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_NO_THROW( expr, stopOnFailure, macroName ) \ try \ { \ diff --git a/include/internal/catch_interfaces_capture.h b/include/internal/catch_interfaces_capture.h index f3a530d6..e74563ef 100644 --- a/include/internal/catch_interfaces_capture.h +++ b/include/internal/catch_interfaces_capture.h @@ -20,6 +20,7 @@ namespace Catch class TestCaseInfo; class ScopedInfo; class MutableResultInfo; + class ResultInfo; struct IResultCapture { @@ -66,6 +67,8 @@ namespace Catch ) = 0; virtual std::string getCurrentTestName + () const = 0; + virtual const ResultInfo* getLastResult () const = 0; }; diff --git a/include/internal/catch_resultinfo.hpp b/include/internal/catch_resultinfo.hpp index 258cc47c..f9da25a8 100644 --- a/include/internal/catch_resultinfo.hpp +++ b/include/internal/catch_resultinfo.hpp @@ -63,10 +63,11 @@ namespace Catch } /////////////////////////////////////////////////////////////////////////// - virtual ~ResultInfo + virtual ~ResultInfo () - { - } + { + } + /////////////////////////////////////////////////////////////////////////// bool ok () diff --git a/include/internal/catch_runner_impl.hpp b/include/internal/catch_runner_impl.hpp index 0bb28203..17ef47fe 100644 --- a/include/internal/catch_runner_impl.hpp +++ b/include/internal/catch_runner_impl.hpp @@ -548,6 +548,14 @@ namespace Catch ? m_runningTest->getTestCaseInfo().getName() : ""; } + + /////////////////////////////////////////////////////////////////////////// + virtual const ResultInfo* getLastResult + () + const + { + return &m_lastResult; + } private: @@ -556,10 +564,10 @@ namespace Catch () { testEnded( m_currentResult ); + m_lastResult = m_currentResult; - bool ok = m_currentResult.ok(); m_currentResult = MutableResultInfo(); - if( ok ) + if( m_lastResult.ok() ) return ResultAction::None; else if( shouldDebugBreak() ) return ResultAction::DebugFailed; @@ -612,6 +620,7 @@ namespace Catch private: RunningTest* m_runningTest; MutableResultInfo m_currentResult; + ResultInfo m_lastResult; const Config& m_config; std::size_t m_successes; |