diff --git a/testsuite.cpp b/testsuite.cpp index b37532c78..06e096b59 100644 --- a/testsuite.cpp +++ b/testsuite.cpp @@ -76,6 +76,26 @@ bool TestFixture::runTest(const char testname[]) std::cout << classname << "::" << testname << "\n"; return true; } + +static std::string writestr( const std::string &str ) +{ + std::ostringstream ostr; + ostr << "\""; + for (unsigned int i = 0; i < str.length(); ++i) + { + char ch = str[i]; + if ( ch == '\n' ) + ostr << "\\n"; + else if ( ch == '\t' ) + ostr << "\\t"; + else if ( ch == '\"' ) + ostr << "\\\""; + else + ostr << std::string(1, ch); + } + ostr << "\""; + return ostr.str(); +} void TestFixture::assertEquals(const char *filename, int linenr, const std::string &expected, const std::string &actual) { @@ -83,9 +103,9 @@ void TestFixture::assertEquals(const char *filename, int linenr, const std::stri { errmsg << "Assertion failed in " << filename << " at line " << linenr << std::endl << "Expected:" << std::endl - << expected << std::endl + << writestr(expected) << std::endl << "Actual:" << std::endl - << actual << std::endl; + << writestr(actual) << std::endl; } }