Split out LazyExpr into its own header

This enables us to avoid `catch_reporter_bases.hpp` being indirectly
dependent on `catch_tostring.hpp`, cutting apart quite a bit indirect
inclusions.
This commit is contained in:
Martin Hořeňovský 2020-05-10 19:19:42 +02:00
parent 824ffe6525
commit 27f1756d8e
No known key found for this signature in database
GPG key ID: DE48307B8B0D381A
10 changed files with 72 additions and 45 deletions

View file

@ -0,0 +1,30 @@
#include <catch2/internal/catch_lazy_expr.hpp>
#include <catch2/internal/catch_decomposer.hpp>
namespace Catch {
namespace {
auto operator <<(std::ostream& os, ITransientExpression const& expr) -> std::ostream& {
expr.streamReconstructedExpression(os);
return os;
}
}
auto operator << (std::ostream& os, LazyExpression const& lazyExpr) -> std::ostream& {
if (lazyExpr.m_isNegated)
os << "!";
if (lazyExpr) {
if (lazyExpr.m_isNegated && lazyExpr.m_transientExpression->isBinaryExpression())
os << "(" << *lazyExpr.m_transientExpression << ")";
else
os << *lazyExpr.m_transientExpression;
} else {
os << "{** error - unchecked empty expression requested **}";
}
return os;
}
} // namespace Catch