mirror of
https://github.com/catchorg/Catch2.git
synced 2025-01-16 07:08:01 +00:00
Compare commits
9 Commits
7efbc83ae0
...
a39154e115
Author | SHA1 | Date | |
---|---|---|---|
|
a39154e115 | ||
|
7c622a79d4 | ||
|
04cbbb8a4b | ||
|
f64487bf70 | ||
|
27f1756d8e | ||
|
824ffe6525 | ||
|
d5e08a4beb | ||
|
ed967fd7fc | ||
|
7030d7740d |
@ -38,7 +38,7 @@ set(INTERNAL_HEADERS
|
||||
${SOURCES_DIR}/matchers/internal/catch_matchers_impl.hpp
|
||||
${SOURCES_DIR}/internal/catch_container_nonmembers.hpp
|
||||
${SOURCES_DIR}/catch_approx.hpp
|
||||
${SOURCES_DIR}/internal/catch_assertionhandler.hpp
|
||||
${SOURCES_DIR}/internal/catch_assertion_handler.hpp
|
||||
${SOURCES_DIR}/catch_assertion_info.hpp
|
||||
${SOURCES_DIR}/catch_assertion_result.hpp
|
||||
${SOURCES_DIR}/internal/catch_test_macro_impl.hpp
|
||||
@ -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
|
||||
@ -84,6 +85,7 @@ set(INTERNAL_HEADERS
|
||||
${SOURCES_DIR}/matchers/catch_matchers_templated.hpp
|
||||
${SOURCES_DIR}/matchers/catch_matchers_vector.hpp
|
||||
${SOURCES_DIR}/catch_message.hpp
|
||||
${SOURCES_DIR}/internal/catch_message_info.hpp
|
||||
${SOURCES_DIR}/internal/catch_meta.hpp
|
||||
${SOURCES_DIR}/internal/catch_option.hpp
|
||||
${SOURCES_DIR}/internal/catch_output_redirect.hpp
|
||||
@ -129,7 +131,7 @@ set(INTERNAL_HEADERS
|
||||
)
|
||||
set(IMPL_SOURCES
|
||||
${SOURCES_DIR}/catch_approx.cpp
|
||||
${SOURCES_DIR}/internal/catch_assertionhandler.cpp
|
||||
${SOURCES_DIR}/internal/catch_assertion_handler.cpp
|
||||
${SOURCES_DIR}/catch_assertion_result.cpp
|
||||
${SOURCES_DIR}/matchers/internal/catch_matchers_combined_tu.cpp
|
||||
${SOURCES_DIR}/internal/catch_commandline.cpp
|
||||
|
@ -37,7 +37,7 @@
|
||||
#include <catch2/catch_version_macros.hpp>
|
||||
#include <catch2/generators/catch_generators_all.hpp>
|
||||
#include <catch2/interfaces/catch_interfaces_all.hpp>
|
||||
#include <catch2/internal/catch_assertionhandler.hpp>
|
||||
#include <catch2/internal/catch_assertion_handler.hpp>
|
||||
#include <catch2/internal/catch_clara.hpp>
|
||||
#include <catch2/internal/catch_clara_upstream.hpp>
|
||||
#include <catch2/internal/catch_commandline.hpp>
|
||||
@ -54,8 +54,10 @@
|
||||
#include <catch2/internal/catch_errno_guard.hpp>
|
||||
#include <catch2/internal/catch_exception_translator_registry.hpp>
|
||||
#include <catch2/internal/catch_fatal_condition_handler.hpp>
|
||||
#include <catch2/internal/catch_lazy_expr.hpp>
|
||||
#include <catch2/internal/catch_leak_detector.hpp>
|
||||
#include <catch2/internal/catch_list.hpp>
|
||||
#include <catch2/internal/catch_message_info.hpp>
|
||||
#include <catch2/internal/catch_meta.hpp>
|
||||
#include <catch2/internal/catch_option.hpp>
|
||||
#include <catch2/internal/catch_output_redirect.hpp>
|
||||
|
@ -7,8 +7,10 @@
|
||||
*/
|
||||
|
||||
#include <catch2/catch_assertion_result.hpp>
|
||||
#include <catch2/internal/catch_stream.hpp>
|
||||
|
||||
namespace Catch {
|
||||
|
||||
AssertionResultData::AssertionResultData(ResultWas::OfType _resultType, LazyExpression const & _lazyExpression):
|
||||
lazyExpression(_lazyExpression),
|
||||
resultType(_resultType) {}
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include <catch2/internal/catch_result_type.hpp>
|
||||
#include <catch2/internal/catch_common.hpp>
|
||||
#include <catch2/internal/catch_stringref.hpp>
|
||||
#include <catch2/internal/catch_assertionhandler.hpp>
|
||||
#include <catch2/internal/catch_lazy_expr.hpp>
|
||||
|
||||
namespace Catch {
|
||||
|
||||
|
@ -16,27 +16,6 @@
|
||||
|
||||
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;
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Catch::MessageBuilder::MessageBuilder( StringRef const& macroName,
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <catch2/internal/catch_result_type.hpp>
|
||||
#include <catch2/internal/catch_common.hpp>
|
||||
#include <catch2/internal/catch_stream.hpp>
|
||||
#include <catch2/internal/catch_message_info.hpp>
|
||||
#include <catch2/interfaces/catch_interfaces_capture.hpp>
|
||||
#include <catch2/catch_tostring.hpp>
|
||||
|
||||
@ -19,23 +20,6 @@
|
||||
|
||||
namespace Catch {
|
||||
|
||||
struct MessageInfo {
|
||||
MessageInfo( StringRef const& _macroName,
|
||||
SourceLineInfo const& _lineInfo,
|
||||
ResultWas::OfType _type );
|
||||
|
||||
StringRef macroName;
|
||||
std::string message;
|
||||
SourceLineInfo lineInfo;
|
||||
ResultWas::OfType type;
|
||||
unsigned int sequence;
|
||||
|
||||
bool operator == ( MessageInfo const& other ) const;
|
||||
bool operator < ( MessageInfo const& other ) const;
|
||||
private:
|
||||
static unsigned int globalCount;
|
||||
};
|
||||
|
||||
struct MessageStream {
|
||||
|
||||
template<typename T>
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include <catch2/interfaces/catch_interfaces_reporter.hpp>
|
||||
#include <catch2/internal/catch_console_colour.hpp>
|
||||
#include <catch2/catch_message.hpp>
|
||||
#include <catch2/internal/catch_list.hpp>
|
||||
#include <catch2/internal/catch_text.hpp>
|
||||
#include <catch2/internal/catch_string_manip.hpp>
|
||||
@ -56,8 +57,6 @@ namespace Catch {
|
||||
}
|
||||
}
|
||||
|
||||
AssertionStats::~AssertionStats() = default;
|
||||
|
||||
SectionStats::SectionStats( SectionInfo const& _sectionInfo,
|
||||
Counts const& _assertions,
|
||||
double _durationInSeconds,
|
||||
@ -68,8 +67,6 @@ namespace Catch {
|
||||
missingAssertions( _missingAssertions )
|
||||
{}
|
||||
|
||||
SectionStats::~SectionStats() = default;
|
||||
|
||||
|
||||
TestCaseStats::TestCaseStats( TestCaseInfo const& _testInfo,
|
||||
Totals const& _totals,
|
||||
@ -83,8 +80,6 @@ namespace Catch {
|
||||
aborting( _aborting )
|
||||
{}
|
||||
|
||||
TestCaseStats::~TestCaseStats() = default;
|
||||
|
||||
|
||||
TestGroupStats::TestGroupStats( GroupInfo const& _groupInfo,
|
||||
Totals const& _totals,
|
||||
@ -99,7 +94,6 @@ namespace Catch {
|
||||
aborting( false )
|
||||
{}
|
||||
|
||||
TestGroupStats::~TestGroupStats() = default;
|
||||
|
||||
TestRunStats::TestRunStats( TestRunInfo const& _runInfo,
|
||||
Totals const& _totals,
|
||||
@ -109,8 +103,6 @@ namespace Catch {
|
||||
aborting( _aborting )
|
||||
{}
|
||||
|
||||
TestRunStats::~TestRunStats() = default;
|
||||
|
||||
void IStreamingReporter::fatalErrorEncountered( StringRef ) {}
|
||||
|
||||
void IStreamingReporter::listReporters(std::vector<ReporterDescription> const& descriptions, Config const& config) {
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include <catch2/catch_totals.hpp>
|
||||
#include <catch2/catch_test_case_info.hpp>
|
||||
#include <catch2/catch_assertion_result.hpp>
|
||||
#include <catch2/catch_message.hpp>
|
||||
#include <catch2/internal/catch_message_info.hpp>
|
||||
#include <catch2/internal/catch_option.hpp>
|
||||
#include <catch2/internal/catch_stringref.hpp>
|
||||
|
||||
@ -25,7 +25,6 @@
|
||||
#include <string>
|
||||
#include <iosfwd>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <memory>
|
||||
#include <algorithm>
|
||||
|
||||
@ -89,7 +88,6 @@ namespace Catch {
|
||||
AssertionStats( AssertionStats && ) = default;
|
||||
AssertionStats& operator = ( AssertionStats const& ) = delete;
|
||||
AssertionStats& operator = ( AssertionStats && ) = delete;
|
||||
virtual ~AssertionStats();
|
||||
|
||||
AssertionResult assertionResult;
|
||||
std::vector<MessageInfo> infoMessages;
|
||||
@ -101,11 +99,6 @@ namespace Catch {
|
||||
Counts const& _assertions,
|
||||
double _durationInSeconds,
|
||||
bool _missingAssertions );
|
||||
SectionStats( SectionStats const& ) = default;
|
||||
SectionStats( SectionStats && ) = default;
|
||||
SectionStats& operator = ( SectionStats const& ) = default;
|
||||
SectionStats& operator = ( SectionStats && ) = default;
|
||||
virtual ~SectionStats();
|
||||
|
||||
SectionInfo sectionInfo;
|
||||
Counts assertions;
|
||||
@ -120,12 +113,6 @@ namespace Catch {
|
||||
std::string const& _stdErr,
|
||||
bool _aborting );
|
||||
|
||||
TestCaseStats( TestCaseStats const& ) = default;
|
||||
TestCaseStats( TestCaseStats && ) = default;
|
||||
TestCaseStats& operator = ( TestCaseStats const& ) = default;
|
||||
TestCaseStats& operator = ( TestCaseStats && ) = default;
|
||||
virtual ~TestCaseStats();
|
||||
|
||||
TestCaseInfo const * testInfo;
|
||||
Totals totals;
|
||||
std::string stdOut;
|
||||
@ -139,12 +126,6 @@ namespace Catch {
|
||||
bool _aborting );
|
||||
TestGroupStats( GroupInfo const& _groupInfo );
|
||||
|
||||
TestGroupStats( TestGroupStats const& ) = default;
|
||||
TestGroupStats( TestGroupStats && ) = default;
|
||||
TestGroupStats& operator = ( TestGroupStats const& ) = default;
|
||||
TestGroupStats& operator = ( TestGroupStats && ) = default;
|
||||
virtual ~TestGroupStats();
|
||||
|
||||
GroupInfo groupInfo;
|
||||
Totals totals;
|
||||
bool aborting;
|
||||
@ -155,12 +136,6 @@ namespace Catch {
|
||||
Totals const& _totals,
|
||||
bool _aborting );
|
||||
|
||||
TestRunStats( TestRunStats const& ) = default;
|
||||
TestRunStats( TestRunStats && ) = default;
|
||||
TestRunStats& operator = ( TestRunStats const& ) = default;
|
||||
TestRunStats& operator = ( TestRunStats && ) = default;
|
||||
virtual ~TestRunStats();
|
||||
|
||||
TestRunInfo runInfo;
|
||||
Totals totals;
|
||||
bool aborting;
|
||||
|
@ -6,7 +6,7 @@
|
||||
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
#include <catch2/internal/catch_assertionhandler.hpp>
|
||||
#include <catch2/internal/catch_assertion_handler.hpp>
|
||||
#include <catch2/catch_assertion_result.hpp>
|
||||
#include <catch2/interfaces/catch_interfaces_runner.hpp>
|
||||
#include <catch2/interfaces/catch_interfaces_config.hpp>
|
||||
@ -19,39 +19,6 @@
|
||||
|
||||
namespace Catch {
|
||||
|
||||
namespace {
|
||||
auto operator <<( std::ostream& os, ITransientExpression const& expr ) -> std::ostream& {
|
||||
expr.streamReconstructedExpression( os );
|
||||
return os;
|
||||
}
|
||||
}
|
||||
|
||||
LazyExpression::LazyExpression( bool isNegated )
|
||||
: m_isNegated( isNegated )
|
||||
{}
|
||||
|
||||
LazyExpression::LazyExpression( LazyExpression const& other ) : m_isNegated( other.m_isNegated ) {}
|
||||
|
||||
LazyExpression::operator bool() const {
|
||||
return m_transientExpression != nullptr;
|
||||
}
|
||||
|
||||
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,
|
@ -11,6 +11,7 @@
|
||||
#include <catch2/catch_assertion_info.hpp>
|
||||
#include <catch2/internal/catch_decomposer.hpp>
|
||||
#include <catch2/interfaces/catch_interfaces_capture.hpp>
|
||||
#include <catch2/internal/catch_lazy_expr.hpp>
|
||||
|
||||
namespace Catch {
|
||||
|
||||
@ -19,23 +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 );
|
||||
LazyExpression( LazyExpression const& other );
|
||||
LazyExpression& operator = ( LazyExpression const& ) = delete;
|
||||
|
||||
explicit operator bool() const;
|
||||
|
||||
friend auto operator << ( std::ostream& os, LazyExpression const& lazyExpr ) -> std::ostream&;
|
||||
};
|
||||
|
||||
struct AssertionReaction {
|
||||
bool shouldDebugBreak = false;
|
||||
bool shouldThrow = false;
|
@ -171,3 +171,54 @@ namespace Catch {
|
||||
Catch::LeakDetector::~LeakDetector() {
|
||||
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_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 );
|
||||
|
@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
#include <catch2/internal/catch_exception_translator_registry.hpp>
|
||||
#include <catch2/internal/catch_assertionhandler.hpp>
|
||||
#include <catch2/internal/catch_assertion_handler.hpp>
|
||||
#include <catch2/internal/catch_compiler_capabilities.hpp>
|
||||
#include <catch2/internal/catch_enforce.hpp>
|
||||
|
||||
|
33
src/catch2/internal/catch_lazy_expr.hpp
Normal file
33
src/catch2/internal/catch_lazy_expr.hpp
Normal file
@ -0,0 +1,33 @@
|
||||
#ifndef CATCH_LAZY_EXPR_HPP_INCLUDED
|
||||
#define CATCH_LAZY_EXPR_HPP_INCLUDED
|
||||
|
||||
#include <iosfwd>
|
||||
|
||||
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
|
35
src/catch2/internal/catch_message_info.hpp
Normal file
35
src/catch2/internal/catch_message_info.hpp
Normal file
@ -0,0 +1,35 @@
|
||||
#ifndef CATCH_MESSAGE_INFO_HPP_INCLUDED
|
||||
#define CATCH_MESSAGE_INFO_HPP_INCLUDED
|
||||
|
||||
#include <catch2/internal/catch_result_type.hpp>
|
||||
#include <catch2/internal/catch_common.hpp>
|
||||
#include <catch2/interfaces/catch_interfaces_capture.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace Catch {
|
||||
|
||||
struct MessageInfo {
|
||||
MessageInfo( StringRef const& _macroName,
|
||||
SourceLineInfo const& _lineInfo,
|
||||
ResultWas::OfType _type );
|
||||
|
||||
StringRef macroName;
|
||||
std::string message;
|
||||
SourceLineInfo lineInfo;
|
||||
ResultWas::OfType type;
|
||||
unsigned int sequence;
|
||||
|
||||
bool operator == (MessageInfo const& other) const {
|
||||
return sequence == other.sequence;
|
||||
}
|
||||
bool operator < (MessageInfo const& other) const {
|
||||
return sequence < other.sequence;
|
||||
}
|
||||
private:
|
||||
static unsigned int globalCount;
|
||||
};
|
||||
|
||||
} // end namespace Catch
|
||||
|
||||
#endif // CATCH_MESSAGE_INFO_HPP_INCLUDED
|
@ -16,10 +16,11 @@
|
||||
#include <catch2/internal/catch_test_registry.hpp>
|
||||
#include <catch2/catch_test_case_info.hpp>
|
||||
#include <catch2/internal/catch_test_macro_impl.hpp>
|
||||
#include <catch2/catch_message.hpp>
|
||||
#include <catch2/catch_totals.hpp>
|
||||
#include <catch2/catch_test_spec.hpp>
|
||||
#include <catch2/internal/catch_test_case_tracker.hpp>
|
||||
#include <catch2/internal/catch_assertionhandler.hpp>
|
||||
#include <catch2/internal/catch_assertion_handler.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
#ifndef TWOBLUECUBES_CATCH_CAPTURE_HPP_INCLUDED
|
||||
#define TWOBLUECUBES_CATCH_CAPTURE_HPP_INCLUDED
|
||||
|
||||
#include <catch2/internal/catch_assertionhandler.hpp>
|
||||
#include <catch2/internal/catch_assertion_handler.hpp>
|
||||
#include <catch2/interfaces/catch_interfaces_capture.hpp>
|
||||
#include <catch2/internal/catch_stringref.hpp>
|
||||
|
||||
|
@ -9,6 +9,8 @@
|
||||
#include <catch2/interfaces/catch_interfaces_reporter.hpp>
|
||||
#include <catch2/internal/catch_errno_guard.hpp>
|
||||
#include <catch2/reporters/catch_reporter_bases.hpp>
|
||||
#include <catch2/internal/catch_stream.hpp>
|
||||
#include <catch2/catch_config.hpp>
|
||||
|
||||
#include <cstring>
|
||||
#include <cfloat>
|
||||
@ -69,4 +71,12 @@ namespace Catch {
|
||||
StreamingReporterBase::~StreamingReporterBase() = default;
|
||||
CumulativeReporterBase::~CumulativeReporterBase() = default;
|
||||
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, lineOfChars value) {
|
||||
for (size_t idx = 0; idx < CATCH_CONFIG_CONSOLE_WIDTH - 1; ++idx) {
|
||||
out.put(value.c);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
} // end namespace Catch
|
||||
|
@ -241,16 +241,14 @@ namespace Catch {
|
||||
ReporterPreferences m_reporterPrefs;
|
||||
};
|
||||
|
||||
template<char C>
|
||||
char const* getLineOfChars() {
|
||||
static char line[CATCH_CONFIG_CONSOLE_WIDTH] = {0};
|
||||
if( !*line ) {
|
||||
std::memset( line, C, CATCH_CONFIG_CONSOLE_WIDTH-1 );
|
||||
line[CATCH_CONFIG_CONSOLE_WIDTH-1] = 0;
|
||||
}
|
||||
return line;
|
||||
}
|
||||
struct lineOfChars {
|
||||
char c;
|
||||
constexpr lineOfChars(char c):
|
||||
c(c)
|
||||
{}
|
||||
|
||||
friend std::ostream& operator<< (std::ostream& out, lineOfChars value);
|
||||
};
|
||||
|
||||
struct TestEventListenerBase : StreamingReporterBase {
|
||||
TestEventListenerBase( ReporterConfig const& _config );
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <catch2/internal/catch_string_manip.hpp>
|
||||
#include <catch2/catch_version.hpp>
|
||||
#include <catch2/internal/catch_text.hpp>
|
||||
#include <catch2/internal/catch_stream.hpp>
|
||||
#include <catch2/internal/catch_stringref.hpp>
|
||||
|
||||
#include <cfloat>
|
||||
@ -299,7 +300,7 @@ public:
|
||||
}
|
||||
m_os << headerCols << '\n';
|
||||
|
||||
m_os << Catch::getLineOfChars<'-'>() << '\n';
|
||||
m_os << lineOfChars('-') << '\n';
|
||||
}
|
||||
}
|
||||
void close() {
|
||||
@ -518,7 +519,7 @@ void ConsoleReporter::lazyPrintWithoutClosingBenchmarkTable() {
|
||||
}
|
||||
}
|
||||
void ConsoleReporter::lazyPrintRunInfo() {
|
||||
stream << '\n' << getLineOfChars<'~'>() << '\n';
|
||||
stream << '\n' << lineOfChars('~') << '\n';
|
||||
Colour colour(Colour::SecondaryText);
|
||||
stream << currentTestRunInfo->name
|
||||
<< " is a Catch v" << libraryVersion() << " host application.\n"
|
||||
@ -552,18 +553,18 @@ void ConsoleReporter::printTestCaseAndSectionHeader() {
|
||||
SourceLineInfo lineInfo = m_sectionStack.back().lineInfo;
|
||||
|
||||
|
||||
stream << getLineOfChars<'-'>() << '\n';
|
||||
stream << lineOfChars('-') << '\n';
|
||||
Colour colourGuard(Colour::FileName);
|
||||
stream << lineInfo << '\n';
|
||||
stream << getLineOfChars<'.'>() << '\n' << std::endl;
|
||||
stream << lineOfChars('.') << '\n' << std::endl;
|
||||
}
|
||||
|
||||
void ConsoleReporter::printClosedHeader(std::string const& _name) {
|
||||
printOpenHeader(_name);
|
||||
stream << getLineOfChars<'.'>() << '\n';
|
||||
stream << lineOfChars('.') << '\n';
|
||||
}
|
||||
void ConsoleReporter::printOpenHeader(std::string const& _name) {
|
||||
stream << getLineOfChars<'-'>() << '\n';
|
||||
stream << lineOfChars('-') << '\n';
|
||||
{
|
||||
Colour colourGuard(Colour::Headers);
|
||||
printHeaderString(_name);
|
||||
@ -675,7 +676,7 @@ void ConsoleReporter::printTotalsDivider(Totals const& totals) {
|
||||
stream << '\n';
|
||||
}
|
||||
void ConsoleReporter::printSummaryDivider() {
|
||||
stream << getLineOfChars<'-'>() << '\n';
|
||||
stream << lineOfChars('-') << '\n';
|
||||
}
|
||||
|
||||
void ConsoleReporter::printTestFilters() {
|
||||
|
@ -16,7 +16,6 @@
|
||||
#include <catch2/internal/catch_text.hpp>
|
||||
|
||||
#include <cassert>
|
||||
#include <sstream>
|
||||
#include <ctime>
|
||||
#include <algorithm>
|
||||
|
||||
|
@ -22,7 +22,7 @@ namespace Catch {
|
||||
i = 0;
|
||||
os << Column(_string)
|
||||
.indent(indent + i)
|
||||
.initialIndent(indent) << "\n";
|
||||
.initialIndent(indent) << '\n';
|
||||
}
|
||||
|
||||
std::string escape(std::string const& str) {
|
||||
@ -152,20 +152,20 @@ namespace Catch {
|
||||
assert(!m_sectionStack.empty());
|
||||
|
||||
if (m_sectionStack.size() > 1) {
|
||||
os << getLineOfChars<'-'>() << '\n';
|
||||
os << lineOfChars('-') << '\n';
|
||||
|
||||
std::vector<SectionInfo>::const_iterator
|
||||
it = m_sectionStack.begin() + 1, // Skip first section (test case)
|
||||
itEnd = m_sectionStack.end();
|
||||
for (; it != itEnd; ++it)
|
||||
printHeaderString(os, it->name);
|
||||
os << getLineOfChars<'-'>() << '\n';
|
||||
os << lineOfChars('-') << '\n';
|
||||
}
|
||||
|
||||
SourceLineInfo lineInfo = m_sectionStack.front().lineInfo;
|
||||
|
||||
os << lineInfo << '\n';
|
||||
os << getLineOfChars<'.'>() << "\n\n";
|
||||
os << lineOfChars('.') << "\n\n";
|
||||
}
|
||||
|
||||
} // end namespace Catch
|
||||
|
@ -8,9 +8,7 @@
|
||||
|
||||
#include <catch2/reporters/catch_reporter_xml.hpp>
|
||||
|
||||
#include <catch2/internal/catch_test_macro_impl.hpp>
|
||||
#include <catch2/internal/catch_string_manip.hpp>
|
||||
#include <catch2/catch_reporter_registrars.hpp>
|
||||
#include <catch2/internal/catch_list.hpp>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
|
Loading…
Reference in New Issue
Block a user