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

Removed need for Error class to capture stream inserted strings into exceptions

Commit
8c757cc54253928f86c354f2936d8f7aef1d07fb
Author
Phil Nash ·
Parents
bada67bb72e1

Files · Download .tar.gz

Changes

 include/internal/catch_common.h | 29 ++++++++---------------------
 1 file changed, 8 insertions(+), 21 deletions(-)

diff --git a/include/internal/catch_common.h b/include/internal/catch_common.h
index c4ac2967..ad393c52 100644
--- a/include/internal/catch_common.h
+++ b/include/internal/catch_common.h
@@ -116,29 +116,16 @@ namespace Catch {
     T const& operator + ( T const& value, StreamEndStop ) {
         return value;
     }
-
-    template<typename ExceptionT = std::domain_error>
-    class Error {
-        std::ostringstream m_oss;
-
-    public:
-        template<typename T>
-        auto operator <<( T const& value ) -> Error& {
-            m_oss << value;
-            return *this;
-        }
-
-        [[noreturn]]
-        void raise() {
-            throw ExceptionT( m_oss.str() );
-        }
-    };
 }
 
-#define CATCH_INTERNAL_LINEINFO ::Catch::SourceLineInfo( __FILE__, static_cast<std::size_t>( __LINE__ ) )
-#define CATCH_INTERNAL_ERROR( msg ) do{ ( ::Catch::Error<std::logic_error>() << CATCH_INTERNAL_LINEINFO << ": Internal Catch error: " << msg ).raise(); } while(false)
-#define CATCH_ERROR( msg ) ( ::Catch::Error<>() << msg ).raise()
-#define CATCH_ENFORCE( condition, msg ) do{ if( !(condition) ) CATCH_ERROR( msg ); } while(false)
+#define CATCH_INTERNAL_LINEINFO \
+    ::Catch::SourceLineInfo( __FILE__, static_cast<std::size_t>( __LINE__ ) )
+#define CATCH_INTERNAL_ERROR( msg ) \
+    throw std::logic_error( ( std::ostringstream() << CATCH_INTERNAL_LINEINFO << ": Internal Catch error: " << msg ).str() )
+#define CATCH_ERROR( msg ) \
+    throw std::domain_error( ( std::ostringstream() << msg ).str() )
+#define CATCH_ENFORCE( condition, msg ) \
+    do{ if( !(condition) ) CATCH_ERROR( msg ); } while(false)
 
 #endif // TWOBLUECUBES_CATCH_COMMON_H_INCLUDED