From 396d39c35b98b79b306d44a12691df3fd9a2bb78 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Thu, 1 Sep 2022 17:18:02 +0200 Subject: [PATCH] test: `AlmostEqualsMatcher` compilation fixed --- test/unit_test/runtime/almost_equals.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/test/unit_test/runtime/almost_equals.h b/test/unit_test/runtime/almost_equals.h index f8362143..955edfd8 100644 --- a/test/unit_test/runtime/almost_equals.h +++ b/test/unit_test/runtime/almost_equals.h @@ -30,15 +30,16 @@ template struct AlmostEqualsMatcher : Catch::Matchers::MatcherGenericBase { AlmostEqualsMatcher(const T& target) : target_{target} {} - template - requires std::three_way_comparable_with && std::same_as && - treat_as_floating_point bool + template U> + requires std::same_as && treat_as_floating_point bool match(const U& other) const { + using std::abs; using common = std::common_type_t; - auto maxTUOne = - std::max({typename T::rep(1), std::abs(common(target_).number()), std::abs(common(other).number())}); - return abs(target_ - other).number() <= std::numeric_limits::epsilon() * maxTUOne; + const auto x = common(target_).number(); + const auto y = common(other).number(); + const auto maxXYOne = std::max({typename T::rep{1}, abs(x), abs(y)}); + return abs(x - y) <= std::numeric_limits::epsilon() * maxXYOne; } std::string describe() const override { return "almost equals: " + STD_FMT::format("{}", target_); }