Upgrade to C++17

This commit is contained in:
Chris Thrasher
2025-09-21 13:23:25 -06:00
parent dc3a4ea41a
commit 9c089788ab
92 changed files with 428 additions and 913 deletions

View File

@@ -443,13 +443,9 @@ TEST_CASE( "Parse rng seed in different formats", "[approvals][cli][rng-seed]" )
auto cli = Catch::makeCommandLineParser( config );
SECTION("well formed cases") {
char const* seed_string;
uint32_t seed_value;
// GCC-5 workaround
using gen_type = std::tuple<char const*, uint32_t>;
std::tie( seed_string, seed_value ) = GENERATE( table<char const*, uint32_t>({
gen_type{ "0xBEEF", 0xBEEF },
gen_type{ "12345678", 12345678 }
auto [seed_string, seed_value] = GENERATE( table<char const*, uint32_t>({
{ "0xBEEF", 0xBEEF },
{ "12345678", 12345678 }
} ) );
CAPTURE( seed_string );

View File

@@ -130,10 +130,10 @@ TEST_CASE( "count_equidistant_floats",
std::numeric_limits<double>::max() ) ==
18014398509481982 ); // (1 << 54) - 2 due to not including infinities
STATIC_REQUIRE( std::is_same<std::uint64_t,
decltype( count_floats_with_scaled_ulp(
0., 1. ) )>::value );
STATIC_REQUIRE( std::is_same<std::uint32_t,
decltype( count_floats_with_scaled_ulp(
0.f, 1.f ) )>::value );
STATIC_REQUIRE( std::is_same_v<std::uint64_t,
decltype( count_floats_with_scaled_ulp(
0., 1. ) )> );
STATIC_REQUIRE( std::is_same_v<std::uint32_t,
decltype( count_floats_with_scaled_ulp(
0.f, 1.f ) )> );
}

View File

@@ -427,7 +427,7 @@ TEST_CASE("GENERATE handles function (pointers)", "[generators][compilation][app
TEST_CASE("GENERATE decays arrays", "[generators][compilation][approvals]") {
auto str = GENERATE("abc", "def", "gh");
(void)str;
STATIC_REQUIRE(std::is_same<decltype(str), const char*>::value);
STATIC_REQUIRE(std::is_same_v<decltype(str), const char*>);
}
TEST_CASE("Generators count returned elements", "[generators][approvals]") {

View File

@@ -146,11 +146,11 @@ TEST_CASE( "SizedUnsignedType helpers", "[integer][approvals]" ) {
STATIC_REQUIRE( sizeof( SizedUnsignedType_t<8> ) == 8 );
STATIC_REQUIRE( sizeof( DoubleWidthUnsignedType_t<std::uint8_t> ) == 2 );
STATIC_REQUIRE( std::is_unsigned<DoubleWidthUnsignedType_t<std::uint8_t>>::value );
STATIC_REQUIRE( std::is_unsigned_v<DoubleWidthUnsignedType_t<std::uint8_t>> );
STATIC_REQUIRE( sizeof( DoubleWidthUnsignedType_t<std::uint16_t> ) == 4 );
STATIC_REQUIRE( std::is_unsigned<DoubleWidthUnsignedType_t<std::uint16_t>>::value );
STATIC_REQUIRE( std::is_unsigned_v<DoubleWidthUnsignedType_t<std::uint16_t>> );
STATIC_REQUIRE( sizeof( DoubleWidthUnsignedType_t<std::uint32_t> ) == 8 );
STATIC_REQUIRE( std::is_unsigned<DoubleWidthUnsignedType_t<std::uint32_t>>::value );
STATIC_REQUIRE( std::is_unsigned_v<DoubleWidthUnsignedType_t<std::uint32_t>> );
}
TEST_CASE( "extendedMult 32x32", "[integer][approvals]" ) {

View File

@@ -214,7 +214,7 @@ TEMPLATE_TEST_CASE( "uniform_integer_distribution can handle full width ranges",
constexpr auto lowest = std::numeric_limits<TestType>::min();
constexpr auto highest = std::numeric_limits<TestType>::max();
Catch::uniform_integer_distribution<TestType> dist( lowest, highest );
STATIC_REQUIRE( std::is_same<TestType, decltype( dist( pcg ) )>::value );
STATIC_REQUIRE( std::is_same_v<TestType, decltype( dist( pcg ) )> );
// We need to do bit operations on the results, so we will have to
// cast them to unsigned type.
@@ -451,21 +451,6 @@ namespace {
381264073 };
};
// We need these definitions for C++14 and earlier, but
// GCC will complain about them in newer C++ standards
#if __cplusplus <= 201402L
constexpr bool uniform_integer_test_params<bool>::expected[];
constexpr char uniform_integer_test_params<char>::expected[];
constexpr uint8_t uniform_integer_test_params<uint8_t>::expected[];
constexpr int8_t uniform_integer_test_params<int8_t>::expected[];
constexpr uint16_t uniform_integer_test_params<uint16_t>::expected[];
constexpr int16_t uniform_integer_test_params<int16_t>::expected[];
constexpr uint32_t uniform_integer_test_params<uint32_t>::expected[];
constexpr int32_t uniform_integer_test_params<int32_t>::expected[];
constexpr uint64_t uniform_integer_test_params<uint64_t>::expected[];
constexpr int64_t uniform_integer_test_params<int64_t>::expected[];
#endif
}
TEMPLATE_TEST_CASE( "uniform_integer_distribution is reproducible",
@@ -559,13 +544,6 @@ namespace {
60912.7615841752,
-149060.05936760217 };
};
// We need these definitions for C++14 and earlier, but
// GCC will complain about them in newer C++ standards
#if __cplusplus <= 201402L
constexpr float uniform_fp_test_params<float>::expected[];
constexpr double uniform_fp_test_params<double>::expected[];
#endif
} // namespace
TEMPLATE_TEST_CASE( "uniform_floating_point_distribution is reproducible",

View File

@@ -17,8 +17,8 @@ static const char * const whitespace_at_both_ends = " \r\n \t There is no extra
TEST_CASE("Trim strings", "[string-manip]") {
using Catch::trim; using Catch::StringRef;
static_assert(std::is_same<std::string, decltype(trim(std::string{}))>::value, "Trimming std::string should return std::string");
static_assert(std::is_same<StringRef, decltype(trim(StringRef{}))>::value, "Trimming StringRef should return StringRef");
static_assert(std::is_same_v<std::string, decltype(trim(std::string{}))>, "Trimming std::string should return std::string");
static_assert(std::is_same_v<StringRef, decltype(trim(StringRef{}))>, "Trimming StringRef should return StringRef");
REQUIRE(trim(std::string(no_whitespace)) == no_whitespace);
REQUIRE(trim(std::string(leading_whitespace)) == no_whitespace);

View File

@@ -83,12 +83,12 @@ namespace {
} // end unnamed namespace
static_assert( std::is_constructible<Catch::Detail::unique_ptr<base>,
Catch::Detail::unique_ptr<derived>>::value, "Upcasting is supported");
static_assert(!std::is_constructible<Catch::Detail::unique_ptr<derived>,
Catch::Detail::unique_ptr<base>>::value, "Downcasting is not supported");
static_assert(!std::is_constructible<Catch::Detail::unique_ptr<base>,
Catch::Detail::unique_ptr<unrelated>>::value, "Cannot just convert one ptr type to another");
static_assert( std::is_constructible_v<Catch::Detail::unique_ptr<base>,
Catch::Detail::unique_ptr<derived>>, "Upcasting is supported");
static_assert(!std::is_constructible_v<Catch::Detail::unique_ptr<derived>,
Catch::Detail::unique_ptr<base>>, "Downcasting is not supported");
static_assert(!std::is_constructible_v<Catch::Detail::unique_ptr<base>,
Catch::Detail::unique_ptr<unrelated>>, "Cannot just convert one ptr type to another");
TEST_CASE("Upcasting special member functions", "[internals][unique-ptr]") {
using Catch::Detail::unique_ptr;