Skip to content

Commit 6ab7a82

Browse files
committed
TestCase: Print an extra note when expectations differ only in the amount of whitespace
1 parent 1752858 commit 6ab7a82

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

test/TestCase.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <libsolutil/StringUtils.h>
2525

2626
#include <boost/algorithm/string/predicate.hpp>
27+
#include <boost/algorithm/string/trim_all.hpp>
2728

2829
#include <iostream>
2930

@@ -93,6 +94,13 @@ TestCase::TestResult TestCase::checkResult(std::ostream& _stream, const std::str
9394
util::AnsiColorized(_stream, _formatted, {util::formatting::BOLD, util::formatting::CYAN})
9495
<< _linePrefix << "Obtained result:" << std::endl;
9596
printPrefixed(_stream, m_obtainedResult, nextIndentLevel);
97+
98+
if (boost::trim_all_copy(m_expectation) == boost::trim_all_copy(m_obtainedResult))
99+
// NOTE: This will catch `a b` vs `a b` and ` ab ` vs `ab` but not `ab` vs `a b`.
100+
util::AnsiColorized(_stream, _formatted, {util::formatting::BOLD, util::formatting::YELLOW})
101+
<< "\n"
102+
<< _linePrefix << "NOTE: Results differ only in the amount of whitespace." << std::endl;
103+
96104
return TestResult::Failure;
97105
}
98106
return TestResult::Success;

0 commit comments

Comments
 (0)