mirror of
https://github.com/catchorg/Catch2.git
synced 2024-12-23 03:43:28 +01:00
Replace uses of std::move and std::forward with macros
This improves the SelfTest build times by about 3% (measured with Clang 10 on random Linux box I had lying around).
This commit is contained in:
parent
03ce304102
commit
d2ee7100d2
@ -15,7 +15,7 @@
|
||||
#include <catch2/internal/catch_context.hpp>
|
||||
#include <catch2/interfaces/catch_interfaces_reporter.hpp>
|
||||
#include <catch2/internal/catch_unique_name.hpp>
|
||||
|
||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||
#include <catch2/benchmark/catch_chronometer.hpp>
|
||||
#include <catch2/benchmark/catch_clock.hpp>
|
||||
#include <catch2/benchmark/catch_environment.hpp>
|
||||
@ -36,11 +36,11 @@ namespace Catch {
|
||||
namespace Benchmark {
|
||||
struct Benchmark {
|
||||
Benchmark(std::string&& benchmarkName)
|
||||
: name(std::move(benchmarkName)) {}
|
||||
: name(CATCH_MOVE(benchmarkName)) {}
|
||||
|
||||
template <class FUN>
|
||||
Benchmark(std::string&& benchmarkName , FUN &&func)
|
||||
: fun(std::move(func)), name(std::move(benchmarkName)) {}
|
||||
: fun(CATCH_MOVE(func)), name(CATCH_MOVE(benchmarkName)) {}
|
||||
|
||||
template <typename Clock>
|
||||
ExecutionPlan<FloatDuration<Clock>> prepare(const IConfig &cfg, Environment<FloatDuration<Clock>> env) const {
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <catch2/benchmark/catch_optimizer.hpp>
|
||||
#include <catch2/benchmark/detail/catch_complete_invoke.hpp>
|
||||
#include <catch2/internal/catch_meta.hpp>
|
||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||
|
||||
namespace Catch {
|
||||
namespace Benchmark {
|
||||
@ -42,7 +43,7 @@ namespace Catch {
|
||||
struct Chronometer {
|
||||
public:
|
||||
template <typename Fun>
|
||||
void measure(Fun&& fun) { measure(std::forward<Fun>(fun), is_callable<Fun(int)>()); }
|
||||
void measure(Fun&& fun) { measure(CATCH_FORWARD(fun), is_callable<Fun(int)>()); }
|
||||
|
||||
int runs() const { return repeats; }
|
||||
|
||||
|
@ -10,8 +10,9 @@
|
||||
#ifndef CATCH_CONSTRUCTOR_HPP_INCLUDED
|
||||
#define CATCH_CONSTRUCTOR_HPP_INCLUDED
|
||||
|
||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
namespace Catch {
|
||||
namespace Benchmark {
|
||||
@ -30,7 +31,7 @@ namespace Catch {
|
||||
|
||||
ObjectStorage(ObjectStorage&& other)
|
||||
{
|
||||
new(&data) T(std::move(other.stored_object()));
|
||||
new(&data) T(CATCH_MOVE(other.stored_object()));
|
||||
}
|
||||
|
||||
~ObjectStorage() { destruct_on_exit<T>(); }
|
||||
@ -38,7 +39,7 @@ namespace Catch {
|
||||
template <typename... Args>
|
||||
void construct(Args&&... args)
|
||||
{
|
||||
new (&data) T(std::forward<Args>(args)...);
|
||||
new (&data) T(CATCH_FORWARD(args)...);
|
||||
}
|
||||
|
||||
template <bool AllowManualDestruction = !Destruct>
|
||||
|
@ -14,8 +14,9 @@
|
||||
# include <atomic> // atomic_thread_fence
|
||||
#endif
|
||||
|
||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
namespace Catch {
|
||||
namespace Benchmark {
|
||||
@ -57,12 +58,12 @@ namespace Catch {
|
||||
|
||||
template <typename Fn, typename... Args>
|
||||
inline auto invoke_deoptimized(Fn&& fn, Args&&... args) -> typename std::enable_if<!std::is_same<void, decltype(fn(args...))>::value>::type {
|
||||
deoptimize_value(std::forward<Fn>(fn) (std::forward<Args...>(args...)));
|
||||
deoptimize_value(CATCH_FORWARD(fn) (CATCH_FORWARD(args)...));
|
||||
}
|
||||
|
||||
template <typename Fn, typename... Args>
|
||||
inline auto invoke_deoptimized(Fn&& fn, Args&&... args) -> typename std::enable_if<std::is_same<void, decltype(fn(args...))>::value>::type {
|
||||
std::forward<Fn>(fn) (std::forward<Args...>(args...));
|
||||
CATCH_FORWARD(fn) (CATCH_FORWARD(args)...);
|
||||
}
|
||||
} // namespace Benchmark
|
||||
} // namespace Catch
|
||||
|
@ -13,10 +13,10 @@
|
||||
#include <catch2/benchmark/catch_clock.hpp>
|
||||
#include <catch2/benchmark/catch_estimate.hpp>
|
||||
#include <catch2/benchmark/catch_outlier_classification.hpp>
|
||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <iterator>
|
||||
|
||||
namespace Catch {
|
||||
@ -35,7 +35,7 @@ namespace Catch {
|
||||
samples2.reserve(samples.size());
|
||||
std::transform(samples.begin(), samples.end(), std::back_inserter(samples2), [](Duration d) { return Duration2(d); });
|
||||
return {
|
||||
std::move(samples2),
|
||||
CATCH_MOVE(samples2),
|
||||
mean,
|
||||
standard_deviation,
|
||||
outliers,
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include <catch2/benchmark/catch_sample_analysis.hpp>
|
||||
#include <catch2/benchmark/detail/catch_stats.hpp>
|
||||
#include <catch2/interfaces/catch_interfaces_config.hpp>
|
||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
@ -45,7 +46,7 @@ namespace Catch {
|
||||
samples2.reserve(samples.size());
|
||||
std::transform(samples.begin(), samples.end(), std::back_inserter(samples2), [](double d) { return Duration(d); });
|
||||
return {
|
||||
std::move(samples2),
|
||||
CATCH_MOVE(samples2),
|
||||
wrap_estimate(analysis.mean),
|
||||
wrap_estimate(analysis.standard_deviation),
|
||||
outliers,
|
||||
@ -64,7 +65,7 @@ namespace Catch {
|
||||
mean /= i;
|
||||
|
||||
return {
|
||||
std::move(samples),
|
||||
CATCH_MOVE(samples),
|
||||
Estimate<Duration>{mean, mean, mean, 0.0},
|
||||
Estimate<Duration>{Duration(0), Duration(0), Duration(0), 0.0},
|
||||
OutlierClassification{},
|
||||
|
@ -14,8 +14,8 @@
|
||||
#include <catch2/benchmark/detail/catch_complete_invoke.hpp>
|
||||
#include <catch2/internal/catch_meta.hpp>
|
||||
#include <catch2/internal/catch_unique_ptr.hpp>
|
||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||
|
||||
#include <cassert>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
@ -48,7 +48,7 @@ namespace Catch {
|
||||
};
|
||||
template <typename Fun>
|
||||
struct model : public callable {
|
||||
model(Fun&& fun_) : fun(std::move(fun_)) {}
|
||||
model(Fun&& fun_) : fun(CATCH_MOVE(fun_)) {}
|
||||
model(Fun const& fun_) : fun(fun_) {}
|
||||
|
||||
model<Fun>* clone() const override { return new model<Fun>(*this); }
|
||||
@ -78,17 +78,17 @@ namespace Catch {
|
||||
template <typename Fun,
|
||||
typename std::enable_if<!is_related<Fun, BenchmarkFunction>::value, int>::type = 0>
|
||||
BenchmarkFunction(Fun&& fun)
|
||||
: f(new model<typename std::decay<Fun>::type>(std::forward<Fun>(fun))) {}
|
||||
: f(new model<typename std::decay<Fun>::type>(CATCH_FORWARD(fun))) {}
|
||||
|
||||
BenchmarkFunction( BenchmarkFunction&& that ) noexcept:
|
||||
f( std::move( that.f ) ) {}
|
||||
f( CATCH_MOVE( that.f ) ) {}
|
||||
|
||||
BenchmarkFunction(BenchmarkFunction const& that)
|
||||
: f(that.f->clone()) {}
|
||||
|
||||
BenchmarkFunction&
|
||||
operator=( BenchmarkFunction&& that ) noexcept {
|
||||
f = std::move( that.f );
|
||||
f = CATCH_MOVE( that.f );
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <catch2/internal/catch_meta.hpp>
|
||||
#include <catch2/interfaces/catch_interfaces_capture.hpp>
|
||||
#include <catch2/interfaces/catch_interfaces_registry_hub.hpp>
|
||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
@ -33,14 +34,14 @@ namespace Catch {
|
||||
struct CompleteInvoker {
|
||||
template <typename Fun, typename... Args>
|
||||
static Result invoke(Fun&& fun, Args&&... args) {
|
||||
return std::forward<Fun>(fun)(std::forward<Args>(args)...);
|
||||
return CATCH_FORWARD(fun)(CATCH_FORWARD(args)...);
|
||||
}
|
||||
};
|
||||
template <>
|
||||
struct CompleteInvoker<void> {
|
||||
template <typename Fun, typename... Args>
|
||||
static CompleteType_t<void> invoke(Fun&& fun, Args&&... args) {
|
||||
std::forward<Fun>(fun)(std::forward<Args>(args)...);
|
||||
CATCH_FORWARD(fun)(CATCH_FORWARD(args)...);
|
||||
return {};
|
||||
}
|
||||
};
|
||||
@ -48,14 +49,14 @@ namespace Catch {
|
||||
// invoke and not return void :(
|
||||
template <typename Fun, typename... Args>
|
||||
CompleteType_t<FunctionReturnType<Fun, Args...>> complete_invoke(Fun&& fun, Args&&... args) {
|
||||
return CompleteInvoker<FunctionReturnType<Fun, Args...>>::invoke(std::forward<Fun>(fun), std::forward<Args>(args)...);
|
||||
return CompleteInvoker<FunctionReturnType<Fun, Args...>>::invoke(CATCH_FORWARD(fun), CATCH_FORWARD(args)...);
|
||||
}
|
||||
|
||||
} // namespace Detail
|
||||
|
||||
template <typename Fun>
|
||||
Detail::CompleteType_t<FunctionReturnType<Fun>> user_code(Fun&& fun) {
|
||||
return Detail::complete_invoke(std::forward<Fun>(fun));
|
||||
return Detail::complete_invoke(CATCH_FORWARD(fun));
|
||||
}
|
||||
} // namespace Benchmark
|
||||
} // namespace Catch
|
||||
|
@ -13,8 +13,7 @@
|
||||
#include <catch2/benchmark/catch_clock.hpp>
|
||||
#include <catch2/benchmark/detail/catch_complete_invoke.hpp>
|
||||
#include <catch2/benchmark/detail/catch_timing.hpp>
|
||||
|
||||
#include <utility>
|
||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||
|
||||
namespace Catch {
|
||||
namespace Benchmark {
|
||||
@ -22,10 +21,10 @@ namespace Catch {
|
||||
template <typename Clock, typename Fun, typename... Args>
|
||||
TimingOf<Clock, Fun, Args...> measure(Fun&& fun, Args&&... args) {
|
||||
auto start = Clock::now();
|
||||
auto&& r = Detail::complete_invoke(fun, std::forward<Args>(args)...);
|
||||
auto&& r = Detail::complete_invoke(fun, CATCH_FORWARD(args)...);
|
||||
auto end = Clock::now();
|
||||
auto delta = end - start;
|
||||
return { delta, std::forward<decltype(r)>(r), 1 };
|
||||
return { delta, CATCH_FORWARD(r), 1 };
|
||||
}
|
||||
} // namespace Detail
|
||||
} // namespace Benchmark
|
||||
|
@ -11,7 +11,7 @@
|
||||
#define CATCH_REPEAT_HPP_INCLUDED
|
||||
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||
|
||||
namespace Catch {
|
||||
namespace Benchmark {
|
||||
@ -27,7 +27,7 @@ namespace Catch {
|
||||
};
|
||||
template <typename Fun>
|
||||
repeater<typename std::decay<Fun>::type> repeat(Fun&& fun) {
|
||||
return { std::forward<Fun>(fun) };
|
||||
return { CATCH_FORWARD(fun) };
|
||||
}
|
||||
} // namespace Detail
|
||||
} // namespace Benchmark
|
||||
|
@ -16,8 +16,8 @@
|
||||
#include <catch2/benchmark/detail/catch_complete_invoke.hpp>
|
||||
#include <catch2/benchmark/detail/catch_timing.hpp>
|
||||
#include <catch2/internal/catch_meta.hpp>
|
||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||
|
||||
#include <utility>
|
||||
#include <type_traits>
|
||||
|
||||
namespace Catch {
|
||||
@ -32,7 +32,7 @@ namespace Catch {
|
||||
Detail::ChronometerModel<Clock> meter;
|
||||
auto&& result = Detail::complete_invoke(fun, Chronometer(meter, iters));
|
||||
|
||||
return { meter.elapsed(), std::move(result), iters };
|
||||
return { meter.elapsed(), CATCH_MOVE(result), iters };
|
||||
}
|
||||
|
||||
template <typename Clock, typename Fun>
|
||||
@ -52,7 +52,7 @@ namespace Catch {
|
||||
auto&& Timing = measure_one<Clock>(fun, iters, is_callable<Fun(Chronometer)>());
|
||||
|
||||
if (Timing.elapsed >= how_long) {
|
||||
return { Timing.elapsed, std::move(Timing.result), iters };
|
||||
return { Timing.elapsed, CATCH_MOVE(Timing.result), iters };
|
||||
}
|
||||
iters *= 2;
|
||||
}
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <catch2/interfaces/catch_interfaces_capture.hpp>
|
||||
#include <catch2/internal/catch_uncaught_exceptions.hpp>
|
||||
#include <catch2/internal/catch_enforce.hpp>
|
||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||
|
||||
#include <cassert>
|
||||
#include <stack>
|
||||
@ -25,7 +26,7 @@ namespace Catch {
|
||||
}
|
||||
|
||||
ScopedMessage::ScopedMessage( ScopedMessage&& old ) noexcept:
|
||||
m_info( std::move( old.m_info ) ) {
|
||||
m_info( CATCH_MOVE( old.m_info ) ) {
|
||||
old.m_moved = true;
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include <catch2/catch_test_case_info.hpp>
|
||||
#include <catch2/internal/catch_noncopyable.hpp>
|
||||
#include <catch2/interfaces/catch_interfaces_reporter_factory.hpp>
|
||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||
|
||||
namespace Catch {
|
||||
|
||||
@ -48,16 +49,16 @@ namespace Catch {
|
||||
|
||||
public: // IMutableRegistryHub
|
||||
void registerReporter( std::string const& name, IReporterFactoryPtr factory ) override {
|
||||
m_reporterRegistry.registerReporter( name, std::move(factory) );
|
||||
m_reporterRegistry.registerReporter( name, CATCH_MOVE(factory) );
|
||||
}
|
||||
void registerListener( IReporterFactoryPtr factory ) override {
|
||||
m_reporterRegistry.registerListener( std::move(factory) );
|
||||
m_reporterRegistry.registerListener( CATCH_MOVE(factory) );
|
||||
}
|
||||
void registerTest( Detail::unique_ptr<TestCaseInfo>&& testInfo, Detail::unique_ptr<ITestInvoker>&& invoker ) override {
|
||||
m_testCaseRegistry.registerTest( std::move(testInfo), std::move(invoker) );
|
||||
m_testCaseRegistry.registerTest( CATCH_MOVE(testInfo), CATCH_MOVE(invoker) );
|
||||
}
|
||||
void registerTranslator( Detail::unique_ptr<IExceptionTranslator>&& translator ) override {
|
||||
m_exceptionTranslatorRegistry.registerTranslator( std::move(translator) );
|
||||
m_exceptionTranslatorRegistry.registerTranslator( CATCH_MOVE(translator) );
|
||||
}
|
||||
void registerTagAlias( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) override {
|
||||
m_tagAliasRegistry.add( alias, tag, lineInfo );
|
||||
|
@ -23,7 +23,7 @@ namespace Catch {
|
||||
// still use the `-c` flag comfortably.
|
||||
SectionInfo( SourceLineInfo const& _lineInfo, std::string _name,
|
||||
const char* const = nullptr ):
|
||||
name(std::move(_name)),
|
||||
name(CATCH_MOVE(_name)),
|
||||
lineInfo(_lineInfo)
|
||||
{}
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <catch2/reporters/catch_reporter_listening.hpp>
|
||||
#include <catch2/interfaces/catch_interfaces_reporter_registry.hpp>
|
||||
#include <catch2/interfaces/catch_interfaces_reporter_factory.hpp>
|
||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <iomanip>
|
||||
@ -57,7 +58,7 @@ namespace Catch {
|
||||
explicit TestGroup(IStreamingReporterPtr&& reporter, Config const* config):
|
||||
m_reporter(reporter.get()),
|
||||
m_config{config},
|
||||
m_context{config, std::move(reporter)} {
|
||||
m_context{config, CATCH_MOVE(reporter)} {
|
||||
|
||||
auto const& allTestCases = getAllTestCasesSorted(*m_config);
|
||||
m_matches = m_config->testSpec().matchesByFilter(allTestCases, *m_config);
|
||||
@ -277,7 +278,7 @@ namespace Catch {
|
||||
return 0;
|
||||
}
|
||||
|
||||
TestGroup tests { std::move(reporter), m_config.get() };
|
||||
TestGroup tests { CATCH_MOVE(reporter), m_config.get() };
|
||||
auto const totals = tests.execute();
|
||||
|
||||
if( m_config->warnAboutNoTests() && totals.error == -1 )
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <catch2/interfaces/catch_interfaces_generatortracker.hpp>
|
||||
#include <catch2/internal/catch_source_line_info.hpp>
|
||||
#include <catch2/internal/catch_stringref.hpp>
|
||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||
|
||||
#include <vector>
|
||||
#include <tuple>
|
||||
@ -55,7 +56,7 @@ namespace Detail {
|
||||
GeneratorWrapper(IGenerator<T>* generator):
|
||||
m_generator(generator) {}
|
||||
GeneratorWrapper(GeneratorPtr<T> generator):
|
||||
m_generator(std::move(generator)) {}
|
||||
m_generator(CATCH_MOVE(generator)) {}
|
||||
|
||||
T const& get() const {
|
||||
return m_generator->get();
|
||||
@ -74,7 +75,7 @@ namespace Detail {
|
||||
m_value(value)
|
||||
{}
|
||||
SingleValueGenerator(T&& value):
|
||||
m_value(std::move(value))
|
||||
m_value(CATCH_MOVE(value))
|
||||
{}
|
||||
|
||||
T const& get() const override {
|
||||
@ -108,7 +109,7 @@ namespace Detail {
|
||||
GeneratorWrapper<DecayedT> value( T&& value ) {
|
||||
return GeneratorWrapper<DecayedT>(
|
||||
Catch::Detail::make_unique<SingleValueGenerator<DecayedT>>(
|
||||
std::forward<T>( value ) ) );
|
||||
CATCH_FORWARD( value ) ) );
|
||||
}
|
||||
template <typename T>
|
||||
GeneratorWrapper<T> values(std::initializer_list<T> values) {
|
||||
@ -121,35 +122,35 @@ namespace Detail {
|
||||
size_t m_current = 0;
|
||||
|
||||
void add_generator( GeneratorWrapper<T>&& generator ) {
|
||||
m_generators.emplace_back( std::move( generator ) );
|
||||
m_generators.emplace_back( CATCH_MOVE( generator ) );
|
||||
}
|
||||
void add_generator( T const& val ) {
|
||||
m_generators.emplace_back( value( val ) );
|
||||
}
|
||||
void add_generator( T&& val ) {
|
||||
m_generators.emplace_back( value( std::move( val ) ) );
|
||||
m_generators.emplace_back( value( CATCH_MOVE( val ) ) );
|
||||
}
|
||||
template <typename U>
|
||||
std::enable_if_t<!std::is_same<std::decay_t<U>, T>::value>
|
||||
add_generator( U&& val ) {
|
||||
add_generator( T( std::forward<U>( val ) ) );
|
||||
add_generator( T( CATCH_FORWARD( val ) ) );
|
||||
}
|
||||
|
||||
template <typename U> void add_generators( U&& valueOrGenerator ) {
|
||||
add_generator( std::forward<U>( valueOrGenerator ) );
|
||||
add_generator( CATCH_FORWARD( valueOrGenerator ) );
|
||||
}
|
||||
|
||||
template <typename U, typename... Gs>
|
||||
void add_generators( U&& valueOrGenerator, Gs&&... moreGenerators ) {
|
||||
add_generator( std::forward<U>( valueOrGenerator ) );
|
||||
add_generators( std::forward<Gs>( moreGenerators )... );
|
||||
add_generator( CATCH_FORWARD( valueOrGenerator ) );
|
||||
add_generators( CATCH_FORWARD( moreGenerators )... );
|
||||
}
|
||||
|
||||
public:
|
||||
template <typename... Gs>
|
||||
Generators(Gs &&... moreGenerators) {
|
||||
m_generators.reserve(sizeof...(Gs));
|
||||
add_generators(std::forward<Gs>(moreGenerators)...);
|
||||
add_generators(CATCH_FORWARD(moreGenerators)...);
|
||||
}
|
||||
|
||||
T const& get() const override {
|
||||
@ -181,19 +182,19 @@ namespace Detail {
|
||||
|
||||
template<typename T, typename... Gs>
|
||||
auto makeGenerators( GeneratorWrapper<T>&& generator, Gs &&... moreGenerators ) -> Generators<T> {
|
||||
return Generators<T>(std::move(generator), std::forward<Gs>(moreGenerators)...);
|
||||
return Generators<T>(CATCH_MOVE(generator), CATCH_FORWARD(moreGenerators)...);
|
||||
}
|
||||
template<typename T>
|
||||
auto makeGenerators( GeneratorWrapper<T>&& generator ) -> Generators<T> {
|
||||
return Generators<T>(std::move(generator));
|
||||
return Generators<T>(CATCH_MOVE(generator));
|
||||
}
|
||||
template<typename T, typename... Gs>
|
||||
auto makeGenerators( T&& val, Gs &&... moreGenerators ) -> Generators<std::decay_t<T>> {
|
||||
return makeGenerators( value( std::forward<T>( val ) ), std::forward<Gs>( moreGenerators )... );
|
||||
return makeGenerators( value( CATCH_FORWARD( val ) ), CATCH_FORWARD( moreGenerators )... );
|
||||
}
|
||||
template<typename T, typename U, typename... Gs>
|
||||
auto makeGenerators( as<T>, U&& val, Gs &&... moreGenerators ) -> Generators<T> {
|
||||
return makeGenerators( value( T( std::forward<U>( val ) ) ), std::forward<Gs>( moreGenerators )... );
|
||||
return makeGenerators( value( T( CATCH_FORWARD( val ) ) ), CATCH_FORWARD( moreGenerators )... );
|
||||
}
|
||||
|
||||
auto acquireGeneratorTracker( StringRef generatorName, SourceLineInfo const& lineInfo ) -> IGeneratorTracker&;
|
||||
|
@ -10,6 +10,9 @@
|
||||
|
||||
#include <catch2/generators/catch_generators.hpp>
|
||||
#include <catch2/internal/catch_meta.hpp>
|
||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||
|
||||
#include <cassert>
|
||||
|
||||
namespace Catch {
|
||||
namespace Generators {
|
||||
@ -21,7 +24,7 @@ namespace Generators {
|
||||
size_t m_target;
|
||||
public:
|
||||
TakeGenerator(size_t target, GeneratorWrapper<T>&& generator):
|
||||
m_generator(std::move(generator)),
|
||||
m_generator(CATCH_MOVE(generator)),
|
||||
m_target(target)
|
||||
{
|
||||
assert(target != 0 && "Empty generators are not allowed");
|
||||
@ -47,7 +50,7 @@ namespace Generators {
|
||||
|
||||
template <typename T>
|
||||
GeneratorWrapper<T> take(size_t target, GeneratorWrapper<T>&& generator) {
|
||||
return GeneratorWrapper<T>(Catch::Detail::make_unique<TakeGenerator<T>>(target, std::move(generator)));
|
||||
return GeneratorWrapper<T>(Catch::Detail::make_unique<TakeGenerator<T>>(target, CATCH_MOVE(generator)));
|
||||
}
|
||||
|
||||
|
||||
@ -58,8 +61,8 @@ namespace Generators {
|
||||
public:
|
||||
template <typename P = Predicate>
|
||||
FilterGenerator(P&& pred, GeneratorWrapper<T>&& generator):
|
||||
m_generator(std::move(generator)),
|
||||
m_predicate(std::forward<P>(pred))
|
||||
m_generator(CATCH_MOVE(generator)),
|
||||
m_predicate(CATCH_FORWARD(pred))
|
||||
{
|
||||
if (!m_predicate(m_generator.get())) {
|
||||
// It might happen that there are no values that pass the
|
||||
@ -88,7 +91,7 @@ namespace Generators {
|
||||
|
||||
template <typename T, typename Predicate>
|
||||
GeneratorWrapper<T> filter(Predicate&& pred, GeneratorWrapper<T>&& generator) {
|
||||
return GeneratorWrapper<T>(Catch::Detail::make_unique<FilterGenerator<T, Predicate>>(std::forward<Predicate>(pred), std::move(generator)));
|
||||
return GeneratorWrapper<T>(Catch::Detail::make_unique<FilterGenerator<T, Predicate>>(CATCH_FORWARD(pred), CATCH_MOVE(generator)));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@ -103,7 +106,7 @@ namespace Generators {
|
||||
size_t m_repeat_index = 0;
|
||||
public:
|
||||
RepeatGenerator(size_t repeats, GeneratorWrapper<T>&& generator):
|
||||
m_generator(std::move(generator)),
|
||||
m_generator(CATCH_MOVE(generator)),
|
||||
m_target_repeats(repeats)
|
||||
{
|
||||
assert(m_target_repeats > 0 && "Repeat generator must repeat at least once");
|
||||
@ -144,7 +147,7 @@ namespace Generators {
|
||||
|
||||
template <typename T>
|
||||
GeneratorWrapper<T> repeat(size_t repeats, GeneratorWrapper<T>&& generator) {
|
||||
return GeneratorWrapper<T>(Catch::Detail::make_unique<RepeatGenerator<T>>(repeats, std::move(generator)));
|
||||
return GeneratorWrapper<T>(Catch::Detail::make_unique<RepeatGenerator<T>>(repeats, CATCH_MOVE(generator)));
|
||||
}
|
||||
|
||||
template <typename T, typename U, typename Func>
|
||||
@ -157,8 +160,8 @@ namespace Generators {
|
||||
public:
|
||||
template <typename F2 = Func>
|
||||
MapGenerator(F2&& function, GeneratorWrapper<U>&& generator) :
|
||||
m_generator(std::move(generator)),
|
||||
m_function(std::forward<F2>(function)),
|
||||
m_generator(CATCH_MOVE(generator)),
|
||||
m_function(CATCH_FORWARD(function)),
|
||||
m_cache(m_function(m_generator.get()))
|
||||
{}
|
||||
|
||||
@ -177,14 +180,14 @@ namespace Generators {
|
||||
template <typename Func, typename U, typename T = FunctionReturnType<Func, U>>
|
||||
GeneratorWrapper<T> map(Func&& function, GeneratorWrapper<U>&& generator) {
|
||||
return GeneratorWrapper<T>(
|
||||
Catch::Detail::make_unique<MapGenerator<T, U, Func>>(std::forward<Func>(function), std::move(generator))
|
||||
Catch::Detail::make_unique<MapGenerator<T, U, Func>>(CATCH_FORWARD(function), CATCH_MOVE(generator))
|
||||
);
|
||||
}
|
||||
|
||||
template <typename T, typename U, typename Func>
|
||||
GeneratorWrapper<T> map(Func&& function, GeneratorWrapper<U>&& generator) {
|
||||
return GeneratorWrapper<T>(
|
||||
Catch::Detail::make_unique<MapGenerator<T, U, Func>>(std::forward<Func>(function), std::move(generator))
|
||||
Catch::Detail::make_unique<MapGenerator<T, U, Func>>(CATCH_FORWARD(function), CATCH_MOVE(generator))
|
||||
);
|
||||
}
|
||||
|
||||
@ -196,7 +199,7 @@ namespace Generators {
|
||||
bool m_used_up = false;
|
||||
public:
|
||||
ChunkGenerator(size_t size, GeneratorWrapper<T> generator) :
|
||||
m_chunk_size(size), m_generator(std::move(generator))
|
||||
m_chunk_size(size), m_generator(CATCH_MOVE(generator))
|
||||
{
|
||||
m_chunk.reserve(m_chunk_size);
|
||||
if (m_chunk_size != 0) {
|
||||
@ -227,7 +230,7 @@ namespace Generators {
|
||||
template <typename T>
|
||||
GeneratorWrapper<std::vector<T>> chunk(size_t size, GeneratorWrapper<T>&& generator) {
|
||||
return GeneratorWrapper<std::vector<T>>(
|
||||
Catch::Detail::make_unique<ChunkGenerator<T>>(size, std::move(generator))
|
||||
Catch::Detail::make_unique<ChunkGenerator<T>>(size, CATCH_MOVE(generator))
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include <catch2/internal/catch_message_info.hpp>
|
||||
#include <catch2/internal/catch_stringref.hpp>
|
||||
#include <catch2/internal/catch_unique_ptr.hpp>
|
||||
|
||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||
#include <catch2/benchmark/catch_estimate.hpp>
|
||||
#include <catch2/benchmark/catch_outlier_classification.hpp>
|
||||
|
||||
@ -150,7 +150,7 @@ namespace Catch {
|
||||
}
|
||||
return {
|
||||
info,
|
||||
std::move(samples2),
|
||||
CATCH_MOVE(samples2),
|
||||
mean,
|
||||
standardDeviation,
|
||||
outliers,
|
||||
|
@ -30,11 +30,11 @@
|
||||
#endif
|
||||
|
||||
#include <catch2/internal/catch_noncopyable.hpp>
|
||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||
|
||||
#include <cassert>
|
||||
#include <cctype>
|
||||
#include <memory>
|
||||
#include <ostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@ -293,7 +293,7 @@ namespace Catch {
|
||||
T temp;
|
||||
auto result = convertInto( source, temp );
|
||||
if ( result )
|
||||
target = std::move( temp );
|
||||
target = CATCH_MOVE( temp );
|
||||
return result;
|
||||
}
|
||||
#endif // CLARA_CONFIG_OPTIONAL_TYPE
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <catch2/internal/catch_compiler_capabilities.hpp>
|
||||
#include <catch2/internal/catch_enforce.hpp>
|
||||
#include <catch2/internal/catch_test_failure_exception.hpp>
|
||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||
|
||||
namespace Catch {
|
||||
|
||||
@ -16,7 +17,7 @@ namespace Catch {
|
||||
}
|
||||
|
||||
void ExceptionTranslatorRegistry::registerTranslator( Detail::unique_ptr<IExceptionTranslator>&& translator ) {
|
||||
m_translators.push_back( std::move( translator ) );
|
||||
m_translators.push_back( CATCH_MOVE( translator ) );
|
||||
}
|
||||
|
||||
#if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS)
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include <catch2/interfaces/catch_interfaces_reporter_registry.hpp>
|
||||
#include <catch2/interfaces/catch_interfaces_testcase.hpp>
|
||||
#include <catch2/interfaces/catch_interfaces_reporter_factory.hpp>
|
||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||
|
||||
#include <catch2/internal/catch_context.hpp>
|
||||
#include <catch2/catch_config.hpp>
|
||||
@ -43,7 +44,7 @@ namespace Catch {
|
||||
|
||||
std::vector<TagInfo> infos; infos.reserve(tagCounts.size());
|
||||
for (auto& tagc : tagCounts) {
|
||||
infos.push_back(std::move(tagc.second));
|
||||
infos.push_back(CATCH_MOVE(tagc.second));
|
||||
}
|
||||
|
||||
reporter.listTags(infos);
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include <catch2/reporters/catch_reporter_tap.hpp>
|
||||
#include <catch2/reporters/catch_reporter_teamcity.hpp>
|
||||
#include <catch2/reporters/catch_reporter_xml.hpp>
|
||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||
|
||||
namespace Catch {
|
||||
|
||||
@ -43,10 +44,10 @@ namespace Catch {
|
||||
}
|
||||
|
||||
void ReporterRegistry::registerReporter( std::string const& name, IReporterFactoryPtr factory ) {
|
||||
m_factories.emplace(name, std::move(factory));
|
||||
m_factories.emplace(name, CATCH_MOVE(factory));
|
||||
}
|
||||
void ReporterRegistry::registerListener( IReporterFactoryPtr factory ) {
|
||||
m_listeners.push_back( std::move(factory) );
|
||||
m_listeners.push_back( CATCH_MOVE(factory) );
|
||||
}
|
||||
|
||||
IReporterRegistry::FactoryMap const& ReporterRegistry::getFactories() const {
|
||||
|
@ -64,7 +64,7 @@ namespace Catch {
|
||||
Catch::Detail::make_unique<GeneratorTracker>(
|
||||
nameAndLocation, ctx, ¤tTracker );
|
||||
tracker = newTracker.get();
|
||||
currentTracker.addChild( std::move(newTracker) );
|
||||
currentTracker.addChild( CATCH_MOVE(newTracker) );
|
||||
}
|
||||
|
||||
if( !tracker->isComplete() ) {
|
||||
@ -153,7 +153,7 @@ namespace Catch {
|
||||
return m_generator;
|
||||
}
|
||||
void setGenerator( GeneratorBasePtr&& generator ) override {
|
||||
m_generator = std::move( generator );
|
||||
m_generator = CATCH_MOVE( generator );
|
||||
}
|
||||
};
|
||||
GeneratorTracker::~GeneratorTracker() = default;
|
||||
@ -163,7 +163,7 @@ namespace Catch {
|
||||
: m_runInfo(_config->name()),
|
||||
m_context(getCurrentMutableContext()),
|
||||
m_config(_config),
|
||||
m_reporter(std::move(reporter)),
|
||||
m_reporter(CATCH_MOVE(reporter)),
|
||||
m_lastAssertionInfo{ StringRef(), SourceLineInfo("",0), StringRef(), ResultDisposition::Normal },
|
||||
m_includeSuccessfulResults( m_config->includeSuccessfulResults() || m_reporter->getPreferences().shouldReportAllAssertions )
|
||||
{
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <catch2/catch_assertion_info.hpp>
|
||||
#include <catch2/catch_assertion_result.hpp>
|
||||
#include <catch2/internal/catch_option.hpp>
|
||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
|
@ -6,15 +6,16 @@
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
#include <catch2/internal/catch_section.hpp>
|
||||
#include <catch2/internal/catch_test_macro_impl.hpp>
|
||||
#include <catch2/internal/catch_run_context.hpp>
|
||||
#include <catch2/internal/catch_uncaught_exceptions.hpp>
|
||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace Catch {
|
||||
|
||||
Section::Section( SectionInfo&& info ):
|
||||
m_info( std::move( info ) ),
|
||||
m_info( CATCH_MOVE( info ) ),
|
||||
m_sectionIncluded(
|
||||
getResultCapture().sectionStarted( m_info, m_assertions ) ) {
|
||||
// Non-"included" sections will not use the timing information
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <catch2/internal/catch_run_context.hpp>
|
||||
#include <catch2/catch_test_case_info.hpp>
|
||||
#include <catch2/catch_test_spec.hpp>
|
||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
@ -119,8 +120,8 @@ namespace {
|
||||
void TestRegistry::registerTest(Detail::unique_ptr<TestCaseInfo> testInfo, Detail::unique_ptr<ITestInvoker> testInvoker) {
|
||||
m_handles.emplace_back(testInfo.get(), testInvoker.get());
|
||||
m_viewed_test_infos.push_back(testInfo.get());
|
||||
m_owned_test_infos.push_back(std::move(testInfo));
|
||||
m_invokers.push_back(std::move(testInvoker));
|
||||
m_owned_test_infos.push_back(CATCH_MOVE(testInfo));
|
||||
m_invokers.push_back(CATCH_MOVE(testInvoker));
|
||||
}
|
||||
|
||||
std::vector<TestCaseInfo*> const& TestRegistry::getAllInfos() const {
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include <catch2/internal/catch_enforce.hpp>
|
||||
#include <catch2/internal/catch_string_manip.hpp>
|
||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
@ -34,7 +35,7 @@ namespace TestCaseTracking {
|
||||
}
|
||||
|
||||
void ITracker::addChild( ITrackerPtr&& child ) {
|
||||
m_children.push_back( std::move(child) );
|
||||
m_children.push_back( CATCH_MOVE(child) );
|
||||
}
|
||||
|
||||
ITracker* ITracker::findChild( NameAndLocation const& nameAndLocation ) {
|
||||
@ -207,7 +208,7 @@ namespace TestCaseTracking {
|
||||
auto newSection = Catch::Detail::make_unique<SectionTracker>(
|
||||
nameAndLocation, ctx, ¤tTracker );
|
||||
section = newSection.get();
|
||||
currentTracker.addChild( std::move( newSection ) );
|
||||
currentTracker.addChild( CATCH_MOVE( newSection ) );
|
||||
}
|
||||
if( !ctx.completedCycle() )
|
||||
section->tryOpen();
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <catch2/internal/catch_test_case_registry_impl.hpp>
|
||||
#include <catch2/interfaces/catch_interfaces_registry_hub.hpp>
|
||||
#include <catch2/internal/catch_string_manip.hpp>
|
||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||
|
||||
namespace Catch {
|
||||
|
||||
@ -42,7 +43,7 @@ namespace Catch {
|
||||
extractClassName( classOrMethod ),
|
||||
nameAndTags,
|
||||
lineInfo),
|
||||
std::move(invoker)
|
||||
CATCH_MOVE(invoker)
|
||||
);
|
||||
} CATCH_CATCH_ALL {
|
||||
// Do not throw when constructing global objects, instead register the exception to be processed later
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include <catch2/internal/catch_string_manip.hpp>
|
||||
#include <catch2/interfaces/catch_interfaces_tag_alias_registry.hpp>
|
||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||
|
||||
|
||||
namespace Catch {
|
||||
@ -35,7 +36,7 @@ namespace Catch {
|
||||
}
|
||||
TestSpec TestSpecParser::testSpec() {
|
||||
addFilter();
|
||||
return std::move(m_testSpec);
|
||||
return CATCH_MOVE(m_testSpec);
|
||||
}
|
||||
bool TestSpecParser::visitChar( char c ) {
|
||||
if( (m_mode != EscapedName) && (c == '\\') ) {
|
||||
@ -151,7 +152,7 @@ namespace Catch {
|
||||
|
||||
void TestSpecParser::addFilter() {
|
||||
if( !m_currentFilter.m_required.empty() || !m_currentFilter.m_forbidden.empty() ) {
|
||||
m_testSpec.m_filters.push_back( std::move(m_currentFilter) );
|
||||
m_testSpec.m_filters.push_back( CATCH_MOVE(m_currentFilter) );
|
||||
m_currentFilter = TestSpec::Filter();
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@
|
||||
#define CATCH_MATCHERS_HPP_INCLUDED
|
||||
|
||||
#include <catch2/matchers/internal/catch_matchers_impl.hpp>
|
||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@ -87,11 +88,11 @@ namespace Matchers {
|
||||
|
||||
friend MatchAllOf operator&& (MatchAllOf&& lhs, MatcherBase<ArgT> const& rhs) {
|
||||
lhs.m_matchers.push_back(&rhs);
|
||||
return std::move(lhs);
|
||||
return CATCH_MOVE(lhs);
|
||||
}
|
||||
friend MatchAllOf operator&& (MatcherBase<ArgT> const& lhs, MatchAllOf&& rhs) {
|
||||
rhs.m_matchers.insert(rhs.m_matchers.begin(), &lhs);
|
||||
return std::move(rhs);
|
||||
return CATCH_MOVE(rhs);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -140,11 +141,11 @@ namespace Matchers {
|
||||
|
||||
friend MatchAnyOf operator|| (MatchAnyOf&& lhs, MatcherBase<ArgT> const& rhs) {
|
||||
lhs.m_matchers.push_back(&rhs);
|
||||
return std::move(lhs);
|
||||
return CATCH_MOVE(lhs);
|
||||
}
|
||||
friend MatchAnyOf operator|| (MatcherBase<ArgT> const& lhs, MatchAnyOf&& rhs) {
|
||||
rhs.m_matchers.insert(rhs.m_matchers.begin(), &lhs);
|
||||
return std::move(rhs);
|
||||
return CATCH_MOVE(rhs);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include <catch2/matchers/catch_matchers_templated.hpp>
|
||||
#include <catch2/internal/catch_container_nonmembers.hpp>
|
||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||
|
||||
namespace Catch {
|
||||
namespace Matchers {
|
||||
@ -55,7 +56,7 @@ namespace Catch {
|
||||
Matcher m_matcher;
|
||||
public:
|
||||
explicit SizeMatchesMatcher(Matcher m):
|
||||
m_matcher(std::move(m))
|
||||
m_matcher(CATCH_MOVE(m))
|
||||
{}
|
||||
|
||||
template <typename RangeLike>
|
||||
@ -81,7 +82,7 @@ namespace Catch {
|
||||
template <typename Matcher>
|
||||
std::enable_if_t<Detail::is_matcher<Matcher>::value,
|
||||
SizeMatchesMatcher<Matcher>> SizeIs(Matcher&& m) {
|
||||
return SizeMatchesMatcher<Matcher>{std::forward<Matcher>(m)};
|
||||
return SizeMatchesMatcher<Matcher>{CATCH_FORWARD(m)};
|
||||
}
|
||||
|
||||
} // end namespace Matchers
|
||||
|
@ -9,6 +9,7 @@
|
||||
#define CATCH_MATCHERS_CONTAINS_HPP_INCLUDED
|
||||
|
||||
#include <catch2/matchers/catch_matchers_templated.hpp>
|
||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
@ -24,8 +25,8 @@ namespace Catch {
|
||||
public:
|
||||
template <typename T2, typename Equality2>
|
||||
ContainsElementMatcher(T2&& target, Equality2&& predicate):
|
||||
m_desired(std::forward<T2>(target)),
|
||||
m_eq(std::forward<Equality2>(predicate))
|
||||
m_desired(CATCH_FORWARD(target)),
|
||||
m_eq(CATCH_FORWARD(predicate))
|
||||
{}
|
||||
|
||||
std::string describe() const override {
|
||||
@ -52,7 +53,7 @@ namespace Catch {
|
||||
// constructor (and also avoid some perfect forwarding failure
|
||||
// cases)
|
||||
ContainsMatcherMatcher(Matcher matcher):
|
||||
m_matcher(std::move(matcher))
|
||||
m_matcher(CATCH_MOVE(matcher))
|
||||
{}
|
||||
|
||||
template <typename RangeLike>
|
||||
@ -78,14 +79,14 @@ namespace Catch {
|
||||
template <typename T>
|
||||
std::enable_if_t<!Detail::is_matcher<T>::value,
|
||||
ContainsElementMatcher<T, std::equal_to<>>> Contains(T&& elem) {
|
||||
return { std::forward<T>(elem), std::equal_to<>{} };
|
||||
return { CATCH_FORWARD(elem), std::equal_to<>{} };
|
||||
}
|
||||
|
||||
//! Creates a matcher that checks whether a range contains element matching a matcher
|
||||
template <typename Matcher>
|
||||
std::enable_if_t<Detail::is_matcher<Matcher>::value,
|
||||
ContainsMatcherMatcher<Matcher>> Contains(Matcher&& matcher) {
|
||||
return { std::forward<Matcher>(matcher) };
|
||||
return { CATCH_FORWARD(matcher) };
|
||||
}
|
||||
|
||||
/**
|
||||
@ -95,7 +96,7 @@ namespace Catch {
|
||||
*/
|
||||
template <typename T, typename Equality>
|
||||
ContainsElementMatcher<T, Equality> Contains(T&& elem, Equality&& eq) {
|
||||
return { std::forward<T>(elem), std::forward<Equality>(eq) };
|
||||
return { CATCH_FORWARD(elem), CATCH_FORWARD(eq) };
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,9 +10,9 @@
|
||||
|
||||
#include <catch2/matchers/catch_matchers.hpp>
|
||||
#include <catch2/internal/catch_meta.hpp>
|
||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace Catch {
|
||||
namespace Matchers {
|
||||
@ -28,7 +28,7 @@ class PredicateMatcher final : public MatcherBase<T> {
|
||||
public:
|
||||
|
||||
PredicateMatcher(Predicate&& elem, std::string const& descr)
|
||||
:m_predicate(std::forward<Predicate>(elem)),
|
||||
:m_predicate(CATCH_FORWARD(elem)),
|
||||
m_description(Detail::finalizeDescription(descr))
|
||||
{}
|
||||
|
||||
@ -50,7 +50,7 @@ public:
|
||||
PredicateMatcher<T, Pred> Predicate(Pred&& predicate, std::string const& description = "") {
|
||||
static_assert(is_callable<Pred(T)>::value, "Predicate not callable with argument T");
|
||||
static_assert(std::is_same<bool, FunctionReturnType<Pred, T>>::value, "Predicate does not return bool");
|
||||
return PredicateMatcher<T, Pred>(std::forward<Pred>(predicate), description);
|
||||
return PredicateMatcher<T, Pred>(CATCH_FORWARD(predicate), description);
|
||||
}
|
||||
|
||||
} // namespace Matchers
|
||||
|
@ -9,8 +9,7 @@
|
||||
#define CATCH_MATCHERS_QUANTIFIERS_HPP_INCLUDED
|
||||
|
||||
#include <catch2/matchers/catch_matchers_templated.hpp>
|
||||
|
||||
#include <utility>
|
||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||
|
||||
namespace Catch {
|
||||
namespace Matchers {
|
||||
@ -20,7 +19,7 @@ namespace Catch {
|
||||
Matcher m_matcher;
|
||||
public:
|
||||
AllMatchMatcher(Matcher matcher):
|
||||
m_matcher(std::move(matcher))
|
||||
m_matcher(CATCH_MOVE(matcher))
|
||||
{}
|
||||
|
||||
std::string describe() const override {
|
||||
@ -44,7 +43,7 @@ namespace Catch {
|
||||
Matcher m_matcher;
|
||||
public:
|
||||
NoneMatchMatcher(Matcher matcher):
|
||||
m_matcher(std::move(matcher))
|
||||
m_matcher(CATCH_MOVE(matcher))
|
||||
{}
|
||||
|
||||
std::string describe() const override {
|
||||
@ -68,7 +67,7 @@ namespace Catch {
|
||||
Matcher m_matcher;
|
||||
public:
|
||||
AnyMatchMatcher(Matcher matcher):
|
||||
m_matcher(std::move(matcher))
|
||||
m_matcher(CATCH_MOVE(matcher))
|
||||
{}
|
||||
|
||||
std::string describe() const override {
|
||||
@ -89,19 +88,19 @@ namespace Catch {
|
||||
// Creates a matcher that checks whether a range contains element matching a matcher
|
||||
template <typename Matcher>
|
||||
AllMatchMatcher<Matcher> AllMatch(Matcher&& matcher) {
|
||||
return { std::forward<Matcher>(matcher) };
|
||||
return { CATCH_FORWARD(matcher) };
|
||||
}
|
||||
|
||||
// Creates a matcher that checks whether no element in a range matches a matcher.
|
||||
template <typename Matcher>
|
||||
NoneMatchMatcher<Matcher> NoneMatch(Matcher&& matcher) {
|
||||
return { std::forward<Matcher>(matcher) };
|
||||
return { CATCH_FORWARD(matcher) };
|
||||
}
|
||||
|
||||
// Creates a matcher that checks whether any element in a range matches a matcher.
|
||||
template <typename Matcher>
|
||||
AnyMatchMatcher<Matcher> AnyMatch(Matcher&& matcher) {
|
||||
return { std::forward<Matcher>(matcher) };
|
||||
return { CATCH_FORWARD(matcher) };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <catch2/matchers/catch_matchers_string.hpp>
|
||||
#include <catch2/internal/catch_string_manip.hpp>
|
||||
#include <catch2/catch_tostring.hpp>
|
||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||
|
||||
#include <regex>
|
||||
|
||||
@ -76,7 +77,7 @@ namespace Matchers {
|
||||
|
||||
|
||||
|
||||
RegexMatcher::RegexMatcher(std::string regex, CaseSensitive caseSensitivity): m_regex(std::move(regex)), m_caseSensitivity(caseSensitivity) {}
|
||||
RegexMatcher::RegexMatcher(std::string regex, CaseSensitive caseSensitivity): m_regex(CATCH_MOVE(regex)), m_caseSensitivity(caseSensitivity) {}
|
||||
|
||||
bool RegexMatcher::match(std::string const& matchee) const {
|
||||
auto flags = std::regex::ECMAScript; // ECMAScript is the default syntax option anyway
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include <catch2/matchers/catch_matchers.hpp>
|
||||
#include <catch2/internal/catch_stringref.hpp>
|
||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||
|
||||
#include <array>
|
||||
#include <algorithm>
|
||||
@ -145,7 +146,7 @@ namespace Matchers {
|
||||
MatchAllOfGeneric<MatcherTs..., MatchersRHS...> operator && (
|
||||
MatchAllOfGeneric<MatcherTs...>&& lhs,
|
||||
MatchAllOfGeneric<MatchersRHS...>&& rhs) {
|
||||
return MatchAllOfGeneric<MatcherTs..., MatchersRHS...>{array_cat(std::move(lhs.m_matchers), std::move(rhs.m_matchers))};
|
||||
return MatchAllOfGeneric<MatcherTs..., MatchersRHS...>{array_cat(CATCH_MOVE(lhs.m_matchers), CATCH_MOVE(rhs.m_matchers))};
|
||||
}
|
||||
|
||||
//! Avoids type nesting for `GenericAllOf && some matcher` case
|
||||
@ -154,7 +155,7 @@ namespace Matchers {
|
||||
MatchAllOfGeneric<MatcherTs..., MatcherRHS>> operator && (
|
||||
MatchAllOfGeneric<MatcherTs...>&& lhs,
|
||||
MatcherRHS const& rhs) {
|
||||
return MatchAllOfGeneric<MatcherTs..., MatcherRHS>{array_cat(std::move(lhs.m_matchers), static_cast<void const*>(&rhs))};
|
||||
return MatchAllOfGeneric<MatcherTs..., MatcherRHS>{array_cat(CATCH_MOVE(lhs.m_matchers), static_cast<void const*>(&rhs))};
|
||||
}
|
||||
|
||||
//! Avoids type nesting for `some matcher && GenericAllOf` case
|
||||
@ -163,7 +164,7 @@ namespace Matchers {
|
||||
MatchAllOfGeneric<MatcherLHS, MatcherTs...>> operator && (
|
||||
MatcherLHS const& lhs,
|
||||
MatchAllOfGeneric<MatcherTs...>&& rhs) {
|
||||
return MatchAllOfGeneric<MatcherLHS, MatcherTs...>{array_cat(static_cast<void const*>(std::addressof(lhs)), std::move(rhs.m_matchers))};
|
||||
return MatchAllOfGeneric<MatcherLHS, MatcherTs...>{array_cat(static_cast<void const*>(std::addressof(lhs)), CATCH_MOVE(rhs.m_matchers))};
|
||||
}
|
||||
};
|
||||
|
||||
@ -194,7 +195,7 @@ namespace Matchers {
|
||||
friend MatchAnyOfGeneric<MatcherTs..., MatchersRHS...> operator || (
|
||||
MatchAnyOfGeneric<MatcherTs...>&& lhs,
|
||||
MatchAnyOfGeneric<MatchersRHS...>&& rhs) {
|
||||
return MatchAnyOfGeneric<MatcherTs..., MatchersRHS...>{array_cat(std::move(lhs.m_matchers), std::move(rhs.m_matchers))};
|
||||
return MatchAnyOfGeneric<MatcherTs..., MatchersRHS...>{array_cat(CATCH_MOVE(lhs.m_matchers), CATCH_MOVE(rhs.m_matchers))};
|
||||
}
|
||||
|
||||
//! Avoids type nesting for `GenericAnyOf || some matcher` case
|
||||
@ -203,7 +204,7 @@ namespace Matchers {
|
||||
MatchAnyOfGeneric<MatcherTs..., MatcherRHS>> operator || (
|
||||
MatchAnyOfGeneric<MatcherTs...>&& lhs,
|
||||
MatcherRHS const& rhs) {
|
||||
return MatchAnyOfGeneric<MatcherTs..., MatcherRHS>{array_cat(std::move(lhs.m_matchers), static_cast<void const*>(std::addressof(rhs)))};
|
||||
return MatchAnyOfGeneric<MatcherTs..., MatcherRHS>{array_cat(CATCH_MOVE(lhs.m_matchers), static_cast<void const*>(std::addressof(rhs)))};
|
||||
}
|
||||
|
||||
//! Avoids type nesting for `some matcher || GenericAnyOf` case
|
||||
@ -212,7 +213,7 @@ namespace Matchers {
|
||||
MatchAnyOfGeneric<MatcherLHS, MatcherTs...>> operator || (
|
||||
MatcherLHS const& lhs,
|
||||
MatchAnyOfGeneric<MatcherTs...>&& rhs) {
|
||||
return MatchAnyOfGeneric<MatcherLHS, MatcherTs...>{array_cat(static_cast<void const*>(std::addressof(lhs)), std::move(rhs.m_matchers))};
|
||||
return MatchAnyOfGeneric<MatcherLHS, MatcherTs...>{array_cat(static_cast<void const*>(std::addressof(lhs)), CATCH_MOVE(rhs.m_matchers))};
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <catch2/matchers/internal/catch_matchers_impl.hpp>
|
||||
#include <catch2/matchers/catch_matchers.hpp>
|
||||
#include <catch2/interfaces/catch_interfaces_registry_hub.hpp>
|
||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||
|
||||
namespace Catch {
|
||||
|
||||
@ -31,7 +32,7 @@ namespace Catch {
|
||||
// the Equals matcher (so the header does not mention matchers)
|
||||
void handleExceptionMatchExpr( AssertionHandler& handler, StringMatcher const& matcher, StringRef matcherString ) {
|
||||
std::string exceptionMessage = Catch::translateActiveException();
|
||||
MatchExpr<std::string, StringMatcher const&> expr( std::move(exceptionMessage), matcher, matcherString );
|
||||
MatchExpr<std::string, StringMatcher const&> expr( CATCH_MOVE(exceptionMessage), matcher, matcherString );
|
||||
handler.handleExpr( expr );
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include <catch2/internal/catch_test_macro_impl.hpp>
|
||||
#include <catch2/internal/catch_stringref.hpp>
|
||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||
|
||||
namespace Catch {
|
||||
|
||||
@ -21,7 +22,7 @@ namespace Catch {
|
||||
public:
|
||||
MatchExpr( ArgT && arg, MatcherT const& matcher, StringRef matcherString )
|
||||
: ITransientExpression{ true, matcher.match( arg ) }, // not forwarding arg here on purpose
|
||||
m_arg( std::forward<ArgT>(arg) ),
|
||||
m_arg( CATCH_FORWARD(arg) ),
|
||||
m_matcher( matcher ),
|
||||
m_matcherString( matcherString )
|
||||
{}
|
||||
@ -44,7 +45,7 @@ namespace Catch {
|
||||
|
||||
template<typename ArgT, typename MatcherT>
|
||||
auto makeMatchExpr( ArgT && arg, MatcherT const& matcher, StringRef matcherString ) -> MatchExpr<ArgT, MatcherT> {
|
||||
return MatchExpr<ArgT, MatcherT>( std::forward<ArgT>(arg), matcher, matcherString );
|
||||
return MatchExpr<ArgT, MatcherT>( CATCH_FORWARD(arg), matcher, matcherString );
|
||||
}
|
||||
|
||||
} // namespace Catch
|
||||
|
@ -18,8 +18,8 @@
|
||||
#include <catch2/catch_test_case_info.hpp>
|
||||
#include <catch2/internal/catch_console_width.hpp>
|
||||
#include <catch2/reporters/catch_reporter_helpers.hpp>
|
||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||
|
||||
#include <cfloat>
|
||||
#include <cstdio>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
@ -285,7 +285,7 @@ class TablePrinter {
|
||||
public:
|
||||
TablePrinter( std::ostream& os, std::vector<ColumnInfo> columnInfos )
|
||||
: m_os( os ),
|
||||
m_columnInfos( std::move( columnInfos ) ) {}
|
||||
m_columnInfos( CATCH_MOVE( columnInfos ) ) {}
|
||||
|
||||
auto columnInfos() const -> std::vector<ColumnInfo> const& {
|
||||
return m_columnInfos;
|
||||
@ -592,7 +592,7 @@ void ConsoleReporter::printHeaderString(std::string const& _string, std::size_t
|
||||
struct SummaryColumn {
|
||||
|
||||
SummaryColumn( std::string _label, Colour::Code _colour )
|
||||
: label( std::move( _label ) ),
|
||||
: label( CATCH_MOVE( _label ) ),
|
||||
colour( _colour ) {}
|
||||
SummaryColumn addRow( std::size_t count ) {
|
||||
ReusableStringStream rss;
|
||||
|
@ -54,7 +54,7 @@ namespace Catch {
|
||||
auto newNode =
|
||||
Detail::make_unique<SectionNode>( incompleteStats );
|
||||
node = newNode.get();
|
||||
parentNode.childSections.push_back( std::move( newNode ) );
|
||||
parentNode.childSections.push_back( CATCH_MOVE( newNode ) );
|
||||
} else {
|
||||
node = it->get();
|
||||
}
|
||||
@ -90,8 +90,8 @@ namespace Catch {
|
||||
TestCaseStats const& testCaseStats ) {
|
||||
auto node = Detail::make_unique<TestCaseNode>( testCaseStats );
|
||||
assert( m_sectionStack.size() == 0 );
|
||||
node->children.push_back( std::move(m_rootSection) );
|
||||
m_testCases.push_back( std::move(node) );
|
||||
node->children.push_back( CATCH_MOVE(m_rootSection) );
|
||||
m_testCases.push_back( CATCH_MOVE(node) );
|
||||
|
||||
assert( m_deepestSection );
|
||||
m_deepestSection->stdOut = testCaseStats.stdOut;
|
||||
@ -102,7 +102,7 @@ namespace Catch {
|
||||
TestGroupStats const& testGroupStats ) {
|
||||
auto node = Detail::make_unique<TestGroupNode>( testGroupStats );
|
||||
node->children.swap( m_testCases );
|
||||
m_testGroups.push_back( std::move(node) );
|
||||
m_testGroups.push_back( CATCH_MOVE(node) );
|
||||
}
|
||||
|
||||
void CumulativeReporterBase::testRunEnded( TestRunStats const& testRunStats ) {
|
||||
|
@ -6,18 +6,19 @@
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
#include <catch2/reporters/catch_reporter_listening.hpp>
|
||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||
|
||||
#include <cassert>
|
||||
|
||||
namespace Catch {
|
||||
|
||||
void ListeningReporter::addListener( IStreamingReporterPtr&& listener ) {
|
||||
m_listeners.push_back( std::move( listener ) );
|
||||
m_listeners.push_back( CATCH_MOVE( listener ) );
|
||||
}
|
||||
|
||||
void ListeningReporter::addReporter(IStreamingReporterPtr&& reporter) {
|
||||
assert(!m_reporter && "Listening reporter can wrap only 1 real reporter");
|
||||
m_reporter = std::move( reporter );
|
||||
m_reporter = CATCH_MOVE( reporter );
|
||||
m_preferences.shouldRedirectStdOut = m_reporter->getPreferences().shouldRedirectStdOut;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user