mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-03 05:45:39 +02:00
v3.5.1
This commit is contained in:
@@ -6,8 +6,8 @@
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
|
||||
// Catch v3.5.0
|
||||
// Generated: 2023-12-11 00:51:07.662625
|
||||
// Catch v3.5.1
|
||||
// Generated: 2023-12-31 15:10:55.864983
|
||||
// ----------------------------------------------------------
|
||||
// This file is an amalgamation of multiple different files.
|
||||
// You probably shouldn't edit it directly.
|
||||
@@ -2273,7 +2273,7 @@ namespace Catch {
|
||||
}
|
||||
|
||||
Version const& libraryVersion() {
|
||||
static Version version( 3, 5, 0, "", 0 );
|
||||
static Version version( 3, 5, 1, "", 0 );
|
||||
return version;
|
||||
}
|
||||
|
||||
@@ -2415,9 +2415,7 @@ namespace Catch {
|
||||
|
||||
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <iomanip>
|
||||
|
||||
namespace Catch {
|
||||
|
||||
@@ -2627,13 +2625,29 @@ namespace {
|
||||
;
|
||||
}
|
||||
|
||||
std::string normaliseOpt( std::string const& optName ) {
|
||||
#ifdef CATCH_PLATFORM_WINDOWS
|
||||
if ( optName[0] == '/' )
|
||||
return "-" + optName.substr( 1 );
|
||||
else
|
||||
Catch::StringRef normaliseOpt( Catch::StringRef optName ) {
|
||||
if ( optName[0] == '-'
|
||||
#if defined(CATCH_PLATFORM_WINDOWS)
|
||||
|| optName[0] == '/'
|
||||
#endif
|
||||
return optName;
|
||||
) {
|
||||
return optName.substr( 1, optName.size() );
|
||||
}
|
||||
|
||||
return optName;
|
||||
}
|
||||
|
||||
static size_t find_first_separator(Catch::StringRef sr) {
|
||||
auto is_separator = []( char c ) {
|
||||
return c == ' ' || c == ':' || c == '=';
|
||||
};
|
||||
size_t pos = 0;
|
||||
while (pos < sr.size()) {
|
||||
if (is_separator(sr[pos])) { return pos; }
|
||||
++pos;
|
||||
}
|
||||
|
||||
return Catch::StringRef::npos;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -2651,23 +2665,23 @@ namespace Catch {
|
||||
}
|
||||
|
||||
if ( it != itEnd ) {
|
||||
auto const& next = *it;
|
||||
StringRef next = *it;
|
||||
if ( isOptPrefix( next[0] ) ) {
|
||||
auto delimiterPos = next.find_first_of( " :=" );
|
||||
if ( delimiterPos != std::string::npos ) {
|
||||
auto delimiterPos = find_first_separator(next);
|
||||
if ( delimiterPos != StringRef::npos ) {
|
||||
m_tokenBuffer.push_back(
|
||||
{ TokenType::Option,
|
||||
next.substr( 0, delimiterPos ) } );
|
||||
m_tokenBuffer.push_back(
|
||||
{ TokenType::Argument,
|
||||
next.substr( delimiterPos + 1 ) } );
|
||||
next.substr( delimiterPos + 1, next.size() ) } );
|
||||
} else {
|
||||
if ( next[1] != '-' && next.size() > 2 ) {
|
||||
std::string opt = "- ";
|
||||
// Combined short args, e.g. "-ab" for "-a -b"
|
||||
for ( size_t i = 1; i < next.size(); ++i ) {
|
||||
opt[1] = next[i];
|
||||
m_tokenBuffer.push_back(
|
||||
{ TokenType::Option, opt } );
|
||||
{ TokenType::Option,
|
||||
next.substr( i, 1 ) } );
|
||||
}
|
||||
} else {
|
||||
m_tokenBuffer.push_back(
|
||||
@@ -2727,12 +2741,12 @@ namespace Catch {
|
||||
size_t ParserBase::cardinality() const { return 1; }
|
||||
|
||||
InternalParseResult ParserBase::parse( Args const& args ) const {
|
||||
return parse( args.exeName(), TokenStream( args ) );
|
||||
return parse( static_cast<std::string>(args.exeName()), TokenStream( args ) );
|
||||
}
|
||||
|
||||
ParseState::ParseState( ParseResultType type,
|
||||
TokenStream const& remainingTokens ):
|
||||
m_type( type ), m_remainingTokens( remainingTokens ) {}
|
||||
TokenStream remainingTokens ):
|
||||
m_type( type ), m_remainingTokens( CATCH_MOVE(remainingTokens) ) {}
|
||||
|
||||
ParserResult BoundFlagRef::setFlag( bool flag ) {
|
||||
m_ref = flag;
|
||||
@@ -2750,34 +2764,34 @@ namespace Catch {
|
||||
} // namespace Detail
|
||||
|
||||
Detail::InternalParseResult Arg::parse(std::string const&,
|
||||
Detail::TokenStream const& tokens) const {
|
||||
Detail::TokenStream tokens) const {
|
||||
auto validationResult = validate();
|
||||
if (!validationResult)
|
||||
return Detail::InternalParseResult(validationResult);
|
||||
|
||||
auto remainingTokens = tokens;
|
||||
auto const& token = *remainingTokens;
|
||||
auto token = *tokens;
|
||||
if (token.type != Detail::TokenType::Argument)
|
||||
return Detail::InternalParseResult::ok(Detail::ParseState(
|
||||
ParseResultType::NoMatch, remainingTokens));
|
||||
ParseResultType::NoMatch, CATCH_MOVE(tokens)));
|
||||
|
||||
assert(!m_ref->isFlag());
|
||||
auto valueRef =
|
||||
static_cast<Detail::BoundValueRefBase*>(m_ref.get());
|
||||
|
||||
auto result = valueRef->setValue(remainingTokens->token);
|
||||
if (!result)
|
||||
return Detail::InternalParseResult(result);
|
||||
auto result = valueRef->setValue(static_cast<std::string>(token.token));
|
||||
if ( !result )
|
||||
return Detail::InternalParseResult( result );
|
||||
else
|
||||
return Detail::InternalParseResult::ok(Detail::ParseState(
|
||||
ParseResultType::Matched, ++remainingTokens));
|
||||
return Detail::InternalParseResult::ok(
|
||||
Detail::ParseState( ParseResultType::Matched,
|
||||
CATCH_MOVE( ++tokens ) ) );
|
||||
}
|
||||
|
||||
Opt::Opt(bool& ref) :
|
||||
ParserRefImpl(std::make_shared<Detail::BoundFlagRef>(ref)) {}
|
||||
|
||||
std::vector<Detail::HelpColumns> Opt::getHelpColumns() const {
|
||||
std::ostringstream oss;
|
||||
Detail::HelpColumns Opt::getHelpColumns() const {
|
||||
ReusableStringStream oss;
|
||||
bool first = true;
|
||||
for (auto const& opt : m_optNames) {
|
||||
if (first)
|
||||
@@ -2788,10 +2802,10 @@ namespace Catch {
|
||||
}
|
||||
if (!m_hint.empty())
|
||||
oss << " <" << m_hint << '>';
|
||||
return { { oss.str(), m_description } };
|
||||
return { oss.str(), m_description };
|
||||
}
|
||||
|
||||
bool Opt::isMatch(std::string const& optToken) const {
|
||||
bool Opt::isMatch(StringRef optToken) const {
|
||||
auto normalisedToken = normaliseOpt(optToken);
|
||||
for (auto const& name : m_optNames) {
|
||||
if (normaliseOpt(name) == normalisedToken)
|
||||
@@ -2801,15 +2815,14 @@ namespace Catch {
|
||||
}
|
||||
|
||||
Detail::InternalParseResult Opt::parse(std::string const&,
|
||||
Detail::TokenStream const& tokens) const {
|
||||
Detail::TokenStream tokens) const {
|
||||
auto validationResult = validate();
|
||||
if (!validationResult)
|
||||
return Detail::InternalParseResult(validationResult);
|
||||
|
||||
auto remainingTokens = tokens;
|
||||
if (remainingTokens &&
|
||||
remainingTokens->type == Detail::TokenType::Option) {
|
||||
auto const& token = *remainingTokens;
|
||||
if (tokens &&
|
||||
tokens->type == Detail::TokenType::Option) {
|
||||
auto const& token = *tokens;
|
||||
if (isMatch(token.token)) {
|
||||
if (m_ref->isFlag()) {
|
||||
auto flagRef =
|
||||
@@ -2821,35 +2834,35 @@ namespace Catch {
|
||||
if (result.value() ==
|
||||
ParseResultType::ShortCircuitAll)
|
||||
return Detail::InternalParseResult::ok(Detail::ParseState(
|
||||
result.value(), remainingTokens));
|
||||
result.value(), CATCH_MOVE(tokens)));
|
||||
} else {
|
||||
auto valueRef =
|
||||
static_cast<Detail::BoundValueRefBase*>(
|
||||
m_ref.get());
|
||||
++remainingTokens;
|
||||
if (!remainingTokens)
|
||||
++tokens;
|
||||
if (!tokens)
|
||||
return Detail::InternalParseResult::runtimeError(
|
||||
"Expected argument following " +
|
||||
token.token);
|
||||
auto const& argToken = *remainingTokens;
|
||||
auto const& argToken = *tokens;
|
||||
if (argToken.type != Detail::TokenType::Argument)
|
||||
return Detail::InternalParseResult::runtimeError(
|
||||
"Expected argument following " +
|
||||
token.token);
|
||||
const auto result = valueRef->setValue(argToken.token);
|
||||
const auto result = valueRef->setValue(static_cast<std::string>(argToken.token));
|
||||
if (!result)
|
||||
return Detail::InternalParseResult(result);
|
||||
if (result.value() ==
|
||||
ParseResultType::ShortCircuitAll)
|
||||
return Detail::InternalParseResult::ok(Detail::ParseState(
|
||||
result.value(), remainingTokens));
|
||||
result.value(), CATCH_MOVE(tokens)));
|
||||
}
|
||||
return Detail::InternalParseResult::ok(Detail::ParseState(
|
||||
ParseResultType::Matched, ++remainingTokens));
|
||||
ParseResultType::Matched, CATCH_MOVE(++tokens)));
|
||||
}
|
||||
}
|
||||
return Detail::InternalParseResult::ok(
|
||||
Detail::ParseState(ParseResultType::NoMatch, remainingTokens));
|
||||
Detail::ParseState(ParseResultType::NoMatch, CATCH_MOVE(tokens)));
|
||||
}
|
||||
|
||||
Detail::Result Opt::validate() const {
|
||||
@@ -2881,9 +2894,9 @@ namespace Catch {
|
||||
|
||||
Detail::InternalParseResult
|
||||
ExeName::parse(std::string const&,
|
||||
Detail::TokenStream const& tokens) const {
|
||||
Detail::TokenStream tokens) const {
|
||||
return Detail::InternalParseResult::ok(
|
||||
Detail::ParseState(ParseResultType::NoMatch, tokens));
|
||||
Detail::ParseState(ParseResultType::NoMatch, CATCH_MOVE(tokens)));
|
||||
}
|
||||
|
||||
ParserResult ExeName::set(std::string const& newName) {
|
||||
@@ -2913,9 +2926,9 @@ namespace Catch {
|
||||
|
||||
std::vector<Detail::HelpColumns> Parser::getHelpColumns() const {
|
||||
std::vector<Detail::HelpColumns> cols;
|
||||
cols.reserve( m_options.size() );
|
||||
for ( auto const& o : m_options ) {
|
||||
auto childCols = o.getHelpColumns();
|
||||
cols.insert( cols.end(), childCols.begin(), childCols.end() );
|
||||
cols.push_back(o.getHelpColumns());
|
||||
}
|
||||
return cols;
|
||||
}
|
||||
@@ -2953,12 +2966,12 @@ namespace Catch {
|
||||
|
||||
optWidth = ( std::min )( optWidth, consoleWidth / 2 );
|
||||
|
||||
for ( auto const& cols : rows ) {
|
||||
auto row = TextFlow::Column( cols.left )
|
||||
for ( auto& cols : rows ) {
|
||||
auto row = TextFlow::Column( CATCH_MOVE(cols.left) )
|
||||
.width( optWidth )
|
||||
.indent( 2 ) +
|
||||
TextFlow::Spacer( 4 ) +
|
||||
TextFlow::Column( cols.right )
|
||||
TextFlow::Column( static_cast<std::string>(cols.descriptions) )
|
||||
.width( consoleWidth - 7 - optWidth );
|
||||
os << row << '\n';
|
||||
}
|
||||
@@ -2980,7 +2993,7 @@ namespace Catch {
|
||||
|
||||
Detail::InternalParseResult
|
||||
Parser::parse( std::string const& exeName,
|
||||
Detail::TokenStream const& tokens ) const {
|
||||
Detail::TokenStream tokens ) const {
|
||||
|
||||
struct ParserInfo {
|
||||
ParserBase const* parser = nullptr;
|
||||
@@ -2998,7 +3011,7 @@ namespace Catch {
|
||||
m_exeName.set( exeName );
|
||||
|
||||
auto result = Detail::InternalParseResult::ok(
|
||||
Detail::ParseState( ParseResultType::NoMatch, tokens ) );
|
||||
Detail::ParseState( ParseResultType::NoMatch, CATCH_MOVE(tokens) ) );
|
||||
while ( result.value().remainingTokens() ) {
|
||||
bool tokenParsed = false;
|
||||
|
||||
@@ -3006,7 +3019,7 @@ namespace Catch {
|
||||
if ( parseInfo.parser->cardinality() == 0 ||
|
||||
parseInfo.count < parseInfo.parser->cardinality() ) {
|
||||
result = parseInfo.parser->parse(
|
||||
exeName, result.value().remainingTokens() );
|
||||
exeName, CATCH_MOVE(result).value().remainingTokens() );
|
||||
if ( !result )
|
||||
return result;
|
||||
if ( result.value().type() !=
|
||||
@@ -3032,7 +3045,7 @@ namespace Catch {
|
||||
Args::Args(int argc, char const* const* argv) :
|
||||
m_exeName(argv[0]), m_args(argv + 1, argv + argc) {}
|
||||
|
||||
Args::Args(std::initializer_list<std::string> args) :
|
||||
Args::Args(std::initializer_list<StringRef> args) :
|
||||
m_exeName(*args.begin()),
|
||||
m_args(args.begin() + 1, args.end()) {}
|
||||
|
||||
@@ -3338,8 +3351,8 @@ namespace Catch {
|
||||
( "split the tests to execute into this many groups" )
|
||||
| Opt( setShardIndex, "shard index" )
|
||||
["--shard-index"]
|
||||
( "index of the group of tests to execute (see --shard-count)" ) |
|
||||
Opt( config.allowZeroTests )
|
||||
( "index of the group of tests to execute (see --shard-count)" )
|
||||
| Opt( config.allowZeroTests )
|
||||
["--allow-running-no-tests"]
|
||||
( "Treat 'No tests run' as a success" )
|
||||
| Arg( config.testsOrTags, "test name|pattern|tags" )
|
||||
@@ -4641,7 +4654,6 @@ Catch::LeakDetector::~LeakDetector() {
|
||||
|
||||
|
||||
|
||||
|
||||
namespace Catch {
|
||||
namespace {
|
||||
|
||||
@@ -6527,7 +6539,6 @@ namespace Catch {
|
||||
return sorted;
|
||||
}
|
||||
case TestRunOrder::Randomized: {
|
||||
seedRng(config);
|
||||
using TestWithHash = std::pair<TestCaseInfoHasher::hash_t, TestCaseHandle>;
|
||||
|
||||
TestCaseInfoHasher h{ config.rngSeed() };
|
||||
@@ -7390,23 +7401,36 @@ namespace Catch {
|
||||
return os;
|
||||
}
|
||||
|
||||
Columns Column::operator+( Column const& other ) {
|
||||
Columns operator+(Column const& lhs, Column const& rhs) {
|
||||
Columns cols;
|
||||
cols += *this;
|
||||
cols += other;
|
||||
cols += lhs;
|
||||
cols += rhs;
|
||||
return cols;
|
||||
}
|
||||
Columns operator+(Column&& lhs, Column&& rhs) {
|
||||
Columns cols;
|
||||
cols += CATCH_MOVE( lhs );
|
||||
cols += CATCH_MOVE( rhs );
|
||||
return cols;
|
||||
}
|
||||
|
||||
Columns& Columns::operator+=( Column const& col ) {
|
||||
m_columns.push_back( col );
|
||||
return *this;
|
||||
Columns& operator+=(Columns& lhs, Column const& rhs) {
|
||||
lhs.m_columns.push_back( rhs );
|
||||
return lhs;
|
||||
}
|
||||
|
||||
Columns Columns::operator+( Column const& col ) {
|
||||
Columns combined = *this;
|
||||
combined += col;
|
||||
Columns& operator+=(Columns& lhs, Column&& rhs) {
|
||||
lhs.m_columns.push_back( CATCH_MOVE(rhs) );
|
||||
return lhs;
|
||||
}
|
||||
Columns operator+( Columns const& lhs, Column const& rhs ) {
|
||||
auto combined( lhs );
|
||||
combined += rhs;
|
||||
return combined;
|
||||
}
|
||||
Columns operator+( Columns&& lhs, Column&& rhs ) {
|
||||
lhs += CATCH_MOVE( rhs );
|
||||
return CATCH_MOVE( lhs );
|
||||
}
|
||||
|
||||
} // namespace TextFlow
|
||||
} // namespace Catch
|
||||
@@ -8881,11 +8905,10 @@ public:
|
||||
*this << RowBreak();
|
||||
|
||||
TextFlow::Columns headerCols;
|
||||
auto spacer = TextFlow::Spacer(2);
|
||||
for (auto const& info : m_columnInfos) {
|
||||
assert(info.width > 2);
|
||||
headerCols += TextFlow::Column(info.name).width(info.width - 2);
|
||||
headerCols += spacer;
|
||||
headerCols += TextFlow::Spacer( 2 );
|
||||
}
|
||||
m_os << headerCols << '\n';
|
||||
|
||||
|
Reference in New Issue
Block a user