From 597fca3c8971500fe541417c7434e85d9a41b8c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Thu, 17 Aug 2017 15:34:00 +0200 Subject: [PATCH] Remove header from the common path It was only used for std::max within Approx, so we now have ::Catch::Detail::max(double, double) that is used instead. --- include/internal/catch_approx.cpp | 7 +++++++ include/internal/catch_approx.hpp | 5 +++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/include/internal/catch_approx.cpp b/include/internal/catch_approx.cpp index 98fc7bce..419a9cd6 100644 --- a/include/internal/catch_approx.cpp +++ b/include/internal/catch_approx.cpp @@ -13,6 +13,13 @@ namespace Catch { namespace Detail { + double max(double lhs, double rhs) { + if (lhs < rhs) { + return rhs; + } + return lhs; + } + Approx::Approx ( double value ) : m_epsilon( std::numeric_limits::epsilon()*100 ), m_margin( 0.0 ), diff --git a/include/internal/catch_approx.hpp b/include/internal/catch_approx.hpp index 590c8f5b..2185b8f6 100644 --- a/include/internal/catch_approx.hpp +++ b/include/internal/catch_approx.hpp @@ -10,7 +10,6 @@ #include "catch_tostring.h" -#include #include #include @@ -18,6 +17,8 @@ namespace Catch { namespace Detail { + double max(double lhs, double rhs); + class Approx { public: explicit Approx ( double value ); @@ -42,7 +43,7 @@ namespace Detail { friend bool operator == ( const T& lhs, Approx const& rhs ) { // Thanks to Richard Harris for his help refining this formula auto lhs_v = static_cast(lhs); - bool relativeOK = std::fabs(lhs_v - rhs.m_value) < rhs.m_epsilon * (rhs.m_scale + (std::max)(std::fabs(lhs_v), std::fabs(rhs.m_value))); + bool relativeOK = std::fabs(lhs_v - rhs.m_value) < rhs.m_epsilon * (rhs.m_scale + (max)(std::fabs(lhs_v), std::fabs(rhs.m_value))); if (relativeOK) { return true; }