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)
{
const std::string funcname = ftok->str();
const std::string& funcname = ftok->str();
const Token* bufParam = ftok->tokAt(2)->nextArgument();
if (funcname == "readlinkat")

View File

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

View File

@ -891,15 +891,14 @@ private:
" )\n"
"}";
try {
tokenizeAndStringify(code);
assertThrowFail(__FILE__, __LINE__);
}
catch (InternalError& e) {
ASSERT_EQUALS("Analysis failed. If the code is valid then please report this failure.", e.errorMessage);
ASSERT_EQUALS("cppcheckError", e.id);
ASSERT_EQUALS(5, e.token->linenr());
}
try {
tokenizeAndStringify(code);
assertThrowFail(__FILE__, __LINE__);
} catch (InternalError& e) {
ASSERT_EQUALS("Analysis failed. If the code is valid then please report this failure.", e.errorMessage);
ASSERT_EQUALS("cppcheckError", e.id);
ASSERT_EQUALS(5, e.token->linenr());
}
}
void wrong_syntax4() { // #3618