diff options
| author | Leitwolf11 | 2026-10-31 13:00:24 +0300 |
|---|---|---|
| committer | Leitwolf11 | 2026-10-31 13:00:24 +0300 |
| commit | 8814bd0b796b2e291fa5b4a1033f0313c8a26065 (patch) | |
| tree | e87e5f5150f3712bb05ed53911425600aa871f45 /tests/Progmasoft/Strategy.tests.cpp | |
| parent | 6a42cdf6461b2577106ef094d6f98025554b6077 (diff) | |
| download | catch3-8814bd0b796b2e291fa5b4a1033f0313c8a26065.tar.gz | |
Build Catch3 as C++17
C++17 is still the widest common target, and a library built on it stays
usable from C++17 and every later standard, while C++20 would have left
out many users.
Concepts become enable_if on named traits in Detail/TypeTraits.hpp, which
also replaces std::remove_cvref_t and std::identity. std::span becomes
std::vector references, std::bit_cast becomes static_cast and memcpy,
template lambdas become helper templates, and std::erase_if, contains,
starts_with and ends_with have their C++17 forms. Random::Between no
longer uses a lambda over a constexpr local, which MSVC rejects outside
/permissive-, so the headers work under its default mode too.
Tests give up designated initializers, which MSVC refuses in C++17. CI
builds the matrix in C++17 and C++20, since the headers promise both.
Diffstat (limited to 'tests/Progmasoft/Strategy.tests.cpp')
| -rw-r--r-- | tests/Progmasoft/Strategy.tests.cpp | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/tests/Progmasoft/Strategy.tests.cpp b/tests/Progmasoft/Strategy.tests.cpp index 5a1d5a2a..2bd49105 100644 --- a/tests/Progmasoft/Strategy.tests.cpp +++ b/tests/Progmasoft/Strategy.tests.cpp @@ -116,15 +116,23 @@ TEST_CASE( "Integer strategies respect every kind of range", TEST_CASE( "Float strategies stay finite and in range unless allowed", "[progmasoft][strategy]" ) { using Progmasoft::Catch3::FloatOptions; - const auto bounded = Gen::Floats<double>( - FloatOptions{ .Minimum = -2.5, .Maximum = 1000.0 } ); + const auto bounded = Gen::Floats<double>([&] { + FloatOptions made; + made.Minimum = -2.5; + made.Maximum = 1000.0; + return made; + }()); for ( double value : Sample( bounded, 3000, 6 ) ) { CHECK( std::isfinite( value ) ); CHECK( value >= -2.5 ); CHECK( value <= 1000.0 ); } - const auto everything = Gen::Floats<double>( - FloatOptions{ .AllowNaN = true, .AllowInfinity = true } ); + const auto everything = Gen::Floats<double>([&] { + FloatOptions made; + made.AllowNaN = true; + made.AllowInfinity = true; + return made; + }()); const auto values = Sample( everything, 3000, 7 ); CHECK( std::any_of( values.begin(), values.end(), []( double value ) { return std::isnan( value ); @@ -132,14 +140,22 @@ TEST_CASE( "Float strategies stay finite and in range unless allowed", CHECK( std::any_of( values.begin(), values.end(), []( double value ) { return std::isinf( value ); } ) ); - const auto positive = Gen::Floats<float>( - FloatOptions{ .Minimum = 1.0, .Maximum = 2.0 } ); + const auto positive = Gen::Floats<float>([&] { + FloatOptions made; + made.Minimum = 1.0; + made.Maximum = 2.0; + return made; + }()); const std::vector<std::uint64_t> zeros; ChoiceSource simplest( zeros, 0 ); CHECK( positive.Draw( simplest ) == 1.0F ); - CHECK_THROWS_AS( Gen::Floats<double>( FloatOptions{ .Minimum = 2.0, - .Maximum = 1.0 } ), - std::invalid_argument ); + CHECK_THROWS_AS(Gen::Floats<double>([&] { + FloatOptions made; + made.Minimum = 2.0; + made.Maximum = 1.0; + return made; + }()), + std::invalid_argument); } TEST_CASE( "Collection strategies respect their size ranges", |