Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLeitwolf112026-10-29 19:30:46 +0300
committerLeitwolf112026-10-29 19:30:46 +0300
commit0b4b57a0688f2943f4c797c20d68d533cf70fd15 (patch)
tree3af5223ff664544d15eaf20a10eccdf3465d9958
parentf41a9c3c01b4df1100e24a63987716cb4dbf28f2 (diff)
downloadcatch3-feature/catch3-json.tar.gz
Compare whole numbers in catch3.json without floating-point equalityfeature/catch3-json
Clang's -Wfloat-equal, an error in the development builds, rejected the version check, which compared the JSON number with 1.0 by ==. The version is now read through the same whole-number check as the counts and compared as an integer, and that check asks whether the number exceeds its floor instead of comparing the two for equality. The test of the confidence interval compares within 1e-12. The amalgamated source is regenerated.
-rw-r--r--extras/catch_amalgamated.cpp8
-rw-r--r--extras/catch_amalgamated.hpp2
-rw-r--r--src/Progmasoft/Runner/ProjectConfig.cpp6
-rw-r--r--tests/Progmasoft/RunnerConfig.tests.cpp4
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);