Progmasoft Git

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

Catches incorrect reporter name as per #107

Commit
61756974d0246b2bba4b030d96e1d4d46982be04
Author
Phil Nash ·
Parents
b084562b3bd2

Files · Download .tar.gz

Changes

 include/catch_runner.hpp       |  6 ++++++
 include/internal/catch_ptr.hpp |  9 +++++++--
 single_include/catch.hpp       | 17 ++++++++++++++---
 3 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/include/catch_runner.hpp b/include/catch_runner.hpp
index 752a6b84..7b0eda70 100644
--- a/include/catch_runner.hpp
+++ b/include/catch_runner.hpp
@@ -36,6 +36,12 @@ namespace Catch {
         
         Ptr<IReporter> reporter = getCurrentContext().getReporterRegistry().create( reporterName, reporterConfig );
 
+        if( !reporter )
+        {
+            std::cerr << "No reporter registered with name: " << reporterName << "'" << std::endl;
+            return (std::numeric_limits<int>::max)();
+        }
+        
         if( !config.data().stream.empty() ) {
             if( config.data().stream[0] == '%' )
                 config.useStream( config.data().stream.substr( 1 ) );
diff --git a/include/internal/catch_ptr.hpp b/include/internal/catch_ptr.hpp
index 3ebe9f74..73e53ac9 100644
--- a/include/internal/catch_ptr.hpp
+++ b/include/internal/catch_ptr.hpp
@@ -20,10 +20,12 @@ namespace Catch {
     public:
         Ptr() : m_p( NULL ){}
         Ptr( T* p ) : m_p( p ){
-            m_p->addRef();
+            if( m_p )
+                m_p->addRef();
         }
         Ptr( const Ptr& other ) : m_p( other.m_p ){
-            m_p->addRef();
+            if( m_p )
+                m_p->addRef();
         }
         ~Ptr(){
             if( m_p )
@@ -63,6 +65,9 @@ namespace Catch {
         const T* operator->() const{
             return m_p;
         }
+        bool operator !() const {
+            return m_p == NULL;
+        }
         
     private:
         T* m_p;
diff --git a/single_include/catch.hpp b/single_include/catch.hpp
index 69a58735..50331889 100644
--- a/single_include/catch.hpp
+++ b/single_include/catch.hpp
@@ -1,5 +1,5 @@
 /*
- *  Generated: 2012-07-28 20:22:25.519628
+ *  Generated: 2012-07-28 20:36:23.213113
  *  ----------------------------------------------------------
  *  This file has been merged from multiple headers. Please don't edit it directly
  *  Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
@@ -196,10 +196,12 @@ namespace Catch {
     public:
         Ptr() : m_p( NULL ){}
         Ptr( T* p ) : m_p( p ){
-            m_p->addRef();
+            if( m_p )
+                m_p->addRef();
         }
         Ptr( const Ptr& other ) : m_p( other.m_p ){
-            m_p->addRef();
+            if( m_p )
+                m_p->addRef();
         }
         ~Ptr(){
             if( m_p )
@@ -239,6 +241,9 @@ namespace Catch {
         const T* operator->() const{
             return m_p;
         }
+        bool operator !() const {
+            return m_p == NULL;
+        }
 
     private:
         T* m_p;
@@ -4616,6 +4621,12 @@ namespace Catch {
 
         Ptr<IReporter> reporter = getCurrentContext().getReporterRegistry().create( reporterName, reporterConfig );
 
+        if( !reporter )
+        {
+            std::cerr << "No reporter registered with name: " << reporterName << "'" << std::endl;
+            return (std::numeric_limits<int>::max)();
+        }
+
         if( !config.data().stream.empty() ) {
             if( config.data().stream[0] == '%' )
                 config.useStream( config.data().stream.substr( 1 ) );