catch3
Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.
Clonegit clone https://git.progmasoft.com/catch3
Attempt to prevent analyser warnings about dereferencing null.
- Commit
59d556907d28129a8df1e0c5610c85d1e5788535- Author
- Phil Nash ·
- Parents
a2d8f774d22b
Changes
include/internal/catch_context_impl.hpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/include/internal/catch_context_impl.hpp b/include/internal/catch_context_impl.hpp index 0dd326c5..c29a07f3 100644 --- a/include/internal/catch_context_impl.hpp +++ b/include/internal/catch_context_impl.hpp @@ -23,10 +23,16 @@ namespace Catch { public: // IContext virtual IResultCapture& getResultCapture() { - return *m_resultCapture; + if( m_resultCapture ) + return *m_resultCapture; + else + throw std::logic_error( "No result capture instance" ); } virtual IRunner& getRunner() { - return *m_runner; + if( m_runner ) + return *m_runner; + else + throw std::logic_error( "No runner instance" ); } virtual size_t getGeneratorIndex( std::string const& fileInfo, size_t totalSize ) { return getGeneratorsForCurrentTest()