diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 41d93ae0..a8d7799d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -72,6 +72,7 @@ set(INTERNAL_HEADERS ${SOURCES_DIR}/interfaces/catch_interfaces_runner.hpp ${SOURCES_DIR}/interfaces/catch_interfaces_tag_alias_registry.hpp ${SOURCES_DIR}/interfaces/catch_interfaces_testcase.hpp + ${SOURCES_DIR}/internal/catch_lazy_expr.hpp ${SOURCES_DIR}/internal/catch_leak_detector.hpp ${SOURCES_DIR}/internal/catch_list.hpp ${SOURCES_DIR}/matchers/catch_matchers.hpp @@ -147,6 +148,7 @@ set(IMPL_SOURCES ${SOURCES_DIR}/generators/internal/catch_generators_combined_tu.cpp ${SOURCES_DIR}/interfaces/catch_interfaces_combined_tu.cpp ${SOURCES_DIR}/interfaces/catch_interfaces_reporter.cpp + ${SOURCES_DIR}/internal/catch_lazy_expr.cpp ${SOURCES_DIR}/internal/catch_list.cpp ${SOURCES_DIR}/matchers/catch_matchers_floating.cpp ${SOURCES_DIR}/matchers/catch_matchers_string.cpp diff --git a/src/catch2/catch_all.hpp b/src/catch2/catch_all.hpp index 3920e822..019c1bfe 100644 --- a/src/catch2/catch_all.hpp +++ b/src/catch2/catch_all.hpp @@ -54,6 +54,7 @@ #include #include #include +#include #include #include #include diff --git a/src/catch2/catch_assertion_result.cpp b/src/catch2/catch_assertion_result.cpp index 4bbf0416..84bb94c9 100644 --- a/src/catch2/catch_assertion_result.cpp +++ b/src/catch2/catch_assertion_result.cpp @@ -7,8 +7,10 @@ */ #include +#include namespace Catch { + AssertionResultData::AssertionResultData(ResultWas::OfType _resultType, LazyExpression const & _lazyExpression): lazyExpression(_lazyExpression), resultType(_resultType) {} diff --git a/src/catch2/catch_assertion_result.hpp b/src/catch2/catch_assertion_result.hpp index 56b3d1cb..b39e71f7 100644 --- a/src/catch2/catch_assertion_result.hpp +++ b/src/catch2/catch_assertion_result.hpp @@ -13,7 +13,7 @@ #include #include #include -#include +#include namespace Catch { diff --git a/src/catch2/internal/catch_assertion_handler.cpp b/src/catch2/internal/catch_assertion_handler.cpp index 14036062..54153462 100644 --- a/src/catch2/internal/catch_assertion_handler.cpp +++ b/src/catch2/internal/catch_assertion_handler.cpp @@ -19,29 +19,6 @@ 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; - } - AssertionHandler::AssertionHandler ( StringRef const& macroName, SourceLineInfo const& lineInfo, diff --git a/src/catch2/internal/catch_assertion_handler.hpp b/src/catch2/internal/catch_assertion_handler.hpp index 646f12f4..df687f5d 100644 --- a/src/catch2/internal/catch_assertion_handler.hpp +++ b/src/catch2/internal/catch_assertion_handler.hpp @@ -11,6 +11,7 @@ #include #include #include +#include namespace Catch { @@ -19,27 +20,6 @@ namespace Catch { struct IResultCapture; class RunContext; - class LazyExpression { - friend class AssertionHandler; - friend struct AssertionStats; - friend class RunContext; - - ITransientExpression const* m_transientExpression = nullptr; - bool m_isNegated; - public: - LazyExpression( bool isNegated ): - m_isNegated(isNegated) - {} - LazyExpression(LazyExpression const& other) = default; - LazyExpression& operator = ( LazyExpression const& ) = delete; - - explicit operator bool() const { - return m_transientExpression != nullptr; - } - - friend auto operator << ( std::ostream& os, LazyExpression const& lazyExpr ) -> std::ostream&; - }; - struct AssertionReaction { bool shouldDebugBreak = false; bool shouldThrow = false; 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 + +#include + + +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 diff --git a/src/catch2/internal/catch_lazy_expr.hpp b/src/catch2/internal/catch_lazy_expr.hpp new file mode 100644 index 00000000..8efc24fc --- /dev/null +++ b/src/catch2/internal/catch_lazy_expr.hpp @@ -0,0 +1,33 @@ +#ifndef CATCH_LAZY_EXPR_HPP_INCLUDED +#define CATCH_LAZY_EXPR_HPP_INCLUDED + +#include + +namespace Catch { + + struct ITransientExpression; + + class LazyExpression { + friend class AssertionHandler; + friend struct AssertionStats; + friend class RunContext; + + ITransientExpression const* m_transientExpression = nullptr; + bool m_isNegated; + public: + LazyExpression( bool isNegated ): + m_isNegated(isNegated) + {} + LazyExpression(LazyExpression const& other) = default; + LazyExpression& operator = ( LazyExpression const& ) = delete; + + explicit operator bool() const { + return m_transientExpression != nullptr; + } + + friend auto operator << ( std::ostream& os, LazyExpression const& lazyExpr ) -> std::ostream&; + }; + +} // namespace Catch + +#endif // CATCH_LAZY_EXPR_HPP_INCLUDED diff --git a/src/catch2/reporters/catch_reporter_bases.cpp b/src/catch2/reporters/catch_reporter_bases.cpp index de302d18..f0343a19 100644 --- a/src/catch2/reporters/catch_reporter_bases.cpp +++ b/src/catch2/reporters/catch_reporter_bases.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include diff --git a/src/catch2/reporters/catch_reporter_console.cpp b/src/catch2/reporters/catch_reporter_console.cpp index cb38318b..e9bea0ee 100644 --- a/src/catch2/reporters/catch_reporter_console.cpp +++ b/src/catch2/reporters/catch_reporter_console.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include