mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-26 07:16:10 +01:00
Move LazyExpr's and MessageInfo's implementation to the combined TU
Some of the implementations were inlined instead.
This commit is contained in:
parent
27f1756d8e
commit
f64487bf70
@ -148,13 +148,11 @@ set(IMPL_SOURCES
|
|||||||
${SOURCES_DIR}/generators/internal/catch_generators_combined_tu.cpp
|
${SOURCES_DIR}/generators/internal/catch_generators_combined_tu.cpp
|
||||||
${SOURCES_DIR}/interfaces/catch_interfaces_combined_tu.cpp
|
${SOURCES_DIR}/interfaces/catch_interfaces_combined_tu.cpp
|
||||||
${SOURCES_DIR}/interfaces/catch_interfaces_reporter.cpp
|
${SOURCES_DIR}/interfaces/catch_interfaces_reporter.cpp
|
||||||
${SOURCES_DIR}/internal/catch_lazy_expr.cpp
|
|
||||||
${SOURCES_DIR}/internal/catch_list.cpp
|
${SOURCES_DIR}/internal/catch_list.cpp
|
||||||
${SOURCES_DIR}/matchers/catch_matchers_floating.cpp
|
${SOURCES_DIR}/matchers/catch_matchers_floating.cpp
|
||||||
${SOURCES_DIR}/matchers/catch_matchers_string.cpp
|
${SOURCES_DIR}/matchers/catch_matchers_string.cpp
|
||||||
${SOURCES_DIR}/matchers/catch_matchers_templated.cpp
|
${SOURCES_DIR}/matchers/catch_matchers_templated.cpp
|
||||||
${SOURCES_DIR}/catch_message.cpp
|
${SOURCES_DIR}/catch_message.cpp
|
||||||
${SOURCES_DIR}/internal/catch_message_info.cpp
|
|
||||||
${SOURCES_DIR}/internal/catch_output_redirect.cpp
|
${SOURCES_DIR}/internal/catch_output_redirect.cpp
|
||||||
${SOURCES_DIR}/catch_registry_hub.cpp
|
${SOURCES_DIR}/catch_registry_hub.cpp
|
||||||
${SOURCES_DIR}/internal/catch_combined_tu.cpp
|
${SOURCES_DIR}/internal/catch_combined_tu.cpp
|
||||||
|
@ -171,3 +171,54 @@ namespace Catch {
|
|||||||
Catch::LeakDetector::~LeakDetector() {
|
Catch::LeakDetector::~LeakDetector() {
|
||||||
Catch::cleanUp();
|
Catch::cleanUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////
|
||||||
|
// vvv formerly catch_message_info.cpp vvv //
|
||||||
|
/////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include <catch2/internal/catch_message_info.hpp>
|
||||||
|
|
||||||
|
namespace Catch {
|
||||||
|
|
||||||
|
MessageInfo::MessageInfo( StringRef const& _macroName,
|
||||||
|
SourceLineInfo const& _lineInfo,
|
||||||
|
ResultWas::OfType _type )
|
||||||
|
: macroName( _macroName ),
|
||||||
|
lineInfo( _lineInfo ),
|
||||||
|
type( _type ),
|
||||||
|
sequence( ++globalCount )
|
||||||
|
{}
|
||||||
|
|
||||||
|
// This may need protecting if threading support is added
|
||||||
|
unsigned int MessageInfo::globalCount = 0;
|
||||||
|
|
||||||
|
} // end namespace Catch
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////
|
||||||
|
// vvv formerly catch_lazy_expr.cpp vvv //
|
||||||
|
//////////////////////////////////////////
|
||||||
|
#include <catch2/internal/catch_lazy_expr.hpp>
|
||||||
|
#include <catch2/internal/catch_decomposer.hpp>
|
||||||
|
|
||||||
|
namespace Catch {
|
||||||
|
|
||||||
|
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
|
||||||
|
@ -49,7 +49,10 @@ namespace Catch {
|
|||||||
|
|
||||||
bool m_isBinaryExpression;
|
bool m_isBinaryExpression;
|
||||||
bool m_result;
|
bool m_result;
|
||||||
|
friend std::ostream& operator<<(std::ostream& out, ITransientExpression const& expr) {
|
||||||
|
expr.streamReconstructedExpression(out);
|
||||||
|
return out;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void formatReconstructedExpression( std::ostream &os, std::string const& lhs, StringRef op, std::string const& rhs );
|
void formatReconstructedExpression( std::ostream &os, std::string const& lhs, StringRef op, std::string const& rhs );
|
||||||
|
@ -1,30 +0,0 @@
|
|||||||
#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
|
|
@ -1,26 +0,0 @@
|
|||||||
|
|
||||||
#include <catch2/internal/catch_message_info.hpp>
|
|
||||||
|
|
||||||
namespace Catch {
|
|
||||||
|
|
||||||
MessageInfo::MessageInfo( StringRef const& _macroName,
|
|
||||||
SourceLineInfo const& _lineInfo,
|
|
||||||
ResultWas::OfType _type )
|
|
||||||
: macroName( _macroName ),
|
|
||||||
lineInfo( _lineInfo ),
|
|
||||||
type( _type ),
|
|
||||||
sequence( ++globalCount )
|
|
||||||
{}
|
|
||||||
|
|
||||||
bool MessageInfo::operator==( MessageInfo const& other ) const {
|
|
||||||
return sequence == other.sequence;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MessageInfo::operator<( MessageInfo const& other ) const {
|
|
||||||
return sequence < other.sequence;
|
|
||||||
}
|
|
||||||
|
|
||||||
// This may need protecting if threading support is added
|
|
||||||
unsigned int MessageInfo::globalCount = 0;
|
|
||||||
|
|
||||||
} // end namespace Catch
|
|
@ -20,8 +20,12 @@ namespace Catch {
|
|||||||
ResultWas::OfType type;
|
ResultWas::OfType type;
|
||||||
unsigned int sequence;
|
unsigned int sequence;
|
||||||
|
|
||||||
bool operator == ( MessageInfo const& other ) const;
|
bool operator == (MessageInfo const& other) const {
|
||||||
bool operator < ( MessageInfo const& other ) const;
|
return sequence == other.sequence;
|
||||||
|
}
|
||||||
|
bool operator < (MessageInfo const& other) const {
|
||||||
|
return sequence < other.sequence;
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
static unsigned int globalCount;
|
static unsigned int globalCount;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user