Progmasoft Git

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

Moved Approx into its own namespace to avoid ADL issues with operator ==

Commit
01db6c4471b555f475a88a2cca75cf35da43da63
Author
Phil Nash ·
Parents
3c08431c9289

Files · Download .tar.gz

Changes

 catch.hpp                  |  2 +-
 internal/catch_capture.hpp | 82 ++++++++++++++++++++++++----------------------
 2 files changed, 43 insertions(+), 41 deletions(-)

diff --git a/catch.hpp b/catch.hpp
index c1285940..0a241b09 100644
--- a/catch.hpp
+++ b/catch.hpp
@@ -66,6 +66,6 @@
 // Still to be implemented
 #define CHECK_NOFAIL( expr ) // !TBD - reports violation, but doesn't fail Test
 
-using Catch::Approx;
+using Catch::Detail::Approx;
 
 #endif // TWOBLUECUBES_CATCH_HPP_INCLUDED
diff --git a/internal/catch_capture.hpp b/internal/catch_capture.hpp
index 94eb2d01..539129d6 100644
--- a/internal/catch_capture.hpp
+++ b/internal/catch_capture.hpp
@@ -591,53 +591,55 @@ inline double catch_max( double x, double y )
 {
     return x > y ? x : y;
 }
-    
-class Approx
+namespace Detail
 {
-public:
-    ///////////////////////////////////////////////////////////////////////////
-    // !TBD more generic
-    explicit Approx
-    (
-        double d
-    )
-    : m_d( d )
+    class Approx
     {
-    }
+    public:
+        ///////////////////////////////////////////////////////////////////////////
+        // !TBD more generic
+        explicit Approx
+        (
+            double d
+        )
+        : m_d( d )
+        {
+        }
 
-    ///////////////////////////////////////////////////////////////////////////
-    template<typename T>
-    friend bool operator == 
-    (
-        const T& lhs, 
-        const Approx& rhs
-    )
-    {
-        // !TBD Use proper tolerance
-        // From: http://realtimecollisiondetection.net/blog/?p=89
-        // see also: http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm
-        return fabs( lhs - rhs.m_d ) <= catch_max( CATCH_absTol, CATCH_relTol * catch_max( fabs(lhs), fabs(rhs.m_d) ) );
-    }
-    
-    ///////////////////////////////////////////////////////////////////////////
-    template<typename T>
-    friend bool operator != 
-    (
-        const T& lhs, 
-        const Approx& rhs
-    )
-    {
-        return ! operator==( lhs, rhs );
-    }
+        ///////////////////////////////////////////////////////////////////////////
+        template<typename T>
+        friend bool operator == 
+        (
+            const T& lhs, 
+            const Approx& rhs
+        )
+        {
+            // !TBD Use proper tolerance
+            // From: http://realtimecollisiondetection.net/blog/?p=89
+            // see also: http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm
+            return fabs( lhs - rhs.m_d ) <= catch_max( CATCH_absTol, CATCH_relTol * catch_max( fabs(lhs), fabs(rhs.m_d) ) );
+        }
+        
+        ///////////////////////////////////////////////////////////////////////////
+        template<typename T>
+        friend bool operator != 
+        (
+            const T& lhs, 
+            const Approx& rhs
+        )
+        {
+            return ! operator==( lhs, rhs );
+        }
+        
+        double m_d;
+    };
+}
     
-    double m_d;
-};
-
 ///////////////////////////////////////////////////////////////////////////////
 template<>
-inline std::string toString<Approx>
+    inline std::string toString<Detail::Approx>
 (
-    const Approx& value
+    const Detail::Approx& value
 )
 {
     std::ostringstream oss;