Fixed escape order and expression reporting

This commit is contained in:
Phil Nash 2014-12-19 19:24:41 +00:00
parent 7306eb3cfc
commit 3724463be7

View File

@ -23,10 +23,10 @@ namespace Catch {
static std::string escape( std::string const& str ) { static std::string escape( std::string const& str ) {
std::string escaped = str; std::string escaped = str;
replaceInPlace( escaped, "|", "||" );
replaceInPlace( escaped, "\'", "|\'" ); replaceInPlace( escaped, "\'", "|\'" );
replaceInPlace( escaped, "\n", "|n" ); replaceInPlace( escaped, "\n", "|n" );
replaceInPlace( escaped, "\r", "|r" ); replaceInPlace( escaped, "\r", "|r" );
replaceInPlace( escaped, "|", "||" );
replaceInPlace( escaped, "[", "|[" ); replaceInPlace( escaped, "[", "|[" );
replaceInPlace( escaped, "]", "|]" ); replaceInPlace( escaped, "]", "|]" );
return escaped; return escaped;
@ -66,12 +66,13 @@ namespace Catch {
if( !result.isOk() ) { if( !result.isOk() ) {
std::string message; std::string message;
std::string details;
switch( result.getResultType() ) { switch( result.getResultType() ) {
case ResultWas::ExpressionFailed: case ResultWas::ExpressionFailed:
message = "expression failed"; message = "expression failed";
break; break;
case ResultWas::ThrewException: case ResultWas::ThrewException:
message = "unexpected exception with message"; message = "unexpected exception";
break; break;
case ResultWas::FatalErrorCondition: case ResultWas::FatalErrorCondition:
message = "fatal error condition"; message = "fatal error condition";
@ -106,10 +107,12 @@ namespace Catch {
message += "\n" + it->message; message += "\n" + it->message;
std::string details = if( !result.hasExpression() ) {
" " + result.getExpressionInMacro() + "\n" + details =
"with expansion:\n" + " " + result.getExpressionInMacro() + "\n"
" " + result.getExpandedExpression() + "\n"; "with expansion:\n" +
" " + result.getExpandedExpression() + "\n";
}
// !TBD: file/ line // !TBD: file/ line