From dd52044374ef7e91eea9a7add4e9a4564a9a9196 Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Sat, 20 Apr 2013 23:20:05 +0100 Subject: [PATCH] Build 35 - non-SFINAE IsStreamInsertable --- README.md | 2 +- include/internal/catch_version.hpp | 2 +- .../SelfTest/Baselines/approvedResults.txt | 44 +++++++-- single_include/catch.hpp | 96 +++++++++---------- 4 files changed, 84 insertions(+), 60 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) - + @@ -6339,6 +6351,7 @@ TrickyTests.cpp:106 + @@ -12023,6 +12036,17 @@ TrickyTests.cpp" line="335"> + +TrickyTests.cpp" line="349"> + + s == "7" + + + "7" == "7" + + + + @@ -12252,9 +12276,9 @@ BDDTests.cpp" line="54"> - + - + [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 struct NotABooleanExpression; template struct If : NotABooleanExpression {}; @@ -597,10 +597,10 @@ namespace Catch { template<> struct SizedIf : TrueType {}; template<> struct SizedIf : FalseType {}; -} // end namespace Catch - #endif // CATCH_SFINAE +} // end namespace Catch + #include #include #include @@ -652,11 +652,13 @@ inline id performOptionalSelector( id obj, SEL sel ) { #endif namespace Catch { - -#ifdef CATCH_SFINAE - 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 + template class IsStreamInsertableHelper { template struct TrueIfSizeable : TrueType {}; @@ -672,53 +674,47 @@ namespace Detail { template struct IsStreamInsertable : IsStreamInsertableHelper::type {}; - template - void toStream( std::ostream& os, T const& value, typename IsStreamInsertable::Enable* = 0 ) { - os << value; - } - - template - void toStream( std::ostream& os, T const&, typename IsStreamInsertable::Disable* = 0 ) { - os << "{?}"; - } - -} - -template -struct StringMaker { - static std::string convert( T const& value ) { - std::ostringstream oss; - Detail::toStream( oss, value ); - return oss.str(); - } -}; - #else -namespace Detail { + struct BorgType { + template BorgType( T const& ); + }; - struct NonStreamable { - template NonStreamable( const T& ){} + TrueType& testStreamable( std::ostream& ); + FalseType testStreamable( FalseType ); + + FalseType operator<<( std::ostream const&, BorgType const& ); + + template + struct IsStreamInsertable { + static std::ostream &s; + static T const &t; + enum { value = sizeof( testStreamable(s << t) ) == sizeof( TrueType ) }; + }; + +#endif + + template + struct StringMakerBase { + template + static std::string convert( T const& ) { return "{?}"; } + }; + + template<> + struct StringMakerBase { + template + static std::string convert( T const& _value ) { + std::ostringstream oss; + oss << _value; + return oss.str(); + } }; } // end namespace Detail -// 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 << "{?}"; -} - template -struct StringMaker { - static std::string convert( T const& value ) { - std::ostringstream oss; - oss << value; - return oss.str(); - } -}; - -#endif +struct StringMaker : + Detail::StringMakerBase::value> {}; template struct StringMaker { @@ -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