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

regenerated to include Approx changes

Commit
f721a96d245a255cde64cc70956cf2ca2831b757
Author
Phil Nash ·
Parents
2fa72a47cd4b

Files · Download .tar.gz

Changes

 single_include/catch.hpp | 46 ++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 38 insertions(+), 8 deletions(-)

diff --git a/single_include/catch.hpp b/single_include/catch.hpp
index 2b6c7aad..4b5d518b 100644
--- a/single_include/catch.hpp
+++ b/single_include/catch.hpp
@@ -2377,14 +2377,44 @@ namespace Catch
             ///////////////////////////////////////////////////////////////////////////
             explicit Approx
             (
-                double d
+                double value
             )
-            :   m_epsilon( std::numeric_limits<double>::epsilon() ),
+            :   m_epsilon( std::numeric_limits<float>::epsilon()*100 ),
                 m_scale( 1.0 ),
-                m_d( d )
+                m_value( value )
             {
             }
 
+            ///////////////////////////////////////////////////////////////////////////
+            Approx
+            (
+                const Approx& other
+            )
+            :   m_epsilon( other.m_epsilon ),
+                m_scale( other.m_scale ),
+                m_value( other.m_value )
+            {
+            }
+
+            ///////////////////////////////////////////////////////////////////////////
+            static Approx custom
+            ()
+            {
+                return Approx( 0 );
+            }
+
+            ///////////////////////////////////////////////////////////////////////////
+            Approx operator()
+            (
+                double value
+            )
+            {
+                Approx approx( value );
+                approx.epsilon( m_epsilon );
+                approx.scale( m_scale );
+                return approx;
+            }
+
             ///////////////////////////////////////////////////////////////////////////
             friend bool operator ==
             (
@@ -2393,7 +2423,7 @@ namespace Catch
             )
             {
                 // Thanks to Richard Harris for his help refining this formula
-                return fabs( lhs - rhs.m_d ) < rhs.m_epsilon * (rhs.m_scale + (std::max)( fabs(lhs), fabs(rhs.m_d) ) );
+                return fabs( lhs - rhs.m_value ) < rhs.m_epsilon * (rhs.m_scale + (std::max)( fabs(lhs), fabs(rhs.m_value) ) );
             }
 
             ///////////////////////////////////////////////////////////////////////////
@@ -2451,14 +2481,14 @@ namespace Catch
             std::string toString() const
             {
                 std::ostringstream oss;
-                oss << "Approx( " << m_d << ")";
+                oss << "Approx( " << m_value << ")";
                 return oss.str();
             }
 
         private:
             double m_epsilon;
             double m_scale;
-            double m_d;
+            double m_value;
         };
     }
 
@@ -4578,7 +4608,7 @@ namespace Catch
  */
 #define TWOBLUECUBES_CATCH_REPORTER_BASIC_HPP_INCLUDED
 
-// #included from: internal/catch_reporter_registrars.hpp
+// #included from: ../internal/catch_reporter_registrars.hpp
 
 /*
  *  catch_reporter_registrars.hpp
@@ -4979,7 +5009,7 @@ namespace Catch
  */
 #define TWOBLUECUBES_CATCH_REPORTER_XML_HPP_INCLUDED
 
-// #included from: internal/catch_xmlwriter.hpp
+// #included from: ../internal/catch_xmlwriter.hpp
 
 /*
  *  catch_xmlwriter.hpp