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

Split out INTERNAL_CATCH_UNIQUE_NAME into its own header

Also small cleanup of includes of related headers.
Commit
551946c45bb27b78c85971d32e2a8bccbfa0d3f8
Author
Martin Hořeňovský ·
Parents
653764d53bbc

Files · Download .tar.gz

Changes

 src/CMakeLists.txt                                   |  1 +
 src/catch2/benchmark/catch_benchmark.hpp             |  1 +
 src/catch2/catch_all.hpp                             |  1 +
 src/catch2/catch_tag_alias_autoregistrar.hpp         |  1 +
 src/catch2/catch_test_macros.hpp                     |  2 ++
 src/catch2/catch_translate_exception.hpp             |  2 ++
 src/catch2/interfaces/catch_interfaces_exception.hpp |  1 -
 src/catch2/internal/catch_section.hpp                |  3 +--
 src/catch2/internal/catch_source_line_info.hpp       | 10 ----------
 src/catch2/internal/catch_template_test_registry.hpp |  2 ++
 src/catch2/internal/catch_test_macro_impl.hpp        |  1 +
 src/catch2/internal/catch_test_registry.hpp          |  1 +
 src/catch2/internal/catch_unique_name.hpp            | 20 ++++++++++++++++++++
 13 files changed, 33 insertions(+), 13 deletions(-)

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index f2223639..2f3dd4ab 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -65,6 +65,7 @@ set(INTERNAL_HEADERS
     ${SOURCES_DIR}/internal/catch_errno_guard.hpp
     ${SOURCES_DIR}/internal/catch_exception_translator_registry.hpp
     ${SOURCES_DIR}/internal/catch_fatal_condition_handler.hpp
+    ${SOURCES_DIR}/internal/catch_unique_name.hpp
     ${SOURCES_DIR}/generators/catch_generator_exception.hpp
     ${SOURCES_DIR}/generators/catch_generators.hpp
     ${SOURCES_DIR}/generators/catch_generators_adapters.hpp
diff --git a/src/catch2/benchmark/catch_benchmark.hpp b/src/catch2/benchmark/catch_benchmark.hpp
index 8ff69b4a..c99160fb 100644
--- a/src/catch2/benchmark/catch_benchmark.hpp
+++ b/src/catch2/benchmark/catch_benchmark.hpp
@@ -13,6 +13,7 @@
 #include <catch2/interfaces/catch_interfaces_config.hpp>
 #include <catch2/internal/catch_context.hpp>
 #include <catch2/interfaces/catch_interfaces_reporter.hpp>
+#include <catch2/internal/catch_unique_name.hpp>
 
 #include <catch2/benchmark/catch_chronometer.hpp>
 #include <catch2/benchmark/catch_clock.hpp>
diff --git a/src/catch2/catch_all.hpp b/src/catch2/catch_all.hpp
index 3bd6d9c8..c6ab59ec 100644
--- a/src/catch2/catch_all.hpp
+++ b/src/catch2/catch_all.hpp
@@ -100,6 +100,7 @@
 #include <catch2/internal/catch_textflow.hpp>
 #include <catch2/internal/catch_to_string.hpp>
 #include <catch2/internal/catch_uncaught_exceptions.hpp>
+#include <catch2/internal/catch_unique_name.hpp>
 #include <catch2/internal/catch_unique_ptr.hpp>
 #include <catch2/internal/catch_wildcard_pattern.hpp>
 #include <catch2/internal/catch_windows_h_proxy.hpp>
diff --git a/src/catch2/catch_tag_alias_autoregistrar.hpp b/src/catch2/catch_tag_alias_autoregistrar.hpp
index 6b5c2f1c..c742bcd3 100644
--- a/src/catch2/catch_tag_alias_autoregistrar.hpp
+++ b/src/catch2/catch_tag_alias_autoregistrar.hpp
@@ -9,6 +9,7 @@
 #define CATCH_TAG_ALIAS_AUTOREGISTRAR_HPP_INCLUDED
 
 #include <catch2/internal/catch_compiler_capabilities.hpp>
+#include <catch2/internal/catch_unique_name.hpp>
 #include <catch2/internal/catch_source_line_info.hpp>
 
 namespace Catch {
diff --git a/src/catch2/catch_test_macros.hpp b/src/catch2/catch_test_macros.hpp
index dcbe53db..ae509150 100644
--- a/src/catch2/catch_test_macros.hpp
+++ b/src/catch2/catch_test_macros.hpp
@@ -13,6 +13,8 @@
 #include <catch2/internal/catch_preprocessor.hpp>
 #include <catch2/internal/catch_section.hpp>
 #include <catch2/internal/catch_test_registry.hpp>
+#include <catch2/internal/catch_unique_name.hpp>
+
 
 // All of our user-facing macros support configuration toggle, that
 // forces them to be defined prefixed with CATCH_. We also like to
diff --git a/src/catch2/catch_translate_exception.hpp b/src/catch2/catch_translate_exception.hpp
index 412a1062..1bb8bb92 100644
--- a/src/catch2/catch_translate_exception.hpp
+++ b/src/catch2/catch_translate_exception.hpp
@@ -9,6 +9,8 @@
 #define CATCH_TRANSLATE_EXCEPTION_HPP_INCLUDED
 
 #include <catch2/interfaces/catch_interfaces_exception.hpp>
+#include <catch2/internal/catch_compiler_capabilities.hpp>
+#include <catch2/internal/catch_unique_name.hpp>
 
 #include <exception>
 
diff --git a/src/catch2/interfaces/catch_interfaces_exception.hpp b/src/catch2/interfaces/catch_interfaces_exception.hpp
index 84bb4974..5d660873 100644
--- a/src/catch2/interfaces/catch_interfaces_exception.hpp
+++ b/src/catch2/interfaces/catch_interfaces_exception.hpp
@@ -9,7 +9,6 @@
 #define CATCH_INTERFACES_EXCEPTION_HPP_INCLUDED
 
 #include <catch2/interfaces/catch_interfaces_registry_hub.hpp>
-#include <catch2/internal/catch_compiler_capabilities.hpp>
 #include <catch2/internal/catch_unique_ptr.hpp>
 
 #include <string>
diff --git a/src/catch2/internal/catch_section.hpp b/src/catch2/internal/catch_section.hpp
index 36d900bb..2e72923c 100644
--- a/src/catch2/internal/catch_section.hpp
+++ b/src/catch2/internal/catch_section.hpp
@@ -13,8 +13,7 @@
 #include <catch2/catch_section_info.hpp>
 #include <catch2/catch_timer.hpp>
 #include <catch2/catch_totals.hpp>
-
-#include <string>
+#include <catch2/internal/catch_unique_name.hpp>
 
 namespace Catch {
 
diff --git a/src/catch2/internal/catch_source_line_info.hpp b/src/catch2/internal/catch_source_line_info.hpp
index 8aca4867..bd828fad 100644
--- a/src/catch2/internal/catch_source_line_info.hpp
+++ b/src/catch2/internal/catch_source_line_info.hpp
@@ -8,19 +8,9 @@
 #ifndef CATCH_SOURCE_LINE_INFO_HPP_INCLUDED
 #define CATCH_SOURCE_LINE_INFO_HPP_INCLUDED
 
-#include <catch2/internal/catch_config_counter.hpp>
-
 #include <cstddef>
 #include <iosfwd>
 
-#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line
-#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line )
-#ifdef CATCH_CONFIG_COUNTER
-#  define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __COUNTER__ )
-#else
-#  define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ )
-#endif
-
 // We need a dummy global operator<< so we can bring it into Catch namespace later
 struct Catch_global_namespace_dummy {};
 std::ostream& operator<<(std::ostream&, Catch_global_namespace_dummy);
diff --git a/src/catch2/internal/catch_template_test_registry.hpp b/src/catch2/internal/catch_template_test_registry.hpp
index 3617109b..83c47d7d 100644
--- a/src/catch2/internal/catch_template_test_registry.hpp
+++ b/src/catch2/internal/catch_template_test_registry.hpp
@@ -12,6 +12,8 @@
 #include <catch2/internal/catch_compiler_capabilities.hpp>
 #include <catch2/internal/catch_preprocessor.hpp>
 #include <catch2/internal/catch_meta.hpp>
+#include <catch2/internal/catch_unique_name.hpp>
+
 
 // GCC 5 and older do not properly handle disabling unused-variable warning
 // with a _Pragma. This means that we have to leak the suppression to the
diff --git a/src/catch2/internal/catch_test_macro_impl.hpp b/src/catch2/internal/catch_test_macro_impl.hpp
index 9ceb03ab..357e114d 100644
--- a/src/catch2/internal/catch_test_macro_impl.hpp
+++ b/src/catch2/internal/catch_test_macro_impl.hpp
@@ -11,6 +11,7 @@
 #include <catch2/internal/catch_assertion_handler.hpp>
 #include <catch2/interfaces/catch_interfaces_capture.hpp>
 #include <catch2/internal/catch_stringref.hpp>
+#include <catch2/internal/catch_source_line_info.hpp>
 
 // We need this suppression to leak, because it took until GCC 9
 // for the front end to handle local suppression via _Pragma properly
diff --git a/src/catch2/internal/catch_test_registry.hpp b/src/catch2/internal/catch_test_registry.hpp
index 0f5ec488..9e8b5b6e 100644
--- a/src/catch2/internal/catch_test_registry.hpp
+++ b/src/catch2/internal/catch_test_registry.hpp
@@ -13,6 +13,7 @@
 #include <catch2/interfaces/catch_interfaces_testcase.hpp>
 #include <catch2/internal/catch_stringref.hpp>
 #include <catch2/internal/catch_unique_ptr.hpp>
+#include <catch2/internal/catch_unique_name.hpp>
 
 // GCC 5 and older do not properly handle disabling unused-variable warning
 // with a _Pragma. This means that we have to leak the suppression to the
diff --git a/src/catch2/internal/catch_unique_name.hpp b/src/catch2/internal/catch_unique_name.hpp
new file mode 100644
index 00000000..31ab9126
--- /dev/null
+++ b/src/catch2/internal/catch_unique_name.hpp
@@ -0,0 +1,20 @@
+
+//              Copyright Catch2 Authors
+// Distributed under the Boost Software License, Version 1.0.
+//   (See accompanying file LICENSE_1_0.txt or copy at
+//        https://www.boost.org/LICENSE_1_0.txt)
+
+// SPDX-License-Identifier: BSL-1.0
+#ifndef CATCH_UNIQUE_NAME_HPP_INCLUDED
+#define CATCH_UNIQUE_NAME_HPP_INCLUDED
+
+#include <catch2/internal/catch_config_counter.hpp>
+#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line
+#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line )
+#ifdef CATCH_CONFIG_COUNTER
+#  define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __COUNTER__ )
+#else
+#  define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ )
+#endif
+
+#endif // CATCH_UNIQUE_NAME_HPP_INCLUDED