Skip to content

Commit 9b307cf

Browse files
committed
Improved readability of testsuite output when ASSERT_EQUALS_MSG fails.
Fixed another true positive in checkbufferoverrun.cpp AStyle
1 parent e8c7a72 commit 9b307cf

3 files changed

Lines changed: 15 additions & 14 deletions

File tree

lib/checkbufferoverrun.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1423,7 +1423,7 @@ bool CheckBufferOverrun::isArrayOfStruct(const Token* tok, int &position)
14231423

14241424
void CheckBufferOverrun::checkReadlinkBufferUsage(const Token* ftok, const Token *scope_begin, const unsigned int varid, const MathLib::bigint total_size)
14251425
{
1426-
const std::string funcname = ftok->str();
1426+
const std::string& funcname = ftok->str();
14271427

14281428
const Token* bufParam = ftok->tokAt(2)->nextArgument();
14291429
if (funcname == "readlinkat")

test/testsuite.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,17 @@ void TestFixture::assertEquals(const char *filename, unsigned int linenr, const
135135
<< writestr(actual, true)
136136
<< '.'
137137
<< std::endl;
138+
if (!msg.empty())
139+
errmsg << msg << std::endl;
138140
} else {
139141
errmsg << "Assertion failed in " << filename << " at line " << linenr << std::endl
140142
<< "Expected:" << std::endl
141143
<< writestr(expected) << std::endl
142144
<< "Actual:" << std::endl
143-
<< writestr(actual) << std::endl << "_____" << std::endl;
144-
}
145-
if (!msg.empty()) {
146-
errmsg << msg << std::endl;
145+
<< writestr(actual) << std::endl;
146+
if (!msg.empty())
147+
errmsg << "Hint:" << std::endl << msg << std::endl;
148+
errmsg << "_____" << std::endl;
147149
}
148150
}
149151
}

test/testtokenize.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -891,15 +891,14 @@ class TestTokenizer : public TestFixture {
891891
" )\n"
892892
"}";
893893

894-
try {
895-
tokenizeAndStringify(code);
896-
assertThrowFail(__FILE__, __LINE__);
897-
}
898-
catch (InternalError& e) {
899-
ASSERT_EQUALS("Analysis failed. If the code is valid then please report this failure.", e.errorMessage);
900-
ASSERT_EQUALS("cppcheckError", e.id);
901-
ASSERT_EQUALS(5, e.token->linenr());
902-
}
894+
try {
895+
tokenizeAndStringify(code);
896+
assertThrowFail(__FILE__, __LINE__);
897+
} catch (InternalError& e) {
898+
ASSERT_EQUALS("Analysis failed. If the code is valid then please report this failure.", e.errorMessage);
899+
ASSERT_EQUALS("cppcheckError", e.id);
900+
ASSERT_EQUALS(5, e.token->linenr());
901+
}
903902
}
904903

905904
void wrong_syntax4() { // #3618

0 commit comments

Comments
 (0)