diff --git a/CMakeLists.txt b/CMakeLists.txt
index c577231c..9d765212 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -35,7 +35,7 @@ if (CMAKE_BINARY_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
endif()
project(Catch2
- VERSION 3.7.1 # CML version placeholder, don't delete
+ VERSION 3.8.0 # CML version placeholder, don't delete
LANGUAGES CXX
HOMEPAGE_URL "https://github.com/catchorg/Catch2"
DESCRIPTION "A modern, C++-native, unit test framework."
diff --git a/docs/release-notes.md b/docs/release-notes.md
index 5f2d92ae..4fe2789b 100644
--- a/docs/release-notes.md
+++ b/docs/release-notes.md
@@ -2,6 +2,7 @@
# Release notes
**Contents**
+[3.8.0](#380)
[3.7.1](#371)
[3.7.0](#370)
[3.6.0](#360)
@@ -65,6 +66,31 @@
[Even Older versions](#even-older-versions)
+## 3.8.0
+
+### Improvements
+* Added `std::initializer_list` overloads for `(Unordered)RangeEquals` matcher (#2915, #2919)
+* Added explicit casts to silence GCC's `Wconversion` (#2875)
+* Made the use of `builtin_constant_p` tricks in assertion macros configurable (#2925)
+ * It is used to prod GCC-like compilers into providing warnings for the asserted expressions, but the compilers miscompile it annoyingly often.
+* Cleaned out Clang-Tidy's `performance-enum-size` warnings
+* Added support for using `from_range` generator with iterators with `value_type = const T` (#2926)
+ * This is not correct `value_type` typedef, but it is used in the wild and the change does not make the code meaningfully worse.
+
+### Fixes
+* Fixed crash when stringifying pre-1970 (epoch) dates on Windows (#2944)
+
+### Miscellaneous
+* Fixes and improvements for `catch_discover_tests` CMake helper
+ * Removed redundant `CTEST_FILE` param when creating the indirection file for `PRE_TEST` discovery mode (#2936)
+ * Rewrote the test discovery logic to use output from the JSON reporter
+ * This means that `catch_discover_tests` now requires CMake 3.19 or newer
+ * Added `ADD_TAGS_AS_LABELS` option. If specified, each CTest test will be labeled with corrensponding Catch2's test tag
+* Bumped up the minimum required CMake version to build Catch2 to 3.16
+* Meson build now provides option to avoid installing Catch2
+* Bazel build is moved to Bzlmod.
+
+
## 3.7.1
### Improvements
diff --git a/extras/catch_amalgamated.cpp b/extras/catch_amalgamated.cpp
index f45c18a0..5b9d7384 100644
--- a/extras/catch_amalgamated.cpp
+++ b/extras/catch_amalgamated.cpp
@@ -6,8 +6,8 @@
// SPDX-License-Identifier: BSL-1.0
-// Catch v3.7.1
-// Generated: 2024-09-17 10:36:45.608896
+// Catch v3.8.0
+// Generated: 2025-01-06 00:39:54.679994
// ----------------------------------------------------------
// This file is an amalgamation of multiple different files.
// You probably shouldn't edit it directly.
@@ -332,7 +332,7 @@ namespace Catch {
double diff = b - m;
return a + diff * diff;
} ) /
- ( last - first );
+ static_cast( last - first );
return std::sqrt( variance );
}
@@ -367,7 +367,7 @@ namespace Catch {
double* first,
double* last ) {
auto count = last - first;
- double idx = (count - 1) * k / static_cast(q);
+ double idx = static_cast((count - 1) * k) / static_cast(q);
int j = static_cast(idx);
double g = idx - j;
std::nth_element(first, first + j, last);
@@ -470,10 +470,10 @@ namespace Catch {
double accel = sum_cubes / ( 6 * std::pow( sum_squares, 1.5 ) );
long n = static_cast( resample.size() );
- double prob_n =
+ double prob_n = static_cast(
std::count_if( resample.begin(),
resample.end(),
- [point]( double x ) { return x < point; } ) /
+ [point]( double x ) { return x < point; } )) /
static_cast( n );
// degenerate case with uniform samples
if ( Catch::Detail::directCompare( prob_n, 0. ) ) {
@@ -1926,7 +1926,7 @@ namespace Catch {
return static_cast(getElapsedMicroseconds()/1000);
}
auto Timer::getElapsedSeconds() const -> double {
- return getElapsedMicroseconds()/1000000.0;
+ return static_cast(getElapsedMicroseconds())/1000000.0;
}
@@ -1946,7 +1946,10 @@ namespace Detail {
const int hexThreshold = 255;
struct Endianness {
- enum Arch { Big, Little };
+ enum Arch : uint8_t {
+ Big,
+ Little
+ };
static Arch which() {
int one = 1;
@@ -2280,7 +2283,7 @@ namespace Catch {
}
Version const& libraryVersion() {
- static Version version( 3, 7, 1, "", 0 );
+ static Version version( 3, 8, 0, "", 0 );
return version;
}
@@ -3516,7 +3519,7 @@ namespace {
#endif // Windows/ ANSI/ None
-#if defined( CATCH_PLATFORM_LINUX ) || defined( CATCH_PLATFORM_MAC )
+#if defined( CATCH_PLATFORM_LINUX ) || defined( CATCH_PLATFORM_MAC ) || defined( __GLIBC__ )
# define CATCH_INTERNAL_HAS_ISATTY
# include
#endif
@@ -5258,7 +5261,7 @@ namespace {
SimplePcg32::result_type SimplePcg32::operator()() {
// prepare the output value
const uint32_t xorshifted = static_cast(((m_state >> 18u) ^ m_state) >> 27u);
- const auto output = rotate_right(xorshifted, m_state >> 59u);
+ const auto output = rotate_right(xorshifted, static_cast(m_state >> 59u));
// advance state
m_state = m_state * 6364136223846793005ULL + s_inc;
@@ -9108,7 +9111,7 @@ struct RowBreak {};
struct OutputFlush {};
class Duration {
- enum class Unit {
+ enum class Unit : uint8_t {
Auto,
Nanoseconds,
Microseconds,
@@ -9180,7 +9183,10 @@ public:
};
} // end anon namespace
-enum class Justification { Left, Right };
+enum class Justification : uint8_t {
+ Left,
+ Right
+};
struct ColumnInfo {
std::string name;
diff --git a/extras/catch_amalgamated.hpp b/extras/catch_amalgamated.hpp
index b7c768b8..b77bbb61 100644
--- a/extras/catch_amalgamated.hpp
+++ b/extras/catch_amalgamated.hpp
@@ -6,8 +6,8 @@
// SPDX-License-Identifier: BSL-1.0
-// Catch v3.7.1
-// Generated: 2024-09-17 10:36:40.974985
+// Catch v3.8.0
+// Generated: 2025-01-06 00:39:54.340018
// ----------------------------------------------------------
// This file is an amalgamation of multiple different files.
// You probably shouldn't edit it directly.
@@ -150,7 +150,7 @@
# define CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS \
_Pragma( "GCC diagnostic ignored \"-Wshadow\"" )
-# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)__builtin_constant_p(__VA_ARGS__)
+# define CATCH_INTERNAL_CONFIG_USE_BUILTIN_CONSTANT_P
#endif
@@ -174,35 +174,13 @@
// clang-cl defines _MSC_VER as well as __clang__, which could cause the
// start/stop internal suppression macros to be double defined.
#if defined(__clang__) && !defined(_MSC_VER)
-
+# define CATCH_INTERNAL_CONFIG_USE_BUILTIN_CONSTANT_P
# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma( "clang diagnostic push" )
# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma( "clang diagnostic pop" )
-
#endif // __clang__ && !_MSC_VER
#if defined(__clang__)
-// As of this writing, IBM XL's implementation of __builtin_constant_p has a bug
-// which results in calls to destructors being emitted for each temporary,
-// without a matching initialization. In practice, this can result in something
-// like `std::string::~string` being called on an uninitialized value.
-//
-// For example, this code will likely segfault under IBM XL:
-// ```
-// REQUIRE(std::string("12") + "34" == "1234")
-// ```
-//
-// Similarly, NVHPC's implementation of `__builtin_constant_p` has a bug which
-// results in calls to the immediately evaluated lambda expressions to be
-// reported as unevaluated lambdas.
-// https://developer.nvidia.com/nvidia_bug/3321845.
-//
-// Therefore, `CATCH_INTERNAL_IGNORE_BUT_WARN` is not implemented.
-# if !defined(__ibmxl__) && !defined(__CUDACC__) && !defined( __NVCOMPILER )
-# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)__builtin_constant_p(__VA_ARGS__) /* NOLINT(cppcoreguidelines-pro-type-vararg, hicpp-vararg) */
-# endif
-
-
# define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
_Pragma( "clang diagnostic ignored \"-Wexit-time-destructors\"" ) \
_Pragma( "clang diagnostic ignored \"-Wglobal-constructors\"")
@@ -227,6 +205,27 @@
#endif // __clang__
+// As of this writing, IBM XL's implementation of __builtin_constant_p has a bug
+// which results in calls to destructors being emitted for each temporary,
+// without a matching initialization. In practice, this can result in something
+// like `std::string::~string` being called on an uninitialized value.
+//
+// For example, this code will likely segfault under IBM XL:
+// ```
+// REQUIRE(std::string("12") + "34" == "1234")
+// ```
+//
+// Similarly, NVHPC's implementation of `__builtin_constant_p` has a bug which
+// results in calls to the immediately evaluated lambda expressions to be
+// reported as unevaluated lambdas.
+// https://developer.nvidia.com/nvidia_bug/3321845.
+//
+// Therefore, `CATCH_INTERNAL_IGNORE_BUT_WARN` is not implemented.
+#if defined( __ibmxl__ ) || defined( __CUDACC__ ) || defined( __NVCOMPILER )
+# define CATCH_INTERNAL_CONFIG_NO_USE_BUILTIN_CONSTANT_P
+#endif
+
+
////////////////////////////////////////////////////////////////////////////////
// We know some environments not to support full POSIX signals
@@ -450,6 +449,22 @@
#endif
+// The goal of this macro is to avoid evaluation of the arguments, but
+// still have the compiler warn on problems inside...
+#if defined( CATCH_INTERNAL_CONFIG_USE_BUILTIN_CONSTANT_P ) && \
+ !defined( CATCH_INTERNAL_CONFIG_NO_USE_BUILTIN_CONSTANT_P ) && !defined(CATCH_CONFIG_USE_BUILTIN_CONSTANT_P)
+#define CATCH_CONFIG_USE_BUILTIN_CONSTANT_P
+#endif
+
+#if defined( CATCH_CONFIG_USE_BUILTIN_CONSTANT_P ) && \
+ !defined( CATCH_CONFIG_NO_USE_BUILTIN_CONSTANT_P )
+# define CATCH_INTERNAL_IGNORE_BUT_WARN( ... ) \
+ (void)__builtin_constant_p( __VA_ARGS__ ) /* NOLINT(cppcoreguidelines-pro-type-vararg, \
+ hicpp-vararg) */
+#else
+# define CATCH_INTERNAL_IGNORE_BUT_WARN( ... )
+#endif
+
// Even if we do not think the compiler has that warning, we still have
// to provide a macro that can be used by the code.
#if !defined(CATCH_INTERNAL_START_WARNINGS_SUPPRESSION)
@@ -486,13 +501,6 @@
# define CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS
#endif
-
-// The goal of this macro is to avoid evaluation of the arguments, but
-// still have the compiler warn on problems inside...
-#if !defined(CATCH_INTERNAL_IGNORE_BUT_WARN)
-# define CATCH_INTERNAL_IGNORE_BUT_WARN(...)
-#endif
-
#if defined(__APPLE__) && defined(__apple_build_version__) && (__clang_major__ < 10)
# undef CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS
#elif defined(__clang__) && (__clang_major__ < 5)
@@ -3050,7 +3058,11 @@ struct ratio_string {
#ifdef _MSC_VER
std::tm timeInfo = {};
- gmtime_s(&timeInfo, &converted);
+ const auto err = gmtime_s(&timeInfo, &converted);
+ if ( err ) {
+ return "gmtime from provided timepoint has failed. This "
+ "happens e.g. with pre-1970 dates using Microsoft libc";
+ }
#else
std::tm* timeInfo = std::gmtime(&converted);
#endif
@@ -7329,8 +7341,8 @@ namespace Catch {
#define CATCH_VERSION_MACROS_HPP_INCLUDED
#define CATCH_VERSION_MAJOR 3
-#define CATCH_VERSION_MINOR 7
-#define CATCH_VERSION_PATCH 1
+#define CATCH_VERSION_MINOR 8
+#define CATCH_VERSION_PATCH 0
#endif // CATCH_VERSION_MACROS_HPP_INCLUDED
@@ -8713,7 +8725,7 @@ public:
template ::value_type>
+ typename ResultType = std::remove_const_t::value_type>>
GeneratorWrapper from_range(InputIterator from, InputSentinel to) {
return GeneratorWrapper(Catch::Detail::make_unique>(from, to));
}
@@ -12691,56 +12703,65 @@ namespace Catch {
* Creates a matcher that checks if all elements in a range are equal
* to all elements in another range.
*
- * Uses `std::equal_to` to do the comparison
+ * Uses the provided predicate `predicate` to do the comparisons
+ * (defaulting to `std::equal_to`)
*/
- template
- constexpr
- std::enable_if_t::value,
- RangeEqualsMatcher>>
- RangeEquals( RangeLike&& range ) {
- return { CATCH_FORWARD( range ), std::equal_to<>{} };
- }
-
- /**
- * Creates a matcher that checks if all elements in a range are equal
- * to all elements in another range.
- *
- * Uses to provided predicate `predicate` to do the comparisons
- */
- template
+ template {} )>
constexpr
RangeEqualsMatcher
- RangeEquals( RangeLike&& range, Equality&& predicate ) {
+ RangeEquals( RangeLike&& range,
+ Equality&& predicate = std::equal_to<>{} ) {
return { CATCH_FORWARD( range ), CATCH_FORWARD( predicate ) };
}
/**
* Creates a matcher that checks if all elements in a range are equal
- * to all elements in another range, in some permutation
+ * to all elements in an initializer list.
*
- * Uses `std::equal_to` to do the comparison
+ * Uses the provided predicate `predicate` to do the comparisons
+ * (defaulting to `std::equal_to`)
*/
- template
+ template {} )>
constexpr
- std::enable_if_t<
- !Detail::is_matcher::value,
- UnorderedRangeEqualsMatcher>>
- UnorderedRangeEquals( RangeLike&& range ) {
- return { CATCH_FORWARD( range ), std::equal_to<>{} };
+ RangeEqualsMatcher, Equality>
+ RangeEquals( std::initializer_list range,
+ Equality&& predicate = std::equal_to<>{} ) {
+ return { range, CATCH_FORWARD( predicate ) };
}
/**
* Creates a matcher that checks if all elements in a range are equal
* to all elements in another range, in some permutation.
*
- * Uses to provided predicate `predicate` to do the comparisons
+ * Uses the provided predicate `predicate` to do the comparisons
+ * (defaulting to `std::equal_to`)
*/
- template
+ template {} )>
constexpr
UnorderedRangeEqualsMatcher
- UnorderedRangeEquals( RangeLike&& range, Equality&& predicate ) {
+ UnorderedRangeEquals( RangeLike&& range,
+ Equality&& predicate = std::equal_to<>{} ) {
return { CATCH_FORWARD( range ), CATCH_FORWARD( predicate ) };
}
+
+ /**
+ * Creates a matcher that checks if all elements in a range are equal
+ * to all elements in an initializer list, in some permutation.
+ *
+ * Uses the provided predicate `predicate` to do the comparisons
+ * (defaulting to `std::equal_to`)
+ */
+ template {} )>
+ constexpr
+ UnorderedRangeEqualsMatcher, Equality>
+ UnorderedRangeEquals( std::initializer_list range,
+ Equality&& predicate = std::equal_to<>{} ) {
+ return { range, CATCH_FORWARD( predicate ) };
+ }
} // namespace Matchers
} // namespace Catch
diff --git a/meson.build b/meson.build
index 99bf3aff..e8e681c4 100644
--- a/meson.build
+++ b/meson.build
@@ -8,7 +8,7 @@
project(
'catch2',
'cpp',
- version: '3.7.1', # CML version placeholder, don't delete
+ version: '3.8.0', # CML version placeholder, don't delete
license: 'BSL-1.0',
meson_version: '>=0.54.1',
)
diff --git a/src/catch2/catch_version.cpp b/src/catch2/catch_version.cpp
index 1701f3ad..9b34969e 100644
--- a/src/catch2/catch_version.cpp
+++ b/src/catch2/catch_version.cpp
@@ -36,7 +36,7 @@ namespace Catch {
}
Version const& libraryVersion() {
- static Version version( 3, 7, 1, "", 0 );
+ static Version version( 3, 8, 0, "", 0 );
return version;
}
diff --git a/src/catch2/catch_version_macros.hpp b/src/catch2/catch_version_macros.hpp
index 88b5d0d0..b77a455a 100644
--- a/src/catch2/catch_version_macros.hpp
+++ b/src/catch2/catch_version_macros.hpp
@@ -9,7 +9,7 @@
#define CATCH_VERSION_MACROS_HPP_INCLUDED
#define CATCH_VERSION_MAJOR 3
-#define CATCH_VERSION_MINOR 7
-#define CATCH_VERSION_PATCH 1
+#define CATCH_VERSION_MINOR 8
+#define CATCH_VERSION_PATCH 0
#endif // CATCH_VERSION_MACROS_HPP_INCLUDED