Skip to content

Commit caeaa48

Browse files
committed
TestCase: Treat expectations as a match even if the test case does not add a trailing newline
1 parent 37864df commit caeaa48

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Diff for: test/TestCase.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ void TestCase::printUpdatedExpectations(std::ostream& _stream, std::string const
8484

8585
TestCase::TestResult TestCase::checkResult(std::ostream& _stream, const std::string& _linePrefix, bool const _formatted)
8686
{
87-
if (m_expectation != m_obtainedResult)
87+
// NOTE: Test cases usually use parseSimpleExpectations(), which ensures that m_expectations ends
88+
// with a newline, so count m_obtainedResult as a match even if it does not.
89+
if (m_expectation != m_obtainedResult && m_expectation != m_obtainedResult + '\n')
8890
{
8991
std::string nextIndentLevel = _linePrefix + " ";
9092
util::AnsiColorized(_stream, _formatted, {util::formatting::BOLD, util::formatting::CYAN})

Diff for: test/libevmasm/EVMAssemblyTest.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,6 @@ TestCase::TestResult EVMAssemblyTest::run(std::ostream& _stream, std::string con
174174
std::string separator = (content.empty() ? "" : (output == "Assembly" ? "\n" : " "));
175175
m_obtainedResult += output + ":" + separator + content;
176176
}
177-
if (!m_obtainedResult.empty() && m_obtainedResult.back() != '\n')
178-
m_obtainedResult += "\n";
179177

180178
return checkResult(_stream, _linePrefix, _formatted);
181179
}

0 commit comments

Comments
 (0)