From d6f23a9a36cf008b870a2d7c51e422dc209d3241 Mon Sep 17 00:00:00 2001 From: Andy Sawyer Date: Sat, 21 Sep 2013 18:45:42 +0100 Subject: [PATCH] catch_tostring : moved defintion of rangeToString Detail::rangeToString is now defined after the various toString overloads. This results in them being accessible with rangeToString is instantiated (in this case, by StringMaker). This (sort-of) fixes the problem where contained types are toString'd incorrectly. Consider: std::vector v { "abc" }; Before: Catch::toString( v ) == "{ abc }" After: Catch::toString( v ) == "{ "abc" }" (note the extra pair of quotes around the "abc" - these are added by Catch::toString( std::string ) which is now called by rangeToString) --- include/internal/catch_tostring.hpp | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/include/internal/catch_tostring.hpp b/include/internal/catch_tostring.hpp index 48bc6830..d5714e8d 100644 --- a/include/internal/catch_tostring.hpp +++ b/include/internal/catch_tostring.hpp @@ -101,18 +101,7 @@ struct StringMaker { namespace Detail { template - std::string rangeToString( InputIterator first, InputIterator last ) { - std::ostringstream oss; - oss << "{ "; - if( first != last ) { - oss << toString( *first ); - for( ++first ; first != last ; ++first ) { - oss << ", " << toString( *first ); - } - } - oss << " }"; - return oss.str(); - } + std::string rangeToString( InputIterator first, InputIterator last ); } template @@ -238,6 +227,22 @@ inline std::string toString( std::nullptr_t ) { } #endif + namespace Detail { + template + std::string rangeToString( InputIterator first, InputIterator last ) { + std::ostringstream oss; + oss << "{ "; + if( first != last ) { + oss << toString( *first ); + for( ++first ; first != last ; ++first ) { + oss << ", " << toString( *first ); + } + } + oss << " }"; + return oss.str(); + } +} + } // end namespace Catch #endif // TWOBLUECUBES_CATCH_TOSTRING_HPP_INCLUDED