Skip to content

Commit 551946c

Browse files
committed
Split out INTERNAL_CATCH_UNIQUE_NAME into its own header
Also small cleanup of includes of related headers.
1 parent 653764d commit 551946c

13 files changed

+33
-13
lines changed

src/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ set(INTERNAL_HEADERS
6565
${SOURCES_DIR}/internal/catch_errno_guard.hpp
6666
${SOURCES_DIR}/internal/catch_exception_translator_registry.hpp
6767
${SOURCES_DIR}/internal/catch_fatal_condition_handler.hpp
68+
${SOURCES_DIR}/internal/catch_unique_name.hpp
6869
${SOURCES_DIR}/generators/catch_generator_exception.hpp
6970
${SOURCES_DIR}/generators/catch_generators.hpp
7071
${SOURCES_DIR}/generators/catch_generators_adapters.hpp

src/catch2/benchmark/catch_benchmark.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <catch2/interfaces/catch_interfaces_config.hpp>
1414
#include <catch2/internal/catch_context.hpp>
1515
#include <catch2/interfaces/catch_interfaces_reporter.hpp>
16+
#include <catch2/internal/catch_unique_name.hpp>
1617

1718
#include <catch2/benchmark/catch_chronometer.hpp>
1819
#include <catch2/benchmark/catch_clock.hpp>

src/catch2/catch_all.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
#include <catch2/internal/catch_textflow.hpp>
101101
#include <catch2/internal/catch_to_string.hpp>
102102
#include <catch2/internal/catch_uncaught_exceptions.hpp>
103+
#include <catch2/internal/catch_unique_name.hpp>
103104
#include <catch2/internal/catch_unique_ptr.hpp>
104105
#include <catch2/internal/catch_wildcard_pattern.hpp>
105106
#include <catch2/internal/catch_windows_h_proxy.hpp>

src/catch2/catch_tag_alias_autoregistrar.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#define CATCH_TAG_ALIAS_AUTOREGISTRAR_HPP_INCLUDED
1010

1111
#include <catch2/internal/catch_compiler_capabilities.hpp>
12+
#include <catch2/internal/catch_unique_name.hpp>
1213
#include <catch2/internal/catch_source_line_info.hpp>
1314

1415
namespace Catch {

src/catch2/catch_test_macros.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include <catch2/internal/catch_preprocessor.hpp>
1414
#include <catch2/internal/catch_section.hpp>
1515
#include <catch2/internal/catch_test_registry.hpp>
16+
#include <catch2/internal/catch_unique_name.hpp>
17+
1618

1719
// All of our user-facing macros support configuration toggle, that
1820
// forces them to be defined prefixed with CATCH_. We also like to

src/catch2/catch_translate_exception.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#define CATCH_TRANSLATE_EXCEPTION_HPP_INCLUDED
1010

1111
#include <catch2/interfaces/catch_interfaces_exception.hpp>
12+
#include <catch2/internal/catch_compiler_capabilities.hpp>
13+
#include <catch2/internal/catch_unique_name.hpp>
1214

1315
#include <exception>
1416

src/catch2/interfaces/catch_interfaces_exception.hpp

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#define CATCH_INTERFACES_EXCEPTION_HPP_INCLUDED
1010

1111
#include <catch2/interfaces/catch_interfaces_registry_hub.hpp>
12-
#include <catch2/internal/catch_compiler_capabilities.hpp>
1312
#include <catch2/internal/catch_unique_ptr.hpp>
1413

1514
#include <string>

src/catch2/internal/catch_section.hpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
#include <catch2/catch_section_info.hpp>
1414
#include <catch2/catch_timer.hpp>
1515
#include <catch2/catch_totals.hpp>
16-
17-
#include <string>
16+
#include <catch2/internal/catch_unique_name.hpp>
1817

1918
namespace Catch {
2019

src/catch2/internal/catch_source_line_info.hpp

-10
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,9 @@
88
#ifndef CATCH_SOURCE_LINE_INFO_HPP_INCLUDED
99
#define CATCH_SOURCE_LINE_INFO_HPP_INCLUDED
1010

11-
#include <catch2/internal/catch_config_counter.hpp>
12-
1311
#include <cstddef>
1412
#include <iosfwd>
1513

16-
#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line
17-
#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line )
18-
#ifdef CATCH_CONFIG_COUNTER
19-
# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __COUNTER__ )
20-
#else
21-
# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ )
22-
#endif
23-
2414
// We need a dummy global operator<< so we can bring it into Catch namespace later
2515
struct Catch_global_namespace_dummy {};
2616
std::ostream& operator<<(std::ostream&, Catch_global_namespace_dummy);

src/catch2/internal/catch_template_test_registry.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#include <catch2/internal/catch_compiler_capabilities.hpp>
1313
#include <catch2/internal/catch_preprocessor.hpp>
1414
#include <catch2/internal/catch_meta.hpp>
15+
#include <catch2/internal/catch_unique_name.hpp>
16+
1517

1618
// GCC 5 and older do not properly handle disabling unused-variable warning
1719
// with a _Pragma. This means that we have to leak the suppression to the

src/catch2/internal/catch_test_macro_impl.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <catch2/internal/catch_assertion_handler.hpp>
1212
#include <catch2/interfaces/catch_interfaces_capture.hpp>
1313
#include <catch2/internal/catch_stringref.hpp>
14+
#include <catch2/internal/catch_source_line_info.hpp>
1415

1516
// We need this suppression to leak, because it took until GCC 9
1617
// for the front end to handle local suppression via _Pragma properly

src/catch2/internal/catch_test_registry.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <catch2/interfaces/catch_interfaces_testcase.hpp>
1414
#include <catch2/internal/catch_stringref.hpp>
1515
#include <catch2/internal/catch_unique_ptr.hpp>
16+
#include <catch2/internal/catch_unique_name.hpp>
1617

1718
// GCC 5 and older do not properly handle disabling unused-variable warning
1819
// with a _Pragma. This means that we have to leak the suppression to the
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
// Copyright Catch2 Authors
3+
// Distributed under the Boost Software License, Version 1.0.
4+
// (See accompanying file LICENSE_1_0.txt or copy at
5+
// https://www.boost.org/LICENSE_1_0.txt)
6+
7+
// SPDX-License-Identifier: BSL-1.0
8+
#ifndef CATCH_UNIQUE_NAME_HPP_INCLUDED
9+
#define CATCH_UNIQUE_NAME_HPP_INCLUDED
10+
11+
#include <catch2/internal/catch_config_counter.hpp>
12+
#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line
13+
#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line )
14+
#ifdef CATCH_CONFIG_COUNTER
15+
# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __COUNTER__ )
16+
#else
17+
# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ )
18+
#endif
19+
20+
#endif // CATCH_UNIQUE_NAME_HPP_INCLUDED

0 commit comments

Comments
 (0)