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

Reduce misc includes all around

Commit
c487b27d9d98e69358f3eee7b02c7d2ad0889139
Author
Martin Hořeňovský ·
Parents
3230760db209

Files · Download .tar.gz

Changes

 src/CMakeLists.txt                                   |  1 +
 src/catch2/catch_tostring.hpp                        |  1 -
 src/catch2/catch_translate_exception.cpp             | 20 ++++++++++++++++++++
 src/catch2/catch_translate_exception.hpp             | 10 +++++++---
 src/catch2/interfaces/catch_interfaces_exception.hpp |  1 -
 src/catch2/internal/catch_assertion_handler.cpp      |  1 -
 src/catch2/internal/catch_assertion_handler.hpp      |  3 ---
 src/catch2/meson.build                               |  1 +
 src/catch2/reporters/catch_reporter_registrars.cpp   |  1 +
 src/catch2/reporters/catch_reporter_registrars.hpp   |  2 --
 10 files changed, 30 insertions(+), 11 deletions(-)

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 719413d2..47b7dfe5 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -153,6 +153,7 @@ set(IMPL_SOURCES
   ${SOURCES_DIR}/catch_timer.cpp
   ${SOURCES_DIR}/catch_tostring.cpp
   ${SOURCES_DIR}/catch_totals.cpp
+  ${SOURCES_DIR}/catch_translate_exception.cpp
   ${SOURCES_DIR}/catch_version.cpp
   ${SOURCES_DIR}/internal/catch_assertion_handler.cpp
   ${SOURCES_DIR}/internal/catch_case_insensitive_comparisons.cpp
diff --git a/src/catch2/catch_tostring.hpp b/src/catch2/catch_tostring.hpp
index 904caa7e..788d824c 100644
--- a/src/catch2/catch_tostring.hpp
+++ b/src/catch2/catch_tostring.hpp
@@ -116,7 +116,6 @@ namespace Catch {
     } // namespace Detail
 
 
-    // If we decide for C++14, change these to enable_if_ts
     template <typename T, typename = void>
     struct StringMaker {
         template <typename Fake = T>
diff --git a/src/catch2/catch_translate_exception.cpp b/src/catch2/catch_translate_exception.cpp
new file mode 100644
index 00000000..c4b28944
--- /dev/null
+++ b/src/catch2/catch_translate_exception.cpp
@@ -0,0 +1,20 @@
+
+//              Copyright Catch2 Authors
+// Distributed under the Boost Software License, Version 1.0.
+//   (See accompanying file LICENSE.txt or copy at
+//        https://www.boost.org/LICENSE_1_0.txt)
+
+// SPDX-License-Identifier: BSL-1.0
+
+#include <catch2/catch_translate_exception.hpp>
+#include <catch2/interfaces/catch_interfaces_registry_hub.hpp>
+
+namespace Catch {
+    namespace Detail {
+        void registerTranslatorImpl(
+            Detail::unique_ptr<IExceptionTranslator>&& translator ) {
+            getMutableRegistryHub().registerTranslator(
+                CATCH_MOVE( translator ) );
+        }
+    } // namespace Detail
+} // namespace Catch
diff --git a/src/catch2/catch_translate_exception.hpp b/src/catch2/catch_translate_exception.hpp
index 2dbeb17e..5a4dc5e3 100644
--- a/src/catch2/catch_translate_exception.hpp
+++ b/src/catch2/catch_translate_exception.hpp
@@ -15,6 +15,10 @@
 #include <exception>
 
 namespace Catch {
+    namespace Detail {
+        void registerTranslatorImpl(
+            Detail::unique_ptr<IExceptionTranslator>&& translator );
+    }
 
     class ExceptionTranslatorRegistrar {
         template<typename T>
@@ -48,9 +52,9 @@ namespace Catch {
     public:
         template<typename T>
         ExceptionTranslatorRegistrar( std::string(*translateFunction)( T const& ) ) {
-            getMutableRegistryHub().registerTranslator(
-                Detail::make_unique<ExceptionTranslator<T>>(translateFunction)
-            );
+            Detail::registerTranslatorImpl(
+                Detail::make_unique<ExceptionTranslator<T>>(
+                    translateFunction ) );
         }
     };
 
diff --git a/src/catch2/interfaces/catch_interfaces_exception.hpp b/src/catch2/interfaces/catch_interfaces_exception.hpp
index 9177666a..fcc2a8f9 100644
--- a/src/catch2/interfaces/catch_interfaces_exception.hpp
+++ b/src/catch2/interfaces/catch_interfaces_exception.hpp
@@ -8,7 +8,6 @@
 #ifndef CATCH_INTERFACES_EXCEPTION_HPP_INCLUDED
 #define CATCH_INTERFACES_EXCEPTION_HPP_INCLUDED
 
-#include <catch2/interfaces/catch_interfaces_registry_hub.hpp>
 #include <catch2/internal/catch_unique_ptr.hpp>
 
 #include <string>
diff --git a/src/catch2/internal/catch_assertion_handler.cpp b/src/catch2/internal/catch_assertion_handler.cpp
index c28b6190..b66a1456 100644
--- a/src/catch2/internal/catch_assertion_handler.cpp
+++ b/src/catch2/internal/catch_assertion_handler.cpp
@@ -12,7 +12,6 @@
 #include <catch2/internal/catch_debugger.hpp>
 #include <catch2/internal/catch_test_failure_exception.hpp>
 #include <catch2/interfaces/catch_interfaces_registry_hub.hpp>
-#include <catch2/internal/catch_run_context.hpp>
 #include <catch2/matchers/catch_matchers_string.hpp>
 
 namespace Catch {
diff --git a/src/catch2/internal/catch_assertion_handler.hpp b/src/catch2/internal/catch_assertion_handler.hpp
index ee7188ba..01dd7801 100644
--- a/src/catch2/internal/catch_assertion_handler.hpp
+++ b/src/catch2/internal/catch_assertion_handler.hpp
@@ -11,14 +11,11 @@
 #include <catch2/catch_assertion_info.hpp>
 #include <catch2/internal/catch_decomposer.hpp>
 #include <catch2/interfaces/catch_interfaces_capture.hpp>
-#include <catch2/internal/catch_lazy_expr.hpp>
 
 #include <string>
 
 namespace Catch {
 
-    class IResultCapture;
-
     struct AssertionReaction {
         bool shouldDebugBreak = false;
         bool shouldThrow = false;
diff --git a/src/catch2/meson.build b/src/catch2/meson.build
index fee3b4ed..b5ffc224 100644
--- a/src/catch2/meson.build
+++ b/src/catch2/meson.build
@@ -260,6 +260,7 @@ internal_sources = files(
   'catch_timer.cpp',
   'catch_tostring.cpp',
   'catch_totals.cpp',
+  'catch_translate_exception.cpp',
   'catch_version.cpp',
 )
 
diff --git a/src/catch2/reporters/catch_reporter_registrars.cpp b/src/catch2/reporters/catch_reporter_registrars.cpp
index 17f59517..2a3ac957 100644
--- a/src/catch2/reporters/catch_reporter_registrars.cpp
+++ b/src/catch2/reporters/catch_reporter_registrars.cpp
@@ -8,6 +8,7 @@
 
 #include <catch2/reporters/catch_reporter_registrars.hpp>
 
+#include <catch2/interfaces/catch_interfaces_registry_hub.hpp>
 #include <catch2/internal/catch_compiler_capabilities.hpp>
 
 namespace Catch {
diff --git a/src/catch2/reporters/catch_reporter_registrars.hpp b/src/catch2/reporters/catch_reporter_registrars.hpp
index cab395f4..a93963f0 100644
--- a/src/catch2/reporters/catch_reporter_registrars.hpp
+++ b/src/catch2/reporters/catch_reporter_registrars.hpp
@@ -8,8 +8,6 @@
 #ifndef CATCH_REPORTER_REGISTRARS_HPP_INCLUDED
 #define CATCH_REPORTER_REGISTRARS_HPP_INCLUDED
 
-#include <catch2/interfaces/catch_interfaces_registry_hub.hpp>
-#include <catch2/interfaces/catch_interfaces_reporter.hpp>
 #include <catch2/interfaces/catch_interfaces_reporter_factory.hpp>
 #include <catch2/internal/catch_compiler_capabilities.hpp>
 #include <catch2/internal/catch_unique_name.hpp>