Improved readability of testsuite output when ASSERT_EQUALS_MSG fails.

Fixed another true positive in checkbufferoverrun.cpp
AStyle
This commit is contained in:
PKEuS 2014-03-27 16:06:30 +01:00
parent e8c7a723f5
commit 9b307cf8e0
3 changed files with 15 additions and 14 deletions

View File

@ -1423,7 +1423,7 @@ bool CheckBufferOverrun::isArrayOfStruct(const Token* tok, int &position)
void CheckBufferOverrun::checkReadlinkBufferUsage(const Token* ftok, const Token *scope_begin, const unsigned int varid, const MathLib::bigint total_size) void CheckBufferOverrun::checkReadlinkBufferUsage(const Token* ftok, const Token *scope_begin, const unsigned int varid, const MathLib::bigint total_size)
{ {
const std::string funcname = ftok->str(); const std::string& funcname = ftok->str();
const Token* bufParam = ftok->tokAt(2)->nextArgument(); const Token* bufParam = ftok->tokAt(2)->nextArgument();
if (funcname == "readlinkat") if (funcname == "readlinkat")

View File

@ -135,15 +135,17 @@ void TestFixture::assertEquals(const char *filename, unsigned int linenr, const
<< writestr(actual, true) << writestr(actual, true)
<< '.' << '.'
<< std::endl; << std::endl;
if (!msg.empty())
errmsg << msg << std::endl;
} else { } else {
errmsg << "Assertion failed in " << filename << " at line " << linenr << std::endl errmsg << "Assertion failed in " << filename << " at line " << linenr << std::endl
<< "Expected:" << std::endl << "Expected:" << std::endl
<< writestr(expected) << std::endl << writestr(expected) << std::endl
<< "Actual:" << std::endl << "Actual:" << std::endl
<< writestr(actual) << std::endl << "_____" << std::endl; << writestr(actual) << std::endl;
} if (!msg.empty())
if (!msg.empty()) { errmsg << "Hint:" << std::endl << msg << std::endl;
errmsg << msg << std::endl; errmsg << "_____" << std::endl;
} }
} }
} }

View File

@ -894,8 +894,7 @@ private:
try { try {
tokenizeAndStringify(code); tokenizeAndStringify(code);
assertThrowFail(__FILE__, __LINE__); assertThrowFail(__FILE__, __LINE__);
} } catch (InternalError& e) {
catch (InternalError& e) {
ASSERT_EQUALS("Analysis failed. If the code is valid then please report this failure.", e.errorMessage); ASSERT_EQUALS("Analysis failed. If the code is valid then please report this failure.", e.errorMessage);
ASSERT_EQUALS("cppcheckError", e.id); ASSERT_EQUALS("cppcheckError", e.id);
ASSERT_EQUALS(5, e.token->linenr()); ASSERT_EQUALS(5, e.token->linenr());