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

Factored out mention of "unprintable string" ("{?}")

Commit
ea33961b4362ba9cee6e060e4ec9b94da366e960
Author
Phil Nash ·
Parents
3e1d3c72712d

Files · Download .tar.gz

Changes

 include/internal/catch_capture.hpp  |  2 +-
 include/internal/catch_tostring.h   | 23 +++++++++++++++--------
 include/internal/catch_tostring.hpp |  2 ++
 3 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/include/internal/catch_capture.hpp b/include/internal/catch_capture.hpp
index 1285b31f..39e5fc87 100644
--- a/include/internal/catch_capture.hpp
+++ b/include/internal/catch_capture.hpp
@@ -134,7 +134,7 @@
             std::string matcherAsString = ::Catch::Matchers::matcher.toString(); \
             __catchResult \
                 .setLhs( Catch::toString( arg ) ) \
-                .setRhs( matcherAsString == "{?}" ? #matcher : matcherAsString ) \
+                .setRhs( matcherAsString == Catch::Detail::unprintableString ? #matcher : matcherAsString ) \
                 .setOp( "matches" ) \
                 .setResultType( ::Catch::Matchers::matcher.match( arg ) ); \
             __catchResult.captureExpression(); \
diff --git a/include/internal/catch_tostring.h b/include/internal/catch_tostring.h
index dbb31423..674533ff 100644
--- a/include/internal/catch_tostring.h
+++ b/include/internal/catch_tostring.h
@@ -29,6 +29,8 @@ std::string toString( T const& value );
 
 namespace Detail {
 
+    extern std::string unprintableString;
+
 // SFINAE is currently disabled by default for all compilers.
 // If the non SFINAE version of IsStreamInsertable is ambiguous for you
 // and your compiler supports SFINAE, try #defining CATCH_CONFIG_SFINAE
@@ -71,11 +73,11 @@ namespace Detail {
 
 #if defined(CATCH_CPP11_OR_GREATER)
     template<typename T,
-             bool IsEmum = std::is_enum<T>::value
+             bool IsEnum = std::is_enum<T>::value
              >
     struct EnumStringMaker
     {
-        static std::string convert( T const& ) { return "{?}"; }
+        static std::string convert( T const& ) { return unprintableString; }
     };
 
     template<typename T>
@@ -99,7 +101,7 @@ namespace Detail {
         }
 #else
         template<typename T>
-        static std::string convert( T const& ) { return "{?}"; }
+        static std::string convert( T const& ) { return unprintableString; }
 #endif
     };
 
@@ -152,12 +154,17 @@ namespace Detail {
     std::string rangeToString( InputIterator first, InputIterator last );
 }
 
+//template<typename T, typename Allocator>
+//struct StringMaker<std::vector<T, Allocator> > {
+//    static std::string convert( std::vector<T,Allocator> const& v ) {
+//        return Detail::rangeToString( v.begin(), v.end() );
+//    }
+//};
+
 template<typename T, typename Allocator>
-struct StringMaker<std::vector<T, Allocator> > {
-    static std::string convert( std::vector<T,Allocator> const& v ) {
-        return Detail::rangeToString( v.begin(), v.end() );
-    }
-};
+std::string toString( std::vector<T,Allocator> const& v ) {
+    return Detail::rangeToString( v.begin(), v.end() );
+}
 
 namespace Detail {
     template<typename T>
diff --git a/include/internal/catch_tostring.hpp b/include/internal/catch_tostring.hpp
index f9369f1e..9b234b18 100644
--- a/include/internal/catch_tostring.hpp
+++ b/include/internal/catch_tostring.hpp
@@ -15,6 +15,8 @@ namespace Catch {
 
 namespace Detail {
 
+    std::string unprintableString = "{?}";
+
     namespace {
         struct Endianness {
             enum Arch { Big, Little };