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

Enabled previous commit under MSVC, introduced new feature toggle

Commit
60a9ac7e65a57d82a92eebb7c8c6c1111a75897e
Author
Martin Hořeňovský ·
Parents
c06afe438e26

Files · Download .tar.gz

Changes

 docs/configuration.md                          | 1 +
 include/internal/catch_approx.hpp              | 4 ++--
 include/internal/catch_compiler_capabilities.h | 9 +++++++++
 projects/SelfTest/ApproxTests.cpp              | 6 +++++-
 4 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/docs/configuration.md b/docs/configuration.md
index f2b7104e..ea57e789 100644
--- a/docs/configuration.md
+++ b/docs/configuration.md
@@ -62,6 +62,7 @@ This can be useful on certain platforms that do not provide ```std::cout``` and
 	CATCH_CONFIG_CPP11_OVERRIDE				// CATCH_OVERRIDE expands to override (for virtual function implementations)
 	CATCH_CONFIG_CPP11_UNIQUE_PTR			// Use std::unique_ptr instead of std::auto_ptr
     CATCH_CONFIG_CPP11_SHUFFLE              // Use std::shuffle instead of std::random_shuffle
+    CATCH_CONFIG_CPP11_TYPE_TRAITS          // Use std::enable_if and <type_traits>
 
 Catch has some basic compiler detection that will attempt to select the appropriate mix of these macros. However being incomplete - and often without access to the respective compilers - this detection tends to be conservative.
 So overriding control is given to the user. If a compiler supports a feature (and Catch does not already detect it) then one or more of these may be defined to enable it (or suppress it, in some cases). If you do do this please raise an issue, specifying your compiler version (ideally with an idea of how to detect it) and stating that it has such support.
diff --git a/include/internal/catch_approx.hpp b/include/internal/catch_approx.hpp
index 87d40fe9..f1937427 100644
--- a/include/internal/catch_approx.hpp
+++ b/include/internal/catch_approx.hpp
@@ -13,7 +13,7 @@
 #include <cmath>
 #include <limits>
 
-#if defined(CATCH_CPP11_OR_GREATER)
+#if defined(CATCH_CONFIG_CPP11_TYPE_TRAITS)
 #include <type_traits>
 #endif
 
@@ -45,7 +45,7 @@ namespace Detail {
             return approx;
         }
 
-#if defined(CATCH_CPP11_OR_GREATER)
+#if defined(CATCH_CONFIG_CPP11_TYPE_TRAITS)
         template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>
         friend bool operator == ( const T& lhs, Approx const& rhs ) {
             // Thanks to Richard Harris for his help refining this formula
diff --git a/include/internal/catch_compiler_capabilities.h b/include/internal/catch_compiler_capabilities.h
index f3dfdf81..2b947fbd 100644
--- a/include/internal/catch_compiler_capabilities.h
+++ b/include/internal/catch_compiler_capabilities.h
@@ -19,6 +19,8 @@
 // CATCH_CONFIG_CPP11_LONG_LONG : is long long supported?
 // CATCH_CONFIG_CPP11_OVERRIDE : is override supported?
 // CATCH_CONFIG_CPP11_UNIQUE_PTR : is unique_ptr supported (otherwise use auto_ptr)
+// CATCH_CONFIG_CPP11_SHUFFLE : is std::shuffle supported?
+// CATCH_CONFIG_CPP11_TYPE_TRAITS : are type_traits and enable_if supported?
 
 // CATCH_CONFIG_CPP11_OR_GREATER : Is C++11 supported?
 
@@ -116,6 +118,7 @@
 #define CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT
 #define CATCH_INTERNAL_CONFIG_CPP11_GENERATED_METHODS
 #define CATCH_INTERNAL_CONFIG_CPP11_SHUFFLE
+#define CATCH_INTERNAL_CONFIG_CPP11_TYPE_TRAITS
 #endif
 
 #endif // _MSC_VER
@@ -184,6 +187,9 @@
 # if !defined(CATCH_INTERNAL_CONFIG_CPP11_SHUFFLE)
 #   define CATCH_INTERNAL_CONFIG_CPP11_SHUFFLE
 #  endif
+# if !defined(CATCH_INTERNAL_CONFIG_CPP11_TYPE_TRAITS)
+#  define CATCH_INTERNAL_CONFIG_CPP11_TYPE_TRAITS
+# endif
 
 #endif // __cplusplus >= 201103L
 
@@ -224,6 +230,9 @@
 #if defined(CATCH_INTERNAL_CONFIG_CPP11_SHUFFLE) && !defined(CATCH_CONFIG_CPP11_NO_SHUFFLE) && !defined(CATCH_CONFIG_CPP11_SHUFFLE) && !defined(CATCH_CONFIG_NO_CPP11)
 #   define CATCH_CONFIG_CPP11_SHUFFLE
 #endif
+# if defined(CATCH_INTERNAL_CONFIG_CPP11_TYPE_TRAITS) && !defined(CATCH_CONFIG_CPP11_NO_TYPE_TRAITS) && !defined(CATCH_CONFIG_CPP11_TYPE_TRAITS) && !defined(CATCH_CONFIG_NO_CPP11)
+#  define CATCH_CONFIG_CPP11_TYPE_TRAITS
+# endif
 
 #if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS)
 #   define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS
diff --git a/projects/SelfTest/ApproxTests.cpp b/projects/SelfTest/ApproxTests.cpp
index a16dd59f..8a12858c 100644
--- a/projects/SelfTest/ApproxTests.cpp
+++ b/projects/SelfTest/ApproxTests.cpp
@@ -143,7 +143,7 @@ TEST_CASE( "Approximate PI", "[Approx][PI]" )
 
 ////////////////////////////////////////////////////////////////////////////////
 
-#if defined(CATCH_CPP11_OR_GREATER)
+#if defined(CATCH_CONFIG_CPP11_TYPE_TRAITS)
 class StrongDoubleTypedef
 {
   double d_ = 0.0;
@@ -153,6 +153,10 @@ class StrongDoubleTypedef
     explicit operator double() const { return d_; }
 };
 
+inline std::ostream& operator<<( std::ostream& os, StrongDoubleTypedef td ) {
+    return os << "StrongDoubleTypedef(" << static_cast<double>(td) << ")";
+}
+
 TEST_CASE
 (
  "Comparison with explicitly convertible types",