catch3
Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.
Clonegit clone https://git.progmasoft.com/catch3
Compare whole numbers in catch3.json without floating-point equality
- Commit
0b4b57a0688f2943f4c797c20d68d533cf70fd15- Author
- Leitwolf11 ·
- Parents
f41a9c3c01b4
Changes
extras/catch_amalgamated.cpp | 8 ++++---- extras/catch_amalgamated.hpp | 2 +- src/Progmasoft/Runner/ProjectConfig.cpp | 6 +++--- tests/Progmasoft/RunnerConfig.tests.cpp | 4 +++- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/extras/catch_amalgamated.cpp b/extras/catch_amalgamated.cpp index b87c46a4..fc87bf40 100644 --- a/extras/catch_amalgamated.cpp +++ b/extras/catch_amalgamated.cpp @@ -7,7 +7,7 @@ // SPDX-License-Identifier: BSL-1.0 // Catch3 v0.3.0, on the Catch2 v3.16.1 engine -// Generated: 2026-10-29 19:10:35.449209 +// Generated: 2026-10-29 19:30:41.305371 // ---------------------------------------------------------- // This file is an amalgamation of multiple different files. // You probably shouldn't edit it directly. @@ -15774,7 +15774,7 @@ namespace Progmasoft::Catch3::Runner namespace { /// The version of the file format this runner reads. - constexpr double kConfigVersion = 1; + constexpr std::uint64_t kConfigVersion = 1; /// What the value of a key is, and how it becomes arguments. enum class ValueKind : std::uint8_t @@ -15933,7 +15933,7 @@ namespace Progmasoft::Catch3::Runner } const double number = value.AsNumber(); if (!std::isfinite(number) || number < 0 - || number != std::floor(number) || number > 9007199254740992.0) + || number > std::floor(number) || number > 9007199254740992.0) { return std::nullopt; } @@ -16192,7 +16192,7 @@ namespace Progmasoft::Catch3::Runner } if (name == "version") { - if (!value.IsNumber() || value.AsNumber() != kConfigVersion) + if (WholeNumber(value) != kConfigVersion) { return Error{ prefix + "version " + value.ToString() diff --git a/extras/catch_amalgamated.hpp b/extras/catch_amalgamated.hpp index 07a42b88..09e99fb2 100644 --- a/extras/catch_amalgamated.hpp +++ b/extras/catch_amalgamated.hpp @@ -7,7 +7,7 @@ // SPDX-License-Identifier: BSL-1.0 // Catch3 v0.3.0, on the Catch2 v3.16.1 engine -// Generated: 2026-10-29 19:10:35.285105 +// Generated: 2026-10-29 19:30:41.164140 // ---------------------------------------------------------- // This file is an amalgamation of multiple different files. // You probably shouldn't edit it directly. diff --git a/src/Progmasoft/Runner/ProjectConfig.cpp b/src/Progmasoft/Runner/ProjectConfig.cpp index ea5d921f..ca1957d4 100644 --- a/src/Progmasoft/Runner/ProjectConfig.cpp +++ b/src/Progmasoft/Runner/ProjectConfig.cpp @@ -16,7 +16,7 @@ namespace Progmasoft::Catch3::Runner namespace { /// The version of the file format this runner reads. - constexpr double kConfigVersion = 1; + constexpr std::uint64_t kConfigVersion = 1; /// What the value of a key is, and how it becomes arguments. enum class ValueKind : std::uint8_t @@ -175,7 +175,7 @@ namespace Progmasoft::Catch3::Runner } const double number = value.AsNumber(); if (!std::isfinite(number) || number < 0 - || number != std::floor(number) || number > 9007199254740992.0) + || number > std::floor(number) || number > 9007199254740992.0) { return std::nullopt; } @@ -434,7 +434,7 @@ namespace Progmasoft::Catch3::Runner } if (name == "version") { - if (!value.IsNumber() || value.AsNumber() != kConfigVersion) + if (WholeNumber(value) != kConfigVersion) { return Error{ prefix + "version " + value.ToString() diff --git a/tests/Progmasoft/RunnerConfig.tests.cpp b/tests/Progmasoft/RunnerConfig.tests.cpp index 4dce1f79..3dba3e0b 100644 --- a/tests/Progmasoft/RunnerConfig.tests.cpp +++ b/tests/Progmasoft/RunnerConfig.tests.cpp @@ -4,6 +4,7 @@ // catch3.json: where it is found, what its keys set, how the command line // wins over it and how a wrong file is explained. +#include <Progmasoft/Catch3/Matchers/FloatingPoint.hpp> #include <Progmasoft/Catch3/Matchers/String.hpp> #include <Progmasoft/Catch3/TestMacros.hpp> #include <Progmasoft/Runner/Files.hpp> @@ -21,6 +22,7 @@ namespace namespace Runner = Progmasoft::Catch3::Runner; namespace fs = std::filesystem; using Catch::Matchers::ContainsSubstring; + using Catch::Matchers::WithinAbs; using std::chrono::milliseconds; /// A directory of its own under the system's temporary directory, @@ -221,7 +223,7 @@ TEST_CASE("Keys set the option of the same name", CHECK(options.skipBenchmarks); CHECK(options.benchmarkSamples == 10); CHECK(options.benchmarkResamples == 1000); - CHECK(options.benchmarkConfidenceInterval == 0.9); + CHECK_THAT(options.benchmarkConfidenceInterval, WithinAbs(0.9, 1e-12)); CHECK(options.benchmarkNoAnalysis); CHECK(options.benchmarkWarmupTime == milliseconds{ 5 }); CHECK(options.quarantine == Runner::QuarantineMode::kReport);