Compare commits

..

2 Commits

Author SHA1 Message Date
Chris Thrasher
7ee2173aca Update CI image to macOS 14 2024-03-12 12:47:55 -06:00
Chris Thrasher
20d3f1939d Ignore C++98 related compiler warnings
Catch2 has long since required a standard newer than C++98 so we
can safely ignore any warnings related to such old standards.
2024-03-12 11:27:06 -06:00
36 changed files with 302 additions and 606 deletions

View File

@@ -5,4 +5,3 @@ find_package(Catch2 CONFIG REQUIRED)
add_executable(test_package test_package.cpp)
target_link_libraries(test_package Catch2::Catch2WithMain)
target_compile_features(test_package PRIVATE cxx_std_14)

View File

@@ -3,14 +3,12 @@
from conan import ConanFile
from conan.tools.cmake import CMake, cmake_layout
from conan.tools.build import can_run
from conan.tools.files import save, load
import os
class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv"
test_type = "explicit"
generators = "CMakeToolchain", "CMakeDeps"
def requirements(self):
self.requires(self.tested_reference_str)
@@ -18,12 +16,6 @@ class TestPackageConan(ConanFile):
def layout(self):
cmake_layout(self)
def generate(self):
save(self, os.path.join(self.build_folder, "package_folder"),
self.dependencies[self.tested_reference_str].package_folder)
save(self, os.path.join(self.build_folder, "license"),
self.dependencies[self.tested_reference_str].license)
def build(self):
cmake = CMake(self)
cmake.configure()
@@ -34,7 +26,8 @@ class TestPackageConan(ConanFile):
cmd = os.path.join(self.cpp.build.bindir, "test_package")
self.run(cmd, env="conanrun")
package_folder = load(self, os.path.join(self.build_folder, "package_folder"))
license = load(self, os.path.join(self.build_folder, "license"))
assert os.path.isfile(os.path.join(package_folder, "licenses", "LICENSE.txt"))
assert license == 'BSL-1.0'
# If we are on conan 2 we can check the license info is populated
if hasattr(self, 'dependencies'):
catch2 = self.dependencies["catch2"]
assert os.path.exists(f'{catch2.package_folder}/licenses/LICENSE.txt')
assert catch2.license == 'BSL-1.0'

View File

@@ -9,8 +9,6 @@ jobs:
strategy:
matrix:
cxx:
- g++-5
- g++-6
- g++-7
- g++-8
- g++-9
@@ -23,10 +21,6 @@ jobs:
build_type: [Debug, Release]
std: [14]
include:
- cxx: g++-5
other_pkgs: g++-5
- cxx: g++-6
other_pkgs: g++-6
- cxx: g++-7
other_pkgs: g++-7
- cxx: g++-8

View File

@@ -1,44 +0,0 @@
name: M1 Mac builds
on: [push, pull_request]
jobs:
build:
runs-on: macos-14
strategy:
matrix:
cxx:
- clang++
build_type: [Debug, Release]
std: [14, 17]
include:
- build_type: Debug
examples: ON
extra_tests: ON
steps:
- uses: actions/checkout@v4
- name: Configure build
working-directory: ${{runner.workspace}}
env:
CXX: ${{matrix.cxx}}
CXXFLAGS: ${{matrix.cxxflags}}
run: |
cmake -Bbuild -H$GITHUB_WORKSPACE \
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
-DCMAKE_CXX_STANDARD=${{matrix.std}} \
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
-DCATCH_DEVELOPMENT_BUILD=ON \
-DCATCH_BUILD_EXAMPLES=${{matrix.examples}} \
-DCATCH_BUILD_EXTRA_TESTS=${{matrix.examples}}
- name: Build tests + lib
working-directory: ${{runner.workspace}}/build
run: make -j `sysctl -n hw.ncpu`
- name: Run tests
env:
CTEST_OUTPUT_ON_FAILURE: 1
working-directory: ${{runner.workspace}}/build
run: ctest -C ${{matrix.build_type}} -j `sysctl -n hw.ncpu`

View File

@@ -4,11 +4,7 @@ on: [push, pull_request]
jobs:
build:
# macos-12 updated to a toolchain that crashes when linking the
# test binary. This seems to be a known bug in that version,
# and will eventually get fixed in an update. After that, we can go
# back to newer macos images.
runs-on: macos-11
runs-on: macos-14
strategy:
matrix:
cxx:

View File

@@ -9,12 +9,12 @@ jobs:
strategy:
matrix:
conan_version:
- '1.63'
- '2.1'
- '1.62'
- '2.0'
include:
# Conan 1 has default profiles installed
- conan_version: '1.63'
- conan_version: '1.62'
profile_generate: 'false'
steps:

View File

@@ -33,7 +33,7 @@ if (CMAKE_BINARY_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
endif()
project(Catch2
VERSION 3.5.4 # CML version placeholder, don't delete
VERSION 3.5.3 # CML version placeholder, don't delete
LANGUAGES CXX
# HOMEPAGE_URL is not supported until CMake version 3.12, which
# we do not target yet.
@@ -200,4 +200,4 @@ if (NOT_SUBPROJECT)
include( CPack )
endif()
endif(NOT_SUBPROJECT)

View File

@@ -1,11 +1,9 @@
#!/usr/bin/env python
from conan import ConanFile
from conan import ConanFile, tools, __version__ as conan_version
from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps, cmake_layout
from conan.tools.files import copy, rmdir
from conan.tools.build import check_min_cppstd
from conan.tools.scm import Version
from conan.errors import ConanInvalidConfiguration
from conan.tools import files, scm
import os
import shutil
import re
required_conan_version = ">=1.53.0"
@@ -18,32 +16,12 @@ class CatchConan(ConanFile):
homepage = url
license = "BSL-1.0"
version = "latest"
exports = "LICENSE.txt"
exports_sources = ("src/*", "CMakeLists.txt", "CMake/*", "extras/*")
settings = "os", "compiler", "build_type", "arch"
options = {
"shared": [True, False],
"fPIC": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
}
@property
def _min_cppstd(self):
return "14"
@property
def _compilers_minimum_version(self):
return {
"gcc": "7",
"Visual Studio": "15",
"msvc": "191",
"clang": "5",
"apple-clang": "10",
}
def set_version(self):
pattern = re.compile(r"\w*VERSION (\d+\.\d+\.\d+) # CML version placeholder, don't delete")
with open("CMakeLists.txt") as file:
@@ -54,57 +32,39 @@ class CatchConan(ConanFile):
self.output.info(f'Using version: {self.version}')
def export(self):
copy(self, "LICENSE.txt", src=self.recipe_folder, dst=self.export_folder)
def export_sources(self):
copy(self, "CMakeLists.txt", src=self.recipe_folder, dst=self.export_sources_folder)
copy(self, "src/*", src=self.recipe_folder, dst=self.export_sources_folder)
copy(self, "extras/*", src=self.recipe_folder, dst=self.export_sources_folder)
copy(self, "CMake/*", src=self.recipe_folder, dst=self.export_sources_folder)
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")
def layout(self):
cmake_layout(self)
def validate(self):
if self.settings.compiler.get_safe("cppstd"):
check_min_cppstd(self, self._min_cppstd)
# INFO: Conan 1.x does not specify cppstd by default, so we need to check the compiler version instead.
minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False)
if minimum_version and Version(self.settings.compiler.version) < minimum_version:
raise ConanInvalidConfiguration(f"{self.ref} requires C++{self._min_cppstd}, which your compiler doesn't support")
def generate(self):
tc = CMakeToolchain(self)
tc.cache_variables["BUILD_TESTING"] = False
tc.cache_variables["CATCH_INSTALL_DOCS"] = False
tc.cache_variables["CATCH_INSTALL_EXTRAS"] = True
tc.generate()
deps = CMakeDeps(self)
deps.generate()
def build(self):
def _configure_cmake(self):
cmake = CMake(self)
cmake.configure()
# These are option variables. The toolchain in conan 2 doesn't appear to
# set these correctly so you have to do it in the configure variables.
cmake.configure(variables= {
"BUILD_TESTING": "OFF",
"CATCH_INSTALL_DOCS": "OFF",
"CATCH_INSTALL_EXTRAS": "ON",
}
)
return cmake
def build(self):
cmake = self._configure_cmake()
cmake.build()
def package(self):
copy(self, "LICENSE.txt", src=str(self.recipe_folder), dst=os.path.join(self.package_folder, "licenses"))
cmake = CMake(self)
cmake = self._configure_cmake()
cmake.install()
rmdir(self, os.path.join(self.package_folder, "share"))
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
copy(self, "*.cmake", src=os.path.join(self.export_sources_folder, "extras"),
dst=os.path.join(self.package_folder, "lib", "cmake", "Catch2"))
os.mkdir(f'{self.package_folder}/licenses/')
shutil.copy2(f'{self.recipe_folder}/LICENSE.txt', f'{self.package_folder}/licenses/')
def package_info(self):
lib_suffix = "d" if self.settings.build_type == "Debug" else ""

View File

@@ -145,7 +145,7 @@ only tests that match the positive filters are included.
You can also match test names with special characters by escaping them
with a backslash (`"\"`), e.g. a test named `"Do A, then B"` is matched
by `"Do A\, then B"` test spec. Backslash also escapes itself.
by "Do A\, then B" test spec. Backslash also escapes itself.
### Examples
@@ -194,8 +194,7 @@ verbose and human-friendly output.
Reporters are also individually configurable. To pass configuration options
to the reporter, you append `::key=value` to the reporter specification
as many times as you want, e.g. `--reporter xml::out=someFile.xml` or
`--reporter custom::colour-mode=ansi::Xoption=2`.
as many times as you want, e.g. `--reporter xml::out=someFile.xml`.
The keys must either be prefixed by "X", in which case they are not parsed
by Catch2 and are only passed down to the reporter, or one of options

View File

@@ -114,10 +114,6 @@ Similar to `INFO`, but messages are not limited to their own scope: They are rem
The message is always reported but does not fail the test.
**SUCCEED(** _message expression_ **)**
The message is reported and the test case succeeds.
**FAIL(** _message expression_ **)**
The message is reported and the test case fails.

View File

@@ -2,7 +2,6 @@
# Release notes
**Contents**<br>
[3.5.4](#354)<br>
[3.5.3](#353)<br>
[3.5.2](#352)<br>
[3.5.1](#351)<br>
@@ -62,29 +61,6 @@
[Even Older versions](#even-older-versions)<br>
## 3.5.4
### Fixes
* Fixed potential compilation error when asked to generate random integers whose type did not match `std::(u)int*_t`.
* This manifested itself when generating random `size_t`s on MacOS
* Added missing outlined destructor causing `Wdelete-incomplete` when compiling against libstdc++ in C++23 mode (#2852)
* Fixed regression where decomposing assertion with const instance of `std::foo_ordering` would not compile
### Improvements
* Reintroduced support for GCC 5 and 6 (#2836)
* As with VS2017, if they start causing trouble again, they will be dropped again.
* Added workaround for targetting newest MacOS (Sonoma) using GCC (#2837, #2839)
* `CATCH_CONFIG_DEFAULT_REPORTER` can now be an arbitrary reporter spec
* Previously it could only be a plain reporter name, so it was impossible to compile in custom arguments to the reporter.
* Improved performance of generating 64bit random integers by 20+%
### Miscellaneous
* Significantly improved Conan in-tree recipe (#2831)
* `DL_PATHS` in `catch_discover_tests` now supports multiple arguments (#2852, #2736)
* Fixed preprocessor logic for checking whether we expect reproducible floating point results in tests.
* Improved the floating point tests structure to avoid `Wunused` when the reproducibility tests are disabled (#2845)
## 3.5.3
### Fixes

View File

@@ -21,8 +21,8 @@ function(catch_discover_tests_impl)
cmake_parse_arguments(
""
""
"TEST_EXECUTABLE;TEST_WORKING_DIR;TEST_OUTPUT_DIR;TEST_OUTPUT_PREFIX;TEST_OUTPUT_SUFFIX;TEST_PREFIX;TEST_REPORTER;TEST_SPEC;TEST_SUFFIX;TEST_LIST;CTEST_FILE"
"TEST_EXTRA_ARGS;TEST_PROPERTIES;TEST_EXECUTOR;TEST_DL_PATHS"
"TEST_EXECUTABLE;TEST_WORKING_DIR;TEST_DL_PATHS;TEST_OUTPUT_DIR;TEST_OUTPUT_PREFIX;TEST_OUTPUT_SUFFIX;TEST_PREFIX;TEST_REPORTER;TEST_SPEC;TEST_SUFFIX;TEST_LIST;CTEST_FILE"
"TEST_EXTRA_ARGS;TEST_PROPERTIES;TEST_EXECUTOR"
${ARGN}
)

View File

@@ -187,7 +187,7 @@ function(ParseAndAddCatchTests_ParseFile SourceFile TestTarget)
if(result)
set(HiddenTagFound ON)
break()
endif()
endif(result)
endforeach(label)
if(PARSE_CATCH_TESTS_NO_HIDDEN_TESTS AND ${HiddenTagFound} AND ${CMAKE_VERSION} VERSION_LESS "3.9")
ParseAndAddCatchTests_PrintDebugMessage("Skipping test \"${CTestName}\" as it has [!hide], [.] or [.foo] label")

View File

@@ -6,8 +6,8 @@
// SPDX-License-Identifier: BSL-1.0
// Catch v3.5.4
// Generated: 2024-04-10 12:03:46.281848
// Catch v3.5.3
// Generated: 2024-03-01 22:05:56.038084
// ----------------------------------------------------------
// This file is an amalgamation of multiple different files.
// You probably shouldn't edit it directly.
@@ -187,7 +187,7 @@ namespace Catch {
double const* last,
Estimator& estimator ) {
auto n = static_cast<size_t>( last - first );
Catch::uniform_integer_distribution<size_t> dist( 0, n - 1 );
std::uniform_int_distribution<size_t> dist( 0, n - 1 );
sample out;
out.reserve( resamples );
@@ -807,16 +807,14 @@ namespace Catch {
// Insert the default reporter if user hasn't asked for a specific one
if ( m_data.reporterSpecifications.empty() ) {
m_data.reporterSpecifications.push_back( {
#if defined( CATCH_CONFIG_DEFAULT_REPORTER )
const auto default_spec = CATCH_CONFIG_DEFAULT_REPORTER;
CATCH_CONFIG_DEFAULT_REPORTER,
#else
const auto default_spec = "console";
"console",
#endif
auto parsed = parseReporterSpec(default_spec);
CATCH_ENFORCE( parsed,
"Cannot parse the provided default reporter spec: '"
<< default_spec << '\'' );
m_data.reporterSpecifications.push_back( std::move( *parsed ) );
{}, {}, {}
} );
}
if ( enableBazelEnvSupport() ) {
@@ -2273,7 +2271,7 @@ namespace Catch {
}
Version const& libraryVersion() {
static Version version( 3, 5, 4, "", 0 );
static Version version( 3, 5, 3, "", 0 );
return version;
}
@@ -6603,8 +6601,6 @@ namespace Catch {
return getRegistryHub().getTestCaseRegistry().getAllTestsSorted( config );
}
TestRegistry::~TestRegistry() = default;
void TestRegistry::registerTest(Detail::unique_ptr<TestCaseInfo> testInfo, Detail::unique_ptr<ITestInvoker> testInvoker) {
m_handles.emplace_back(testInfo.get(), testInvoker.get());
m_viewed_test_infos.push_back(testInfo.get());

View File

@@ -6,8 +6,8 @@
// SPDX-License-Identifier: BSL-1.0
// Catch v3.5.4
// Generated: 2024-04-10 12:03:45.785902
// Catch v3.5.3
// Generated: 2024-03-01 22:05:55.031514
// ----------------------------------------------------------
// This file is an amalgamation of multiple different files.
// You probably shouldn't edit it directly.
@@ -87,9 +87,6 @@
// See e.g.:
// https://opensource.apple.com/source/CarbonHeaders/CarbonHeaders-18.1/TargetConditionals.h.auto.html
#ifdef __APPLE__
# ifndef __has_extension
# define __has_extension(x) 0
# endif
# include <TargetConditionals.h>
# if (defined(TARGET_OS_OSX) && TARGET_OS_OSX == 1) || \
(defined(TARGET_OS_MAC) && TARGET_OS_MAC == 1)
@@ -5257,12 +5254,6 @@ namespace Detail {
namespace Catch {
namespace Detail {
// This was added in C++20, but we require only C++14 for now.
template <typename T>
using RemoveCVRef_t = std::remove_cv_t<std::remove_reference_t<T>>;
}
// Note: There is nothing that stops us from extending this,
// e.g. to `std::is_scalar`, but the more encompassing
// traits are usually also more expensive. For now we
@@ -5302,13 +5293,14 @@ namespace Catch {
ITransientExpression(ITransientExpression const&) = default;
ITransientExpression& operator=(ITransientExpression const&) = default;
// We don't actually need a virtual destructor, but many static analysers
// complain if it's not here :-(
virtual ~ITransientExpression() = default;
friend std::ostream& operator<<(std::ostream& out, ITransientExpression const& expr) {
expr.streamReconstructedExpression(out);
return out;
}
protected:
~ITransientExpression() = default;
};
void formatReconstructedExpression( std::ostream &os, std::string const& lhs, StringRef op, std::string const& rhs );
@@ -5417,7 +5409,7 @@ namespace Catch {
->std::enable_if_t< \
Detail::conjunction<Detail::is_##id##_comparable<LhsT, RhsT>, \
Detail::negation<capture_by_value< \
Detail::RemoveCVRef_t<RhsT>>>>::value, \
std::remove_reference_t<RhsT>>>>::value, \
BinaryExpr<LhsT, RhsT const&>> { \
return { \
static_cast<bool>( lhs.m_lhs op rhs ), lhs.m_lhs, #op##_sr, rhs }; \
@@ -5471,7 +5463,7 @@ namespace Catch {
->std::enable_if_t< \
Detail::conjunction<Detail::is_##id##_comparable<LhsT, RhsT>, \
Detail::negation<capture_by_value< \
Detail::RemoveCVRef_t<RhsT>>>>::value, \
std::remove_reference_t<RhsT>>>>::value, \
BinaryExpr<LhsT, RhsT const&>> { \
return { \
static_cast<bool>( lhs.m_lhs op rhs ), lhs.m_lhs, #op##_sr, rhs }; \
@@ -5521,7 +5513,7 @@ namespace Catch {
template <typename RhsT> \
constexpr friend auto operator op( ExprLhs&& lhs, RhsT&& rhs ) \
->std::enable_if_t< \
!capture_by_value<Detail::RemoveCVRef_t<RhsT>>::value, \
!capture_by_value<std::remove_reference_t<RhsT>>::value, \
BinaryExpr<LhsT, RhsT const&>> { \
return { \
static_cast<bool>( lhs.m_lhs op rhs ), lhs.m_lhs, #op##_sr, rhs }; \
@@ -5561,7 +5553,8 @@ namespace Catch {
struct Decomposer {
template <typename T,
std::enable_if_t<!capture_by_value<Detail::RemoveCVRef_t<T>>::value,
std::enable_if_t<
!capture_by_value<std::remove_reference_t<T>>::value,
int> = 0>
constexpr friend auto operator <= ( Decomposer &&, T && lhs ) -> ExprLhs<T const&> {
return ExprLhs<const T&>{ lhs };
@@ -7270,7 +7263,7 @@ namespace Catch {
#define CATCH_VERSION_MAJOR 3
#define CATCH_VERSION_MINOR 5
#define CATCH_VERSION_PATCH 4
#define CATCH_VERSION_PATCH 3
#endif // CATCH_VERSION_MACROS_HPP_INCLUDED
@@ -7942,32 +7935,6 @@ namespace Catch {
#include <cstdint>
#include <type_traits>
// Note: We use the usual enable-disable-autodetect dance here even though
// we do not support these in CMake configuration options (yet?).
// It is highly unlikely that we will need to make these actually
// user-configurable, but this will make it simpler if weend up needing
// it, and it provides an escape hatch to the users who need it.
#if defined( __SIZEOF_INT128__ )
# define CATCH_CONFIG_INTERNAL_UINT128
#elif defined( _MSC_VER ) && ( defined( _WIN64 ) || defined( _M_ARM64 ) )
# define CATCH_CONFIG_INTERNAL_MSVC_UMUL128
#endif
#if defined( CATCH_CONFIG_INTERNAL_UINT128 ) && \
!defined( CATCH_CONFIG_NO_UINT128 ) && \
!defined( CATCH_CONFIG_UINT128 )
#define CATCH_CONFIG_UINT128
#endif
#if defined( CATCH_CONFIG_INTERNAL_MSVC_UMUL128 ) && \
!defined( CATCH_CONFIG_NO_MSVC_UMUL128 ) && \
!defined( CATCH_CONFIG_MSVC_UMUL128 )
# define CATCH_CONFIG_MSVC_UMUL128
# include <intrin.h>
# pragma intrinsic( _umul128 )
#endif
namespace Catch {
namespace Detail {
@@ -8000,52 +7967,59 @@ namespace Catch {
}
};
/**
* Returns 128 bit result of lhs * rhs using portable C++ code
*
* This implementation is almost twice as fast as naive long multiplication,
* and unlike intrinsic-based approach, it supports constexpr evaluation.
*/
// Returns 128 bit result of multiplying lhs and rhs
constexpr ExtendedMultResult<std::uint64_t>
extendedMultPortable(std::uint64_t lhs, std::uint64_t rhs) {
extendedMult( std::uint64_t lhs, std::uint64_t rhs ) {
// We use the simple long multiplication approach for
// correctness, we can use platform specific builtins
// for performance later.
// Split the lhs and rhs into two 32bit "digits", so that we can
// do 64 bit arithmetic to handle carry bits.
// 32b 32b 32b 32b
// lhs L1 L2
// * rhs R1 R2
// ------------------------
// | R2 * L2 |
// | R2 * L1 |
// | R1 * L2 |
// | R1 * L1 |
// -------------------------
// | a | b | c | d |
#define CarryBits( x ) ( x >> 32 )
#define Digits( x ) ( x & 0xFF'FF'FF'FF )
std::uint64_t lhs_low = Digits( lhs );
std::uint64_t rhs_low = Digits( rhs );
std::uint64_t low_low = ( lhs_low * rhs_low );
std::uint64_t high_high = CarryBits( lhs ) * CarryBits( rhs );
// We add in carry bits from low-low already
std::uint64_t high_low =
( CarryBits( lhs ) * rhs_low ) + CarryBits( low_low );
// Note that we can add only low bits from high_low, to avoid
// overflow with large inputs
std::uint64_t low_high =
( lhs_low * CarryBits( rhs ) ) + Digits( high_low );
auto r2l2 = Digits( rhs ) * Digits( lhs );
auto r2l1 = Digits( rhs ) * CarryBits( lhs );
auto r1l2 = CarryBits( rhs ) * Digits( lhs );
auto r1l1 = CarryBits( rhs ) * CarryBits( lhs );
// Sum to columns first
auto d = Digits( r2l2 );
auto c = CarryBits( r2l2 ) + Digits( r2l1 ) + Digits( r1l2 );
auto b = CarryBits( r2l1 ) + CarryBits( r1l2 ) + Digits( r1l1 );
auto a = CarryBits( r1l1 );
// Propagate carries between columns
c += CarryBits( d );
b += CarryBits( c );
a += CarryBits( b );
// Remove the used carries
c = Digits( c );
b = Digits( b );
a = Digits( a );
return { high_high + CarryBits( high_low ) + CarryBits( low_high ),
( low_high << 32 ) | Digits( low_low ) };
#undef CarryBits
#undef Digits
}
//! Returns 128 bit result of lhs * rhs
inline ExtendedMultResult<std::uint64_t>
extendedMult( std::uint64_t lhs, std::uint64_t rhs ) {
#if defined( CATCH_CONFIG_UINT128 )
auto result = __uint128_t( lhs ) * __uint128_t( rhs );
return { static_cast<std::uint64_t>( result >> 64 ),
static_cast<std::uint64_t>( result ) };
#elif defined( CATCH_CONFIG_MSVC_UMUL128 )
std::uint64_t high;
std::uint64_t low = _umul128( lhs, rhs, &high );
return { high, low };
#else
return extendedMultPortable( lhs, rhs );
#endif
return {
a << 32 | b, // upper 64 bits
c << 32 | d // lower 64 bits
};
}
template <typename UInt>
constexpr ExtendedMultResult<UInt> extendedMult( UInt lhs, UInt rhs ) {
static_assert( std::is_unsigned<UInt>::value,
@@ -8149,6 +8123,22 @@ namespace Catch {
namespace Catch {
namespace Detail {
// Indirection to enable make_unsigned<bool> behaviour.
template <typename T>
struct make_unsigned {
using type = std::make_unsigned_t<T>;
};
template <>
struct make_unsigned<bool> {
using type = uint8_t;
};
template <typename T>
using make_unsigned_t = typename make_unsigned<T>::type;
}
/**
* Implementation of uniform distribution on integers.
*
@@ -8164,7 +8154,7 @@ template <typename IntegerType>
class uniform_integer_distribution {
static_assert(std::is_integral<IntegerType>::value, "...");
using UnsignedIntegerType = Detail::SizedUnsignedType_t<sizeof(IntegerType)>;
using UnsignedIntegerType = Detail::make_unsigned_t<IntegerType>;
// Only the left bound is stored, and we store it converted to its
// unsigned image. This avoids having to do the conversions inside
@@ -10833,8 +10823,6 @@ namespace Catch {
std::vector<TestCaseHandle> const& getAllTests() const override;
std::vector<TestCaseHandle> const& getAllTestsSorted( IConfig const& config ) const override;
~TestRegistry() override; // = default
private:
std::vector<Detail::unique_ptr<TestCaseInfo>> m_owned_test_infos;
// Keeps a materialized vector for `getAllInfos`.

View File

@@ -8,7 +8,7 @@
project(
'catch2',
'cpp',
version: '3.5.4', # CML version placeholder, don't delete
version: '3.5.3', # CML version placeholder, don't delete
license: 'BSL-1.0',
meson_version: '>=0.54.1',
)

View File

@@ -362,10 +362,29 @@ set_target_properties(Catch2 PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION})
# require C++14
# depend on bunch of C++11 and C++14 features to have C++14 enabled by default
target_compile_features(Catch2
PUBLIC
cxx_std_14
cxx_alignas
cxx_alignof
cxx_attributes
cxx_auto_type
cxx_constexpr
cxx_defaulted_functions
cxx_deleted_functions
cxx_final
cxx_lambdas
cxx_noexcept
cxx_override
cxx_range_for
cxx_rvalue_references
cxx_static_assert
cxx_strong_enums
cxx_trailing_return_types
cxx_unicode_literals
cxx_user_literals
cxx_variable_templates
cxx_variadic_macros
)
configure_file(
@@ -456,7 +475,26 @@ if (CATCH_BUILD_EXAMPLES OR CATCH_BUILD_EXTRA_TESTS)
)
target_compile_features(Catch2_buildall_interface
INTERFACE
cxx_std_14
cxx_alignas
cxx_alignof
cxx_attributes
cxx_auto_type
cxx_constexpr
cxx_defaulted_functions
cxx_deleted_functions
cxx_final
cxx_lambdas
cxx_noexcept
cxx_override
cxx_range_for
cxx_rvalue_references
cxx_static_assert
cxx_strong_enums
cxx_trailing_return_types
cxx_unicode_literals
cxx_user_literals
cxx_variable_templates
cxx_variadic_macros
)
endif()

View File

@@ -12,7 +12,6 @@
#include <catch2/internal/catch_compiler_capabilities.hpp>
#include <catch2/internal/catch_floating_point_helpers.hpp>
#include <catch2/internal/catch_random_number_generator.hpp>
#include <catch2/internal/catch_uniform_integer_distribution.hpp>
#include <algorithm>
#include <cassert>
@@ -39,7 +38,7 @@ namespace Catch {
double const* last,
Estimator& estimator ) {
auto n = static_cast<size_t>( last - first );
Catch::uniform_integer_distribution<size_t> dist( 0, n - 1 );
std::uniform_int_distribution<size_t> dist( 0, n - 1 );
sample out;
out.reserve( resamples );

View File

@@ -107,16 +107,14 @@ namespace Catch {
// Insert the default reporter if user hasn't asked for a specific one
if ( m_data.reporterSpecifications.empty() ) {
m_data.reporterSpecifications.push_back( {
#if defined( CATCH_CONFIG_DEFAULT_REPORTER )
const auto default_spec = CATCH_CONFIG_DEFAULT_REPORTER;
CATCH_CONFIG_DEFAULT_REPORTER,
#else
const auto default_spec = "console";
"console",
#endif
auto parsed = parseReporterSpec(default_spec);
CATCH_ENFORCE( parsed,
"Cannot parse the provided default reporter spec: '"
<< default_spec << '\'' );
m_data.reporterSpecifications.push_back( std::move( *parsed ) );
{}, {}, {}
} );
}
if ( enableBazelEnvSupport() ) {

View File

@@ -36,7 +36,7 @@ namespace Catch {
}
Version const& libraryVersion() {
static Version version( 3, 5, 4, "", 0 );
static Version version( 3, 5, 3, "", 0 );
return version;
}

View File

@@ -10,6 +10,6 @@
#define CATCH_VERSION_MAJOR 3
#define CATCH_VERSION_MINOR 5
#define CATCH_VERSION_PATCH 4
#define CATCH_VERSION_PATCH 3
#endif // CATCH_VERSION_MACROS_HPP_INCLUDED

View File

@@ -125,12 +125,6 @@
namespace Catch {
namespace Detail {
// This was added in C++20, but we require only C++14 for now.
template <typename T>
using RemoveCVRef_t = std::remove_cv_t<std::remove_reference_t<T>>;
}
// Note: There is nothing that stops us from extending this,
// e.g. to `std::is_scalar`, but the more encompassing
// traits are usually also more expensive. For now we
@@ -285,7 +279,7 @@ namespace Catch {
->std::enable_if_t< \
Detail::conjunction<Detail::is_##id##_comparable<LhsT, RhsT>, \
Detail::negation<capture_by_value< \
Detail::RemoveCVRef_t<RhsT>>>>::value, \
std::remove_reference_t<RhsT>>>>::value, \
BinaryExpr<LhsT, RhsT const&>> { \
return { \
static_cast<bool>( lhs.m_lhs op rhs ), lhs.m_lhs, #op##_sr, rhs }; \
@@ -339,7 +333,7 @@ namespace Catch {
->std::enable_if_t< \
Detail::conjunction<Detail::is_##id##_comparable<LhsT, RhsT>, \
Detail::negation<capture_by_value< \
Detail::RemoveCVRef_t<RhsT>>>>::value, \
std::remove_reference_t<RhsT>>>>::value, \
BinaryExpr<LhsT, RhsT const&>> { \
return { \
static_cast<bool>( lhs.m_lhs op rhs ), lhs.m_lhs, #op##_sr, rhs }; \
@@ -389,7 +383,7 @@ namespace Catch {
template <typename RhsT> \
constexpr friend auto operator op( ExprLhs&& lhs, RhsT&& rhs ) \
->std::enable_if_t< \
!capture_by_value<Detail::RemoveCVRef_t<RhsT>>::value, \
!capture_by_value<std::remove_reference_t<RhsT>>::value, \
BinaryExpr<LhsT, RhsT const&>> { \
return { \
static_cast<bool>( lhs.m_lhs op rhs ), lhs.m_lhs, #op##_sr, rhs }; \
@@ -429,7 +423,8 @@ namespace Catch {
struct Decomposer {
template <typename T,
std::enable_if_t<!capture_by_value<Detail::RemoveCVRef_t<T>>::value,
std::enable_if_t<
!capture_by_value<std::remove_reference_t<T>>::value,
int> = 0>
constexpr friend auto operator <= ( Decomposer &&, T && lhs ) -> ExprLhs<T const&> {
return ExprLhs<const T&>{ lhs };

View File

@@ -11,9 +11,6 @@
// See e.g.:
// https://opensource.apple.com/source/CarbonHeaders/CarbonHeaders-18.1/TargetConditionals.h.auto.html
#ifdef __APPLE__
# ifndef __has_extension
# define __has_extension(x) 0
# endif
# include <TargetConditionals.h>
# if (defined(TARGET_OS_OSX) && TARGET_OS_OSX == 1) || \
(defined(TARGET_OS_MAC) && TARGET_OS_MAC == 1)

View File

@@ -14,32 +14,6 @@
#include <cstdint>
#include <type_traits>
// Note: We use the usual enable-disable-autodetect dance here even though
// we do not support these in CMake configuration options (yet?).
// It is highly unlikely that we will need to make these actually
// user-configurable, but this will make it simpler if weend up needing
// it, and it provides an escape hatch to the users who need it.
#if defined( __SIZEOF_INT128__ )
# define CATCH_CONFIG_INTERNAL_UINT128
#elif defined( _MSC_VER ) && ( defined( _WIN64 ) || defined( _M_ARM64 ) )
# define CATCH_CONFIG_INTERNAL_MSVC_UMUL128
#endif
#if defined( CATCH_CONFIG_INTERNAL_UINT128 ) && \
!defined( CATCH_CONFIG_NO_UINT128 ) && \
!defined( CATCH_CONFIG_UINT128 )
#define CATCH_CONFIG_UINT128
#endif
#if defined( CATCH_CONFIG_INTERNAL_MSVC_UMUL128 ) && \
!defined( CATCH_CONFIG_NO_MSVC_UMUL128 ) && \
!defined( CATCH_CONFIG_MSVC_UMUL128 )
# define CATCH_CONFIG_MSVC_UMUL128
# include <intrin.h>
# pragma intrinsic( _umul128 )
#endif
namespace Catch {
namespace Detail {
@@ -72,52 +46,59 @@ namespace Catch {
}
};
/**
* Returns 128 bit result of lhs * rhs using portable C++ code
*
* This implementation is almost twice as fast as naive long multiplication,
* and unlike intrinsic-based approach, it supports constexpr evaluation.
*/
// Returns 128 bit result of multiplying lhs and rhs
constexpr ExtendedMultResult<std::uint64_t>
extendedMultPortable(std::uint64_t lhs, std::uint64_t rhs) {
extendedMult( std::uint64_t lhs, std::uint64_t rhs ) {
// We use the simple long multiplication approach for
// correctness, we can use platform specific builtins
// for performance later.
// Split the lhs and rhs into two 32bit "digits", so that we can
// do 64 bit arithmetic to handle carry bits.
// 32b 32b 32b 32b
// lhs L1 L2
// * rhs R1 R2
// ------------------------
// | R2 * L2 |
// | R2 * L1 |
// | R1 * L2 |
// | R1 * L1 |
// -------------------------
// | a | b | c | d |
#define CarryBits( x ) ( x >> 32 )
#define Digits( x ) ( x & 0xFF'FF'FF'FF )
std::uint64_t lhs_low = Digits( lhs );
std::uint64_t rhs_low = Digits( rhs );
std::uint64_t low_low = ( lhs_low * rhs_low );
std::uint64_t high_high = CarryBits( lhs ) * CarryBits( rhs );
// We add in carry bits from low-low already
std::uint64_t high_low =
( CarryBits( lhs ) * rhs_low ) + CarryBits( low_low );
// Note that we can add only low bits from high_low, to avoid
// overflow with large inputs
std::uint64_t low_high =
( lhs_low * CarryBits( rhs ) ) + Digits( high_low );
auto r2l2 = Digits( rhs ) * Digits( lhs );
auto r2l1 = Digits( rhs ) * CarryBits( lhs );
auto r1l2 = CarryBits( rhs ) * Digits( lhs );
auto r1l1 = CarryBits( rhs ) * CarryBits( lhs );
// Sum to columns first
auto d = Digits( r2l2 );
auto c = CarryBits( r2l2 ) + Digits( r2l1 ) + Digits( r1l2 );
auto b = CarryBits( r2l1 ) + CarryBits( r1l2 ) + Digits( r1l1 );
auto a = CarryBits( r1l1 );
// Propagate carries between columns
c += CarryBits( d );
b += CarryBits( c );
a += CarryBits( b );
// Remove the used carries
c = Digits( c );
b = Digits( b );
a = Digits( a );
return { high_high + CarryBits( high_low ) + CarryBits( low_high ),
( low_high << 32 ) | Digits( low_low ) };
#undef CarryBits
#undef Digits
}
//! Returns 128 bit result of lhs * rhs
inline ExtendedMultResult<std::uint64_t>
extendedMult( std::uint64_t lhs, std::uint64_t rhs ) {
#if defined( CATCH_CONFIG_UINT128 )
auto result = __uint128_t( lhs ) * __uint128_t( rhs );
return { static_cast<std::uint64_t>( result >> 64 ),
static_cast<std::uint64_t>( result ) };
#elif defined( CATCH_CONFIG_MSVC_UMUL128 )
std::uint64_t high;
std::uint64_t low = _umul128( lhs, rhs, &high );
return { high, low };
#else
return extendedMultPortable( lhs, rhs );
#endif
return {
a << 32 | b, // upper 64 bits
c << 32 | d // lower 64 bits
};
}
template <typename UInt>
constexpr ExtendedMultResult<UInt> extendedMult( UInt lhs, UInt rhs ) {
static_assert( std::is_unsigned<UInt>::value,

View File

@@ -123,8 +123,6 @@ namespace Catch {
return getRegistryHub().getTestCaseRegistry().getAllTestsSorted( config );
}
TestRegistry::~TestRegistry() = default;
void TestRegistry::registerTest(Detail::unique_ptr<TestCaseInfo> testInfo, Detail::unique_ptr<ITestInvoker> testInvoker) {
m_handles.emplace_back(testInfo.get(), testInvoker.get());
m_viewed_test_infos.push_back(testInfo.get());

View File

@@ -36,8 +36,6 @@ namespace Catch {
std::vector<TestCaseHandle> const& getAllTests() const override;
std::vector<TestCaseHandle> const& getAllTestsSorted( IConfig const& config ) const override;
~TestRegistry() override; // = default
private:
std::vector<Detail::unique_ptr<TestCaseInfo>> m_owned_test_infos;
// Keeps a materialized vector for `getAllInfos`.

View File

@@ -13,6 +13,22 @@
namespace Catch {
namespace Detail {
// Indirection to enable make_unsigned<bool> behaviour.
template <typename T>
struct make_unsigned {
using type = std::make_unsigned_t<T>;
};
template <>
struct make_unsigned<bool> {
using type = uint8_t;
};
template <typename T>
using make_unsigned_t = typename make_unsigned<T>::type;
}
/**
* Implementation of uniform distribution on integers.
*
@@ -28,7 +44,7 @@ template <typename IntegerType>
class uniform_integer_distribution {
static_assert(std::is_integral<IntegerType>::value, "...");
using UnsignedIntegerType = Detail::SizedUnsignedType_t<sizeof(IntegerType)>;
using UnsignedIntegerType = Detail::make_unsigned_t<IntegerType>;
// Only the left bound is stored, and we store it converted to its
// unsigned image. This avoids having to do the conversions inside

View File

@@ -59,7 +59,7 @@ if (CATCH_BUILD_SURROGATES)
)
target_link_libraries(Catch2SurrogateTarget PRIVATE Catch2WithMain)
endif()
endif(CATCH_BUILD_SURROGATES)
####
# Temporary workaround for VS toolset changes in 2017
@@ -70,7 +70,7 @@ if (MSVC)
configure_file(${CATCH_DIR}/tools/misc/SelfTest.vcxproj.user
${CMAKE_BINARY_DIR}/tests
COPYONLY)
endif() #Temporary workaround
endif(MSVC) #Temporary workaround
# define the sources of the self test

View File

@@ -183,7 +183,7 @@ if (NOT WIN32)
PROPERTIES
PASS_REGULAR_EXPRESSION "Catch will terminate"
)
endif()
endif(NOT WIN32)
add_test(NAME CATCH_CONFIG_DISABLE_EXCEPTIONS-3 COMMAND DisabledExceptions-CustomHandler "Tests that run")
@@ -556,7 +556,6 @@ add_executable(AmalgamatedTestCompilation
${CATCH_DIR}/extras/catch_amalgamated.cpp
)
target_include_directories(AmalgamatedTestCompilation PRIVATE ${CATCH_DIR}/extras)
target_compile_features(AmalgamatedTestCompilation PRIVATE cxx_std_14)
add_test(NAME AmalgamatedFileTest COMMAND AmalgamatedTestCompilation)
set_tests_properties(

View File

@@ -8,7 +8,6 @@
#include <catch2/catch_test_macros.hpp>
#include <catch2/internal/catch_random_integer_helpers.hpp>
#include <random>
namespace {
template <typename Int>
@@ -21,58 +20,6 @@ namespace {
CHECK( extendedMult( b, a ) ==
ExtendedMultResult<Int>{ upper_result, lower_result } );
}
// Simple (and slow) implmentation of extended multiplication for tests
constexpr Catch::Detail::ExtendedMultResult<std::uint64_t>
extendedMultNaive( std::uint64_t lhs, std::uint64_t rhs ) {
// This is a simple long multiplication, where we split lhs and rhs
// into two 32-bit "digits", so that we can do ops with carry in 64-bits.
//
// 32b 32b 32b 32b
// lhs L1 L2
// * rhs R1 R2
// ------------------------
// | R2 * L2 |
// | R2 * L1 |
// | R1 * L2 |
// | R1 * L1 |
// -------------------------
// | a | b | c | d |
#define CarryBits( x ) ( x >> 32 )
#define Digits( x ) ( x & 0xFF'FF'FF'FF )
auto r2l2 = Digits( rhs ) * Digits( lhs );
auto r2l1 = Digits( rhs ) * CarryBits( lhs );
auto r1l2 = CarryBits( rhs ) * Digits( lhs );
auto r1l1 = CarryBits( rhs ) * CarryBits( lhs );
// Sum to columns first
auto d = Digits( r2l2 );
auto c = CarryBits( r2l2 ) + Digits( r2l1 ) + Digits( r1l2 );
auto b = CarryBits( r2l1 ) + CarryBits( r1l2 ) + Digits( r1l1 );
auto a = CarryBits( r1l1 );
// Propagate carries between columns
c += CarryBits( d );
b += CarryBits( c );
a += CarryBits( b );
// Remove the used carries
c = Digits( c );
b = Digits( b );
a = Digits( a );
#undef CarryBits
#undef Digits
return {
a << 32 | b, // upper 64 bits
c << 32 | d // lower 64 bits
};
}
} // namespace
TEST_CASE( "extendedMult 64x64", "[Integer][approvals]" ) {
@@ -115,27 +62,6 @@ TEST_CASE( "extendedMult 64x64", "[Integer][approvals]" ) {
0xdf44'2d22'ce48'59b9 );
}
TEST_CASE("extendedMult 64x64 - all implementations", "[integer][approvals]") {
using Catch::Detail::extendedMult;
using Catch::Detail::extendedMultPortable;
using Catch::Detail::fillBitsFrom;
std::random_device rng;
for (size_t i = 0; i < 100; ++i) {
auto a = fillBitsFrom<std::uint64_t>( rng );
auto b = fillBitsFrom<std::uint64_t>( rng );
CAPTURE( a, b );
auto naive_ab = extendedMultNaive( a, b );
REQUIRE( naive_ab == extendedMultNaive( b, a ) );
REQUIRE( naive_ab == extendedMultPortable( a, b ) );
REQUIRE( naive_ab == extendedMultPortable( b, a ) );
REQUIRE( naive_ab == extendedMult( a, b ) );
REQUIRE( naive_ab == extendedMult( b, a ) );
}
}
TEST_CASE( "SizedUnsignedType helpers", "[integer][approvals]" ) {
using Catch::Detail::SizedUnsignedType_t;
using Catch::Detail::DoubleWidthUnsignedType_t;

View File

@@ -140,9 +140,7 @@ TEMPLATE_TEST_CASE( "uniform_integer_distribution can handle unit ranges",
uint32_t,
int32_t,
uint64_t,
int64_t,
size_t,
ptrdiff_t) {
int64_t ) {
// We want random seed to sample different parts of the rng state,
// the output is predetermined anyway
std::random_device rd;
@@ -495,22 +493,6 @@ TEMPLATE_TEST_CASE( "uniform_integer_distribution is reproducible",
REQUIRE_THAT(generated, Catch::Matchers::RangeEquals(uniform_integer_test_params<TestType>::expected));
}
// The reproducibility tests assume that operations on `float`/`double`
// happen in the same precision as the operated-upon type. This is
// generally true, unless the code is compiled for 32 bit targets without
// SSE2 enabled, in which case the operations are done in the x87 FPU,
// which usually implies doing math in 80 bit floats, and then rounding
// into smaller type when the type is saved into memory. This obviously
// leads to a different answer, than doing the math in the correct precision.
#if ( defined( _MSC_VER ) && _M_IX86_FP < 2 ) || \
( defined( __GNUC__ ) && \
( ( defined( __i386__ ) || defined( __x86_64__ ) ) ) && \
!defined( __SSE2_MATH__ ) )
# define CATCH_TEST_CONFIG_DISABLE_FLOAT_REPRODUCIBILITY_TESTS
#endif
#if !defined( CATCH_TEST_CONFIG_DISABLE_FLOAT_REPRODUCIBILITY_TESTS )
namespace {
template <typename T>
struct uniform_fp_test_params;
@@ -568,6 +550,20 @@ namespace {
#endif
} // namespace
// The reproducibility tests assume that operations on `float`/`double`
// happen in the same precision as the operated-upon type. This is
// generally true, unless the code is compiled for 32 bit targets without
// SSE2 enabled, in which case the operations are done in the x87 FPU,
// which usually implies doing math in 80 bit floats, and then rounding
// into smaller type when the type is saved into memory. This obviously
// leads to a different answer, than doing the math in the correct precision.
#if ( defined( _MSC_VER ) && _M_IX86_FP < 2 ) || \
( defined( __GNUC__ ) && !defined( __SSE2_MATH__ ) )
# define CATCH_TEST_CONFIG_DISABLE_FLOAT_REPRODUCIBILITY_TESTS
#endif
#if !defined( CATCH_TEST_CONFIG_DISABLE_FLOAT_REPRODUCIBILITY_TESTS )
TEMPLATE_TEST_CASE( "uniform_floating_point_distribution is reproducible",
"[rng][distribution][floating-point][approvals]",
float,
@@ -598,7 +594,7 @@ TEMPLATE_TEST_CASE( "uniform_floating_point_distribution can handle unitary rang
CAPTURE( seed );
Catch::SimplePcg32 pcg( seed );
const auto highest = TestType(385.125);
const auto highest = uniform_fp_test_params<TestType>::highest;
Catch::uniform_floating_point_distribution<TestType> dist( highest,
highest );

View File

@@ -357,12 +357,6 @@ namespace {
constexpr friend bool operator op( ZeroLiteralConsteval, \
TypeWithConstevalLit0Comparison ) { \
return false; \
} \
/* std::orderings only have these for ==, but we add them for all \
operators so we can test all overloads for decomposer */ \
constexpr friend bool operator op( TypeWithConstevalLit0Comparison, \
TypeWithConstevalLit0Comparison ) { \
return true; \
}
DEFINE_COMP_OP( < )
@@ -400,33 +394,6 @@ TEST_CASE( "#2555 - types that can only be compared with 0 literal implemented a
REQUIRE_FALSE( 0 != TypeWithConstevalLit0Comparison{} );
}
// We check all comparison ops to test, even though orderings, the primary
// motivation for this functionality, only have self-comparison (and thus
// have the ambiguity issue) for `==` and `!=`.
TEST_CASE( "Comparing const instances of type registered with capture_by_value",
"[regression][approvals][compilation]" ) {
SECTION("Type with consteval-int constructor") {
auto const const_Lit0Type_1 = TypeWithConstevalLit0Comparison{};
auto const const_Lit0Type_2 = TypeWithConstevalLit0Comparison{};
REQUIRE( const_Lit0Type_1 == const_Lit0Type_2 );
REQUIRE( const_Lit0Type_1 <= const_Lit0Type_2 );
REQUIRE( const_Lit0Type_1 < const_Lit0Type_2 );
REQUIRE( const_Lit0Type_1 >= const_Lit0Type_2 );
REQUIRE( const_Lit0Type_1 > const_Lit0Type_2 );
REQUIRE( const_Lit0Type_1 != const_Lit0Type_2 );
}
SECTION("Type with constexpr-int constructor") {
auto const const_Lit0Type_1 = TypeWithLit0Comparisons{};
auto const const_Lit0Type_2 = TypeWithLit0Comparisons{};
REQUIRE( const_Lit0Type_1 == const_Lit0Type_2 );
REQUIRE( const_Lit0Type_1 <= const_Lit0Type_2 );
REQUIRE( const_Lit0Type_1 < const_Lit0Type_2 );
REQUIRE( const_Lit0Type_1 >= const_Lit0Type_2 );
REQUIRE( const_Lit0Type_1 > const_Lit0Type_2 );
REQUIRE( const_Lit0Type_1 != const_Lit0Type_2 );
}
}
#endif // C++20 consteval
@@ -453,17 +420,3 @@ TEST_CASE("#2571 - tests compile types that have multiple implicit constructors
REQUIRE( mic1 > mic2 );
REQUIRE( mic1 >= mic2 );
}
#if defined( CATCH_CONFIG_CPP20_COMPARE_OVERLOADS )
// This test does not test all the related codepaths, but it is the original
// reproducer
TEST_CASE( "Comparing const std::weak_ordering instances must compile",
"[compilation][approvals][regression]" ) {
auto const const_ordering_1 = std::weak_ordering::less;
auto const const_ordering_2 = std::weak_ordering::less;
auto plain_ordering_1 = std::weak_ordering::less;
REQUIRE( const_ordering_1 == plain_ordering_1 );
REQUIRE( const_ordering_1 == const_ordering_2 );
REQUIRE( plain_ordering_1 == const_ordering_1 );
}
#endif

View File

@@ -34,12 +34,6 @@ struct TypeWithLit0Comparisons {
constexpr friend bool operator op( ZeroLiteralAsPointer, \
TypeWithLit0Comparisons ) { \
return false; \
} \
/* std::orderings only have these for ==, but we add them for all \
operators so we can test all overloads for decomposer */ \
constexpr friend bool operator op( TypeWithLit0Comparisons, \
TypeWithLit0Comparisons ) { \
return true; \
}
DEFINE_COMP_OP( < )

View File

@@ -11,12 +11,6 @@ add_executable(tests
add_subdirectory(${CATCH2_PATH} catch2-build)
target_link_libraries(tests PRIVATE Catch2::Catch2WithMain)
enable_testing()
include(CTest)
include(Catch)
set(extra_args)
if (CMAKE_VERSION GREATER_EQUAL 3.27)
list(APPEND extra_args
DL_PATHS "${CMAKE_CURRENT_LIST_DIR};${CMAKE_CURRENT_LIST_DIR}/.."
)
endif ()
catch_discover_tests(tests ${extra_args})
catch_discover_tests(tests)

View File

@@ -10,24 +10,7 @@
import os
import subprocess
import sys
import re
import json
cmake_version_regex = re.compile('cmake version (\d+)\.(\d+)\.(\d+)')
def get_cmake_version():
result = subprocess.run(['cmake', '--version'],
capture_output = True,
check = True,
text = True)
version_match = cmake_version_regex.match(result.stdout)
if not version_match:
print('Could not find cmake version in output')
print(f"output: '{result.stdout}'")
exit(4)
return (int(version_match.group(1)),
int(version_match.group(2)),
int(version_match.group(3)))
def build_project(sources_dir, output_base_path, catch2_path):
build_dir = os.path.join(output_base_path, 'ctest-registration-test')
@@ -79,7 +62,8 @@ def get_test_names(build_path):
root = ET.fromstring(result.stdout)
return [tc.text for tc in root.findall('TestCase/Name')]
def get_ctest_listing(build_path):
def list_ctest_tests(build_path):
old_path = os.getcwd()
os.chdir(build_path)
@@ -89,10 +73,10 @@ def get_ctest_listing(build_path):
check = True,
text = True)
os.chdir(old_path)
return result.stdout
def extract_tests_from_ctest(ctest_output):
ctest_response = json.loads(ctest_output)
import json
ctest_response = json.loads(result.stdout)
tests = ctest_response['tests']
test_names = []
for test in tests:
@@ -106,15 +90,6 @@ def extract_tests_from_ctest(ctest_output):
return test_names
def check_DL_PATHS(ctest_output):
ctest_response = json.loads(ctest_output)
tests = ctest_response['tests']
for test in tests:
properties = test['properties']
for property in properties:
if property['name'] == 'ENVIRONMENT_MODIFICATION':
assert len(property['value']) == 2, f"The test provides 2 arguments to DL_PATHS, but instead found {len(property['value'])}"
def escape_catch2_test_name(name):
for char in ('\\', ',', '[', ']'):
name = name.replace(char, f"\\{char}")
@@ -131,8 +106,7 @@ if __name__ == '__main__':
build_path = build_project(sources_dir, output_base_path, catch2_path)
catch_test_names = [escape_catch2_test_name(name) for name in get_test_names(build_path)]
ctest_output = get_ctest_listing(build_path)
ctest_test_names = extract_tests_from_ctest(ctest_output)
ctest_test_names = list_ctest_tests(build_path)
mismatched = 0
for catch_test in catch_test_names:
@@ -147,7 +121,3 @@ if __name__ == '__main__':
if mismatched:
print(f"Found {mismatched} mismatched tests catch test names and ctest test commands!")
exit(1)
cmake_version = get_cmake_version()
if cmake_version >= (3, 27):
check_DL_PATHS(ctest_output)

View File

@@ -28,23 +28,14 @@ if len(sys.argv) != 3:
catch2_source_path = os.path.abspath(sys.argv[1])
build_dir_path = os.path.join(os.path.abspath(sys.argv[2]), 'CMakeConfigTests', 'DefaultReporter')
output_file = f"{build_dir_path}/foo.xml"
# We need to escape backslashes in Windows paths, because otherwise they
# are interpreted as escape characters in strings, and cause compilation
# error.
escaped_output_file = output_file.replace('\\', '\\\\')
configure_and_build(catch2_source_path,
build_dir_path,
[("CATCH_CONFIG_DEFAULT_REPORTER", f"xml::out={escaped_output_file}")])
[("CATCH_CONFIG_DEFAULT_REPORTER", "xml")])
stdout, _ = run_and_return_output(os.path.join(build_dir_path, 'tests'), 'SelfTest', ['[approx][custom]'])
if not os.path.exists(output_file):
print(f'Did not find the {output_file} file')
exit(2)
xml_tag = '</Catch2TestRun>'
with open(output_file, 'r', encoding='utf-8') as file:
if xml_tag not in file.read():
print(f"Could not find '{xml_tag}' in the file")
exit(3)
if xml_tag not in stdout:
print("Could not find '{}' in the stdout".format(xml_tag))
print('stdout: "{}"'.format(stdout))
exit(2)