diff options
| author | Martin Hořeňovský | 2020-05-10 19:19:42 +0200 |
|---|---|---|
| committer | Martin Hořeňovský | 2020-05-10 20:21:02 +0200 |
| commit | 27f1756d8e7d2a59832cac83f3219c9ebd286abf (patch) | |
| tree | 17c4e4c0e4c737ba0f64e7c77a323883c1aca497 /src/catch2/internal/catch_lazy_expr.cpp | |
| parent | 824ffe6525dbb9f27cd4a6cfeac54a6971a67a3e (diff) | |
| download | catch3-27f1756d8e7d2a59832cac83f3219c9ebd286abf.tar.gz | |
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.
Diffstat (limited to 'src/catch2/internal/catch_lazy_expr.cpp')
| -rw-r--r-- | src/catch2/internal/catch_lazy_expr.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/catch2/internal/catch_lazy_expr.cpp b/src/catch2/internal/catch_lazy_expr.cpp new file mode 100644 index 00000000..21a33cdc --- /dev/null +++ b/src/catch2/internal/catch_lazy_expr.cpp @@ -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 |