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; }