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

Build 35

- non-SFINAE IsStreamInsertable
Commit
dd52044374ef7e91eea9a7add4e9a4564a9a9196
Author
Phil Nash ·
Parents
9fff9e47d344

Files · Download .tar.gz

Changes

 README.md                                       |  2 +-
 include/internal/catch_version.hpp              |  2 +-
 projects/SelfTest/Baselines/approvedResults.txt | 44 ++++++++++---
 single_include/catch.hpp                        | 88 ++++++++++++-------------
 4 files changed, 80 insertions(+), 56 deletions(-)

diff --git a/README.md b/README.md
index 1194a86c..5a0a5563 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
 ![catch logo](https://raw.github.com/philsquared/Catch/Integration/catch-logo-small.png)
 
-## CATCH v0.9 build 34 (integration branch)
+## CATCH v0.9 build 35 (integration branch)
 An automated test framework for C, C++ and Objective-C.
 
 This branch may contain code that is experimental or not yet fully tested.
diff --git a/include/internal/catch_version.hpp b/include/internal/catch_version.hpp
index 7332935a..5c5f4ccd 100644
--- a/include/internal/catch_version.hpp
+++ b/include/internal/catch_version.hpp
@@ -13,7 +13,7 @@
 namespace Catch {
 
     // These numbers are maintained by a script
-    Version libraryVersion( 0, 9, 34, "integration" );
+    Version libraryVersion( 0, 9, 35, "integration" );
 }
 
 #endif // TWOBLUECUBES_CATCH_VERSION_HPP_INCLUDED
diff --git a/projects/SelfTest/Baselines/approvedResults.txt b/projects/SelfTest/Baselines/approvedResults.txt
index 2a98c58d..30599ef3 100644
--- a/projects/SelfTest/Baselines/approvedResults.txt
+++ b/projects/SelfTest/Baselines/approvedResults.txt
@@ -1,6 +1,6 @@
 
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-CatchSelfTest is a CATCH v0.9 b34 (integration) host application.
+CatchSelfTest is a CATCH v0.9 b35 (integration) host application.
 Run with -? for options
 
 -------------------------------------------------------------------------------
@@ -5263,6 +5263,18 @@ PASSED:
 with expansion:
   true
 
+-------------------------------------------------------------------------------
+non streamable - with conv. op
+-------------------------------------------------------------------------------
+TrickyTests.cpp:345
+...............................................................................
+
+TrickyTests.cpp:349:
+PASSED:
+  REQUIRE( s == "7" )
+with expansion:
+  "7" == "7"
+
 -------------------------------------------------------------------------------
 Anonymous test case 1
 -------------------------------------------------------------------------------
@@ -5519,11 +5531,11 @@ with message:
   boo!
 
 ===============================================================================
-111 test cases - 49 failed (705 assertions - 106 failed)
+112 test cases - 49 failed (706 assertions - 106 failed)
 
 
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-CatchSelfTest is a CATCH v0.9 b34 (integration) host application.
+CatchSelfTest is a CATCH v0.9 b35 (integration) host application.
 Run with -? for options
 
 -------------------------------------------------------------------------------
@@ -5840,7 +5852,7 @@ with expansion:
 13 test cases - 3 failed (40 assertions - 4 failed)
 
 <testsuites>
-  <testsuite name="~dummy" errors="10" failures="78" tests="705" hostname="tbd" time="tbd" timestamp="tbd">
+  <testsuite name="~dummy" errors="10" failures="78" tests="706" hostname="tbd" time="tbd" timestamp="tbd">
     <testcase classname="global" name="./succeeding/Approx/simple" time="tbd"/>
     <testcase classname="global" name="./succeeding/Approx/epsilon" time="tbd"/>
     <testcase classname="global" name="./succeeding/Approx/float" time="tbd"/>
@@ -6339,6 +6351,7 @@ TrickyTests.cpp:106
     <testcase classname="global" name="./succeeding/unimplemented static bool" time="tbd"/>
     <testcase classname="global" name="./succeeding/SafeBool" time="tbd"/>
     <testcase classname="global" name="Assertions then sections" time="tbd"/>
+    <testcase classname="global" name="non streamable - with conv. op" time="tbd"/>
     <testcase classname="global" name="Anonymous test case 1" time="tbd"/>
     <testcase classname="global" name="Test case with one argument" time="tbd"/>
     <testcase classname="global" name="Variadic macros" time="tbd"/>
@@ -12023,6 +12036,17 @@ TrickyTests.cpp" line="335">
       </Section>
       <OverallResult success="true"/>
     </TestCase>
+    <TestCase name="non streamable - with conv. op">
+TrickyTests.cpp" line="349">
+        <Original>
+          s == &quot;7&quot;
+        </Original>
+        <Expanded>
+          &quot;7&quot; == &quot;7&quot;
+        </Expanded>
+      </Expression>
+      <OverallResult success="true"/>
+    </TestCase>
     <TestCase name="Anonymous test case 1">
       <OverallResult success="true"/>
     </TestCase>
@@ -12252,9 +12276,9 @@ BDDTests.cpp" line="54">
       </Section>
       <OverallResult success="true"/>
     </TestCase>
-    <OverallResults successes="599" failures="106"/>
+    <OverallResults successes="600" failures="106"/>
   </Group>
-  <OverallResults successes="599" failures="106"/>
+  <OverallResults successes="600" failures="106"/>
 </Catch>
 [Started testing: CatchSelfTest]
 [Started group: '~dummy']
@@ -13980,6 +14004,10 @@ TrickyTests.cpp:335: Catch::isTrue( true ) succeeded for: true
 
 [Finished: 'Assertions then sections' All tests passed (6 assertions in 1 test case)]
 
+[Running: non streamable - with conv. op]
+TrickyTests.cpp:349: s == "7" succeeded for: "7" == "7"
+[Finished: 'non streamable - with conv. op' All tests passed (1 assertion in 1 test case)]
+
 [Running: Anonymous test case 1]
 VariadicMacrosTests.cpp:14:  succeeded
 [with message: anonymous test case]
@@ -14091,10 +14119,10 @@ BDDTests.cpp:67:  succeeded
 [End of section: '   Given: A section name that is so long that it cannot fit in a single console width' 1 assertion passed]
 
 [Finished: 'Scenario: This is a really long scenario name to see how the list command deals with wrapping' All tests passed (1 assertion in 1 test case)]
-[End of group: '~dummy'. 49 of 111 test cases failed (106 of 705 assertions failed)]
+[End of group: '~dummy'. 49 of 112 test cases failed (106 of 706 assertions failed)]
 
 
-[Testing completed. 49 of 111 test cases failed (106 of 705 assertions failed)]
+[Testing completed. 49 of 112 test cases failed (106 of 706 assertions failed)]
 
 [Started testing: CatchSelfTest]
 [Started group: '~dummy']
diff --git a/single_include/catch.hpp b/single_include/catch.hpp
index dd7d6e9e..d53a8600 100644
--- a/single_include/catch.hpp
+++ b/single_include/catch.hpp
@@ -1,6 +1,6 @@
 /*
- *  CATCH v0.9 build 34 (integration branch)
- *  Generated: 2013-04-20 21:05:02.595019
+ *  CATCH v0.9 build 35 (integration branch)
+ *  Generated: 2013-04-20 23:19:15.811241
  *  ----------------------------------------------------------
  *  This file has been merged from multiple headers. Please don't edit it directly
  *  Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
@@ -555,7 +555,7 @@ private:
 
 #elif __GNUC__ >= 3
 
-#define CATCH_SFINAE
+// #define CATCH_SFINAE // Taking this out completely for now
 
 #endif // __GNUC__ < 3
 
@@ -572,8 +572,6 @@ private:
 #endif // _MSC_VER
 
 
-#ifdef CATCH_SFINAE
-
 namespace Catch {
 
     struct TrueType {
@@ -587,6 +585,8 @@ namespace Catch {
         char sizer[2];
     };
 
+#ifdef CATCH_SFINAE
+
     template<bool> struct NotABooleanExpression;
 
     template<bool c> struct If : NotABooleanExpression<c> {};
@@ -597,10 +597,10 @@ namespace Catch {
     template<> struct SizedIf<sizeof(TrueType)> : TrueType {};
     template<> struct SizedIf<sizeof(FalseType)> : FalseType {};
 
-} // end namespace Catch
-
 #endif // CATCH_SFINAE
 
+} // end namespace Catch
+
 #include <sstream>
 #include <iomanip>
 #include <limits>
@@ -652,11 +652,13 @@ inline id performOptionalSelector( id obj, SEL sel ) {
 #endif
 
 namespace Catch {
+namespace Detail {
 
+// 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_SFINAE
 #ifdef CATCH_SFINAE
 
-namespace Detail {
-
     template<typename T>
     class IsStreamInsertableHelper {
         template<int N> struct TrueIfSizeable : TrueType {};
@@ -672,53 +674,47 @@ namespace Detail {
     template<typename T>
     struct IsStreamInsertable : IsStreamInsertableHelper<T>::type {};
 
-    template<typename T>
-    void toStream( std::ostream& os, T const& value, typename IsStreamInsertable<T>::Enable* = 0 ) {
-        os << value;
-    }
+#else
 
-    template<typename T>
-    void toStream( std::ostream& os, T const&, typename IsStreamInsertable<T>::Disable* = 0 ) {
-        os << "{?}";
-    }
+    struct BorgType {
+        template<typename T> BorgType( T const& );
+    };
 
-}
+    TrueType& testStreamable( std::ostream& );
+    FalseType testStreamable( FalseType );
 
-template<typename T>
-struct StringMaker {
-    static std::string convert( T const& value ) {
-        std::ostringstream oss;
-        Detail::toStream( oss, value );
-        return oss.str();
-    }
-};
+    FalseType operator<<( std::ostream const&, BorgType const& );
 
-#else
+    template<typename T>
+    struct IsStreamInsertable {
+        static std::ostream &s;
+        static T const &t;
+        enum { value = sizeof( testStreamable(s << t) ) == sizeof( TrueType ) };
+    };
 
-namespace Detail {
+#endif
 
-    struct NonStreamable {
-        template<typename T> NonStreamable( const T& ){}
+    template<bool C>
+    struct StringMakerBase {
+        template<typename T>
+        static std::string convert( T const& ) { return "{?}"; }
     };
 
-} // end namespace Detail
+    template<>
+    struct StringMakerBase<true> {
+        template<typename T>
+        static std::string convert( T const& _value ) {
+            std::ostringstream oss;
+            oss << _value;
+            return oss.str();
+        }
+    };
 
-// If the type does not have its own << overload for ostream then
-// this one will be used instead
-inline std::ostream& operator << ( std::ostream& ss, Detail::NonStreamable ){
-    return ss << "{?}";
-}
+} // end namespace Detail
 
 template<typename T>
-struct StringMaker {
-    static std::string convert( T const& value ) {
-        std::ostringstream oss;
-        oss << value;
-        return oss.str();
-    }
-};
-
-#endif
+struct StringMaker :
+    Detail::StringMakerBase<Detail::IsStreamInsertable<T>::value> {};
 
 template<typename T>
 struct StringMaker<T*> {
@@ -6159,7 +6155,7 @@ namespace Catch {
 namespace Catch {
 
     // These numbers are maintained by a script
-    Version libraryVersion( 0, 9, 34, "integration" );
+    Version libraryVersion( 0, 9, 35, "integration" );
 }
 
 // #included from: catch_text.hpp