This commit is contained in:
Martin Hořeňovský
2023-12-31 15:15:04 +01:00
parent b7b71ffd3a
commit f981c9cbca
7 changed files with 385 additions and 286 deletions

View File

@@ -6,8 +6,8 @@
// SPDX-License-Identifier: BSL-1.0
// Catch v3.5.0
// Generated: 2023-12-11 00:51:06.770598
// Catch v3.5.1
// Generated: 2023-12-31 15:10:53.044176
// ----------------------------------------------------------
// This file is an amalgamation of multiple different files.
// You probably shouldn't edit it directly.
@@ -690,6 +690,8 @@ namespace Catch {
using size_type = std::size_t;
using const_iterator = const char*;
static constexpr size_type npos{ static_cast<size_type>( -1 ) };
private:
static constexpr char const* const s_empty = "";
@@ -740,7 +742,7 @@ namespace Catch {
}
// Returns a substring of [start, start + length).
// If start + length > size(), then the substring is [start, start + size()).
// If start + length > size(), then the substring is [start, size()).
// If start > size(), then the substring is empty.
constexpr StringRef substr(size_type start, size_type length) const noexcept {
if (start < m_size) {
@@ -1969,12 +1971,12 @@ namespace Catch {
template <typename Clock>
int warmup() {
return run_for_at_least<Clock>(std::chrono::duration_cast<IDuration>(warmup_time), warmup_seed, &resolution<Clock>)
return run_for_at_least<Clock>(warmup_time, warmup_seed, &resolution<Clock>)
.iterations;
}
template <typename Clock>
EnvironmentEstimate estimate_clock_resolution(int iterations) {
auto r = run_for_at_least<Clock>(std::chrono::duration_cast<IDuration>(clock_resolution_estimation_time), iterations, &resolution<Clock>)
auto r = run_for_at_least<Clock>(clock_resolution_estimation_time, iterations, &resolution<Clock>)
.result;
return {
FDuration(mean(r.data(), r.data() + r.size())),
@@ -1996,7 +1998,7 @@ namespace Catch {
};
time_clock(1);
int iters = clock_cost_estimation_iterations;
auto&& r = run_for_at_least<Clock>(std::chrono::duration_cast<IDuration>(clock_cost_estimation_time), iters, time_clock);
auto&& r = run_for_at_least<Clock>(clock_cost_estimation_time, iters, time_clock);
std::vector<double> times;
int nsamples = static_cast<int>(std::ceil(time_limit / r.elapsed));
times.reserve(static_cast<size_t>(nsamples));
@@ -3639,141 +3641,6 @@ namespace Catch {
#define CATCH_REPORTER_SPEC_PARSER_HPP_INCLUDED
#ifndef CATCH_CONSOLE_COLOUR_HPP_INCLUDED
#define CATCH_CONSOLE_COLOUR_HPP_INCLUDED
#include <iosfwd>
#include <cstdint>
namespace Catch {
enum class ColourMode : std::uint8_t;
class IStream;
struct Colour {
enum Code {
None = 0,
White,
Red,
Green,
Blue,
Cyan,
Yellow,
Grey,
Bright = 0x10,
BrightRed = Bright | Red,
BrightGreen = Bright | Green,
LightGrey = Bright | Grey,
BrightWhite = Bright | White,
BrightYellow = Bright | Yellow,
// By intention
FileName = LightGrey,
Warning = BrightYellow,
ResultError = BrightRed,
ResultSuccess = BrightGreen,
ResultExpectedFailure = Warning,
Error = BrightRed,
Success = Green,
Skip = LightGrey,
OriginalExpression = Cyan,
ReconstructedExpression = BrightYellow,
SecondaryText = LightGrey,
Headers = White
};
};
class ColourImpl {
protected:
//! The associated stream of this ColourImpl instance
IStream* m_stream;
public:
ColourImpl( IStream* stream ): m_stream( stream ) {}
//! RAII wrapper around writing specific colour of text using specific
//! colour impl into a stream.
class ColourGuard {
ColourImpl const* m_colourImpl;
Colour::Code m_code;
bool m_engaged = false;
public:
//! Does **not** engage the guard/start the colour
ColourGuard( Colour::Code code,
ColourImpl const* colour );
ColourGuard( ColourGuard const& rhs ) = delete;
ColourGuard& operator=( ColourGuard const& rhs ) = delete;
ColourGuard( ColourGuard&& rhs ) noexcept;
ColourGuard& operator=( ColourGuard&& rhs ) noexcept;
//! Removes colour _if_ the guard was engaged
~ColourGuard();
/**
* Explicitly engages colour for given stream.
*
* The API based on operator<< should be preferred.
*/
ColourGuard& engage( std::ostream& stream ) &;
/**
* Explicitly engages colour for given stream.
*
* The API based on operator<< should be preferred.
*/
ColourGuard&& engage( std::ostream& stream ) &&;
private:
//! Engages the guard and starts using colour
friend std::ostream& operator<<( std::ostream& lhs,
ColourGuard& guard ) {
guard.engageImpl( lhs );
return lhs;
}
//! Engages the guard and starts using colour
friend std::ostream& operator<<( std::ostream& lhs,
ColourGuard&& guard) {
guard.engageImpl( lhs );
return lhs;
}
void engageImpl( std::ostream& stream );
};
virtual ~ColourImpl(); // = default
/**
* Creates a guard object for given colour and this colour impl
*
* **Important:**
* the guard starts disengaged, and has to be engaged explicitly.
*/
ColourGuard guardColour( Colour::Code colourCode );
private:
virtual void use( Colour::Code colourCode ) const = 0;
};
//! Provides ColourImpl based on global config and target compilation platform
Detail::unique_ptr<ColourImpl> makeColourImpl( ColourMode colourSelection,
IStream* stream );
//! Checks if specific colour impl has been compiled into the binary
bool isColourImplAvailable( ColourMode colourSelection );
} // end namespace Catch
#endif // CATCH_CONSOLE_COLOUR_HPP_INCLUDED
#include <map>
#include <string>
#include <vector>
@@ -4387,17 +4254,16 @@ namespace Catch {
enum class TokenType { Option, Argument };
struct Token {
TokenType type;
std::string token;
StringRef token;
};
// Abstracts iterators into args as a stream of tokens, with option
// arguments uniformly handled
class TokenStream {
using Iterator = std::vector<std::string>::const_iterator;
using Iterator = std::vector<StringRef>::const_iterator;
Iterator it;
Iterator itEnd;
std::vector<Token> m_tokenBuffer;
void loadBuffer();
public:
@@ -4449,12 +4315,17 @@ namespace Catch {
ResultType m_type;
};
template <typename T> class ResultValueBase : public ResultBase {
template <typename T>
class ResultValueBase : public ResultBase {
public:
auto value() const -> T const& {
T const& value() const& {
enforceOk();
return m_value;
}
T&& value() && {
enforceOk();
return CATCH_MOVE( m_value );
}
protected:
ResultValueBase( ResultType type ): ResultBase( type ) {}
@@ -4464,13 +4335,23 @@ namespace Catch {
if ( m_type == ResultType::Ok )
new ( &m_value ) T( other.m_value );
}
ResultValueBase( ResultType, T const& value ): ResultBase( ResultType::Ok ) {
new ( &m_value ) T( value );
ResultValueBase( ResultValueBase&& other ):
ResultBase( other ) {
if ( m_type == ResultType::Ok )
new ( &m_value ) T( CATCH_MOVE(other.m_value) );
}
auto operator=( ResultValueBase const& other )
-> ResultValueBase& {
ResultValueBase( ResultType, T const& value ):
ResultBase( ResultType::Ok ) {
new ( &m_value ) T( value );
}
ResultValueBase( ResultType, T&& value ):
ResultBase( ResultType::Ok ) {
new ( &m_value ) T( CATCH_MOVE(value) );
}
ResultValueBase& operator=( ResultValueBase const& other ) {
if ( m_type == ResultType::Ok )
m_value.~T();
ResultBase::operator=( other );
@@ -4478,6 +4359,14 @@ namespace Catch {
new ( &m_value ) T( other.m_value );
return *this;
}
ResultValueBase& operator=( ResultValueBase&& other ) {
if ( m_type == ResultType::Ok ) m_value.~T();
ResultBase::operator=( other );
if ( m_type == ResultType::Ok )
new ( &m_value ) T( CATCH_MOVE(other.m_value) );
return *this;
}
~ResultValueBase() override {
if ( m_type == ResultType::Ok )
@@ -4505,8 +4394,8 @@ namespace Catch {
}
template <typename U>
static auto ok( U const& value ) -> BasicResult {
return { ResultType::Ok, value };
static auto ok( U&& value ) -> BasicResult {
return { ResultType::Ok, CATCH_FORWARD(value) };
}
static auto ok() -> BasicResult { return { ResultType::Ok }; }
static auto logicError( std::string&& message )
@@ -4553,12 +4442,15 @@ namespace Catch {
class ParseState {
public:
ParseState( ParseResultType type,
TokenStream const& remainingTokens );
TokenStream remainingTokens );
ParseResultType type() const { return m_type; }
TokenStream const& remainingTokens() const {
TokenStream const& remainingTokens() const& {
return m_remainingTokens;
}
TokenStream&& remainingTokens() && {
return CATCH_MOVE( m_remainingTokens );
}
private:
ParseResultType m_type;
@@ -4571,7 +4463,7 @@ namespace Catch {
struct HelpColumns {
std::string left;
std::string right;
StringRef descriptions;
};
template <typename T>
@@ -4731,7 +4623,7 @@ namespace Catch {
virtual ~ParserBase() = default;
virtual auto validate() const -> Result { return Result::ok(); }
virtual auto parse( std::string const& exeName,
TokenStream const& tokens ) const
TokenStream tokens ) const
-> InternalParseResult = 0;
virtual size_t cardinality() const;
@@ -4751,8 +4643,8 @@ namespace Catch {
protected:
Optionality m_optionality = Optionality::Optional;
std::shared_ptr<BoundRef> m_ref;
std::string m_hint;
std::string m_description;
StringRef m_hint;
StringRef m_description;
explicit ParserRefImpl( std::shared_ptr<BoundRef> const& ref ):
m_ref( ref ) {}
@@ -4761,28 +4653,32 @@ namespace Catch {
template <typename LambdaT>
ParserRefImpl( accept_many_t,
LambdaT const& ref,
std::string const& hint ):
StringRef hint ):
m_ref( std::make_shared<BoundManyLambda<LambdaT>>( ref ) ),
m_hint( hint ) {}
template <typename T,
typename = typename std::enable_if_t<
!Detail::is_unary_function<T>::value>>
ParserRefImpl( T& ref, std::string const& hint ):
ParserRefImpl( T& ref, StringRef hint ):
m_ref( std::make_shared<BoundValueRef<T>>( ref ) ),
m_hint( hint ) {}
template <typename LambdaT,
typename = typename std::enable_if_t<
Detail::is_unary_function<LambdaT>::value>>
ParserRefImpl( LambdaT const& ref, std::string const& hint ):
ParserRefImpl( LambdaT const& ref, StringRef hint ):
m_ref( std::make_shared<BoundLambda<LambdaT>>( ref ) ),
m_hint( hint ) {}
auto operator()( std::string const& description ) -> DerivedT& {
DerivedT& operator()( StringRef description ) & {
m_description = description;
return static_cast<DerivedT&>( *this );
}
DerivedT&& operator()( StringRef description ) && {
m_description = description;
return static_cast<DerivedT&&>( *this );
}
auto optional() -> DerivedT& {
m_optionality = Optionality::Optional;
@@ -4805,7 +4701,7 @@ namespace Catch {
return 1;
}
std::string const& hint() const { return m_hint; }
StringRef hint() const { return m_hint; }
};
} // namespace detail
@@ -4819,13 +4715,13 @@ namespace Catch {
Detail::InternalParseResult
parse(std::string const&,
Detail::TokenStream const& tokens) const override;
Detail::TokenStream tokens) const override;
};
// A parser for options
class Opt : public Detail::ParserRefImpl<Opt> {
protected:
std::vector<std::string> m_optNames;
std::vector<StringRef> m_optNames;
public:
template <typename LambdaT>
@@ -4838,33 +4734,37 @@ namespace Catch {
template <typename LambdaT,
typename = typename std::enable_if_t<
Detail::is_unary_function<LambdaT>::value>>
Opt( LambdaT const& ref, std::string const& hint ):
Opt( LambdaT const& ref, StringRef hint ):
ParserRefImpl( ref, hint ) {}
template <typename LambdaT>
Opt( accept_many_t, LambdaT const& ref, std::string const& hint ):
Opt( accept_many_t, LambdaT const& ref, StringRef hint ):
ParserRefImpl( accept_many, ref, hint ) {}
template <typename T,
typename = typename std::enable_if_t<
!Detail::is_unary_function<T>::value>>
Opt( T& ref, std::string const& hint ):
Opt( T& ref, StringRef hint ):
ParserRefImpl( ref, hint ) {}
auto operator[](std::string const& optName) -> Opt& {
Opt& operator[]( StringRef optName ) & {
m_optNames.push_back(optName);
return *this;
}
Opt&& operator[]( StringRef optName ) && {
m_optNames.push_back( optName );
return CATCH_MOVE(*this);
}
std::vector<Detail::HelpColumns> getHelpColumns() const;
Detail::HelpColumns getHelpColumns() const;
bool isMatch(std::string const& optToken) const;
bool isMatch(StringRef optToken) const;
using ParserBase::parse;
Detail::InternalParseResult
parse(std::string const&,
Detail::TokenStream const& tokens) const override;
Detail::TokenStream tokens) const override;
Detail::Result validate() const override;
};
@@ -4887,7 +4787,7 @@ namespace Catch {
// handled specially
Detail::InternalParseResult
parse(std::string const&,
Detail::TokenStream const& tokens) const override;
Detail::TokenStream tokens) const override;
std::string const& name() const { return *m_name; }
Detail::ParserResult set(std::string const& newName);
@@ -4912,16 +4812,26 @@ namespace Catch {
return *this;
}
auto operator|=(Opt const& opt) -> Parser& {
m_options.push_back(opt);
return *this;
friend Parser& operator|=( Parser& p, Opt const& opt ) {
p.m_options.push_back( opt );
return p;
}
friend Parser& operator|=( Parser& p, Opt&& opt ) {
p.m_options.push_back( CATCH_MOVE(opt) );
return p;
}
Parser& operator|=(Parser const& other);
template <typename T>
auto operator|(T const& other) const -> Parser {
return Parser(*this) |= other;
friend Parser operator|( Parser const& p, T&& rhs ) {
return Parser( p ) |= CATCH_FORWARD(rhs);
}
template <typename T>
friend Parser operator|( Parser&& p, T&& rhs ) {
p |= CATCH_FORWARD(rhs);
return CATCH_MOVE(p);
}
std::vector<Detail::HelpColumns> getHelpColumns() const;
@@ -4939,21 +4849,23 @@ namespace Catch {
using ParserBase::parse;
Detail::InternalParseResult
parse(std::string const& exeName,
Detail::TokenStream const& tokens) const override;
Detail::TokenStream tokens) const override;
};
// Transport for raw args (copied from main args, or supplied via
// init list for testing)
/**
* Wrapper over argc + argv, assumes that the inputs outlive it
*/
class Args {
friend Detail::TokenStream;
std::string m_exeName;
std::vector<std::string> m_args;
StringRef m_exeName;
std::vector<StringRef> m_args;
public:
Args(int argc, char const* const* argv);
Args(std::initializer_list<std::string> args);
// Helper constructor for testing
Args(std::initializer_list<StringRef> args);
std::string const& exeName() const { return m_exeName; }
StringRef exeName() const { return m_exeName; }
};
@@ -6997,6 +6909,7 @@ namespace Catch {
};
class ITestInvoker;
struct NameAndTags;
enum class TestCaseProperties : uint8_t {
None = 0,
@@ -7233,7 +7146,7 @@ namespace Catch {
#define CATCH_VERSION_MAJOR 3
#define CATCH_VERSION_MINOR 5
#define CATCH_VERSION_PATCH 0
#define CATCH_VERSION_PATCH 1
#endif // CATCH_VERSION_MACROS_HPP_INCLUDED
@@ -8133,12 +8046,12 @@ class uniform_integer_distribution {
using UnsignedIntegerType = Detail::make_unsigned_t<IntegerType>;
// We store the left range bound converted to internal representation,
// because it will be used in computation in the () operator.
// Only the left bound is stored, and we store it converted to its
// unsigned image. This avoids having to do the conversions inside
// the operator(), at the cost of having to do the conversion in
// the a() getter. The right bound is only needed in the b() getter,
// so we recompute it there from other stored data.
UnsignedIntegerType m_a;
// After initialization, right bound is only used for the b() getter,
// so we keep it in the original type.
IntegerType m_b;
// How many different values are there in [a, b]. a == b => 1, can be 0 for distribution over all values in the type.
UnsignedIntegerType m_ab_distance;
@@ -8151,11 +8064,10 @@ class uniform_integer_distribution {
// distribution will be reused many times and this is an optimization.
UnsignedIntegerType m_rejection_threshold = 0;
// Assumes m_b and m_a are already filled
UnsignedIntegerType computeDistance() const {
// This overflows and returns 0 if ua == 0 and ub == TYPE_MAX.
UnsignedIntegerType computeDistance(IntegerType a, IntegerType b) const {
// This overflows and returns 0 if a == 0 and b == TYPE_MAX.
// We handle that later when generating the number.
return transposeTo(m_b) - m_a + 1;
return transposeTo(b) - transposeTo(a) + 1;
}
static UnsignedIntegerType computeRejectionThreshold(UnsignedIntegerType ab_distance) {
@@ -8179,8 +8091,7 @@ public:
uniform_integer_distribution( IntegerType a, IntegerType b ):
m_a( transposeTo(a) ),
m_b( b ),
m_ab_distance( computeDistance() ),
m_ab_distance( computeDistance(a, b) ),
m_rejection_threshold( computeRejectionThreshold(m_ab_distance) ) {
assert( a <= b );
}
@@ -8205,7 +8116,7 @@ public:
}
result_type a() const { return transposeBack(m_a); }
result_type b() const { return m_b; }
result_type b() const { return transposeBack(m_ab_distance + m_a - 1); }
};
} // end namespace Catch
@@ -9065,6 +8976,141 @@ namespace Catch {
#endif // CATCH_CONFIG_UNCAUGHT_EXCEPTIONS_HPP_INCLUDED
#ifndef CATCH_CONSOLE_COLOUR_HPP_INCLUDED
#define CATCH_CONSOLE_COLOUR_HPP_INCLUDED
#include <iosfwd>
#include <cstdint>
namespace Catch {
enum class ColourMode : std::uint8_t;
class IStream;
struct Colour {
enum Code {
None = 0,
White,
Red,
Green,
Blue,
Cyan,
Yellow,
Grey,
Bright = 0x10,
BrightRed = Bright | Red,
BrightGreen = Bright | Green,
LightGrey = Bright | Grey,
BrightWhite = Bright | White,
BrightYellow = Bright | Yellow,
// By intention
FileName = LightGrey,
Warning = BrightYellow,
ResultError = BrightRed,
ResultSuccess = BrightGreen,
ResultExpectedFailure = Warning,
Error = BrightRed,
Success = Green,
Skip = LightGrey,
OriginalExpression = Cyan,
ReconstructedExpression = BrightYellow,
SecondaryText = LightGrey,
Headers = White
};
};
class ColourImpl {
protected:
//! The associated stream of this ColourImpl instance
IStream* m_stream;
public:
ColourImpl( IStream* stream ): m_stream( stream ) {}
//! RAII wrapper around writing specific colour of text using specific
//! colour impl into a stream.
class ColourGuard {
ColourImpl const* m_colourImpl;
Colour::Code m_code;
bool m_engaged = false;
public:
//! Does **not** engage the guard/start the colour
ColourGuard( Colour::Code code,
ColourImpl const* colour );
ColourGuard( ColourGuard const& rhs ) = delete;
ColourGuard& operator=( ColourGuard const& rhs ) = delete;
ColourGuard( ColourGuard&& rhs ) noexcept;
ColourGuard& operator=( ColourGuard&& rhs ) noexcept;
//! Removes colour _if_ the guard was engaged
~ColourGuard();
/**
* Explicitly engages colour for given stream.
*
* The API based on operator<< should be preferred.
*/
ColourGuard& engage( std::ostream& stream ) &;
/**
* Explicitly engages colour for given stream.
*
* The API based on operator<< should be preferred.
*/
ColourGuard&& engage( std::ostream& stream ) &&;
private:
//! Engages the guard and starts using colour
friend std::ostream& operator<<( std::ostream& lhs,
ColourGuard& guard ) {
guard.engageImpl( lhs );
return lhs;
}
//! Engages the guard and starts using colour
friend std::ostream& operator<<( std::ostream& lhs,
ColourGuard&& guard) {
guard.engageImpl( lhs );
return lhs;
}
void engageImpl( std::ostream& stream );
};
virtual ~ColourImpl(); // = default
/**
* Creates a guard object for given colour and this colour impl
*
* **Important:**
* the guard starts disengaged, and has to be engaged explicitly.
*/
ColourGuard guardColour( Colour::Code colourCode );
private:
virtual void use( Colour::Code colourCode ) const = 0;
};
//! Provides ColourImpl based on global config and target compilation platform
Detail::unique_ptr<ColourImpl> makeColourImpl( ColourMode colourSelection,
IStream* stream );
//! Checks if specific colour impl has been compiled into the binary
bool isColourImplAvailable( ColourMode colourSelection );
} // end namespace Catch
#endif // CATCH_CONSOLE_COLOUR_HPP_INCLUDED
#ifndef CATCH_CONSOLE_WIDTH_HPP_INCLUDED
#define CATCH_CONSOLE_WIDTH_HPP_INCLUDED
@@ -9340,7 +9386,6 @@ namespace Catch {
#ifndef CATCH_FATAL_CONDITION_HANDLER_HPP_INCLUDED
#define CATCH_FATAL_CONDITION_HANDLER_HPP_INCLUDED
#include <cassert>
namespace Catch {
@@ -10421,7 +10466,7 @@ namespace Catch {
#ifndef CATCH_SHARDING_HPP_INCLUDED
#define CATCH_SHARDING_HPP_INCLUDED
#include <cassert>
#include <cmath>
#include <algorithm>
@@ -10769,6 +10814,7 @@ namespace Catch {
#ifndef CATCH_TEXTFLOW_HPP_INCLUDED
#define CATCH_TEXTFLOW_HPP_INCLUDED
#include <cassert>
#include <string>
#include <vector>
@@ -10797,7 +10843,7 @@ namespace Catch {
public:
/**
* Iterates "lines" in `Column` and return sthem
* Iterates "lines" in `Column` and returns them
*/
class const_iterator {
friend Column;
@@ -10851,20 +10897,35 @@ namespace Catch {
using iterator = const_iterator;
explicit Column( std::string const& text ): m_string( text ) {}
explicit Column( std::string&& text ):
m_string( CATCH_MOVE(text)) {}
Column& width( size_t newWidth ) {
Column& width( size_t newWidth ) & {
assert( newWidth > 0 );
m_width = newWidth;
return *this;
}
Column& indent( size_t newIndent ) {
Column&& width( size_t newWidth ) && {
assert( newWidth > 0 );
m_width = newWidth;
return CATCH_MOVE( *this );
}
Column& indent( size_t newIndent ) & {
m_indent = newIndent;
return *this;
}
Column& initialIndent( size_t newIndent ) {
Column&& indent( size_t newIndent ) && {
m_indent = newIndent;
return CATCH_MOVE( *this );
}
Column& initialIndent( size_t newIndent ) & {
m_initialIndent = newIndent;
return *this;
}
Column&& initialIndent( size_t newIndent ) && {
m_initialIndent = newIndent;
return CATCH_MOVE( *this );
}
size_t width() const { return m_width; }
const_iterator begin() const { return const_iterator( *this ); }
@@ -10873,7 +10934,8 @@ namespace Catch {
friend std::ostream& operator<<( std::ostream& os,
Column const& col );
Columns operator+( Column const& other );
friend Columns operator+( Column const& lhs, Column const& rhs );
friend Columns operator+( Column&& lhs, Column&& rhs );
};
//! Creates a column that serves as an empty space of specific width
@@ -10917,8 +10979,10 @@ namespace Catch {
iterator begin() const { return iterator( *this ); }
iterator end() const { return { *this, iterator::EndTag() }; }
Columns& operator+=( Column const& col );
Columns operator+( Column const& col );
friend Columns& operator+=( Columns& lhs, Column const& rhs );
friend Columns& operator+=( Columns& lhs, Column&& rhs );
friend Columns operator+( Columns const& lhs, Column const& rhs );
friend Columns operator+( Columns&& lhs, Column&& rhs );
friend std::ostream& operator<<( std::ostream& os,
Columns const& cols );