From 5121b5b05886c3667fa8ba738b2f55d138d35490 Mon Sep 17 00:00:00 2001 From: Eric Schmidt Date: Wed, 20 Apr 2016 21:52:20 -0600 Subject: [PATCH] Put quote marks around printed characters; also nicely print some escapes --- include/internal/catch_tostring.hpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/include/internal/catch_tostring.hpp b/include/internal/catch_tostring.hpp index 9d11bbb2..1b26358b 100644 --- a/include/internal/catch_tostring.hpp +++ b/include/internal/catch_tostring.hpp @@ -146,9 +146,19 @@ std::string toString( bool value ) { } std::string toString( char value ) { - return value < ' ' - ? toString( static_cast( value ) ) - : Detail::makeString( value ); + if ( value == '\r' ) + return "'\\r'"; + if ( value == '\l' ) + return "'\\l'"; + if ( value == '\n' ) + return "'\\n'"; + if ( value == '\t' ) + return "'\\t'"; + if ( '\0' <= value && value < ' ' ) + return toString( static_cast( value ) ); + char chstr[] = "' '"; + chstr[1] = value; + return chstr; } std::string toString( signed char value ) {