1
0
mirror of https://github.com/catchorg/Catch2.git synced 2025-01-16 15:18:00 +00:00

Compare commits

...

4 Commits

Author SHA1 Message Date
Martin Hořeňovský
05d7014e75
ApproxMacher uses Approx's overloads for double directly
This saves a tiny little bit of compilation times when the
`ApproxMatcher` is used and `epsilon`, `margin`, or `scale` are
used to customize its behaviour.
2020-08-11 19:07:37 +02:00
Martin Hořeňovský
aa28a917cb
Turn UseColour into enum class 2020-08-11 17:47:54 +02:00
Martin Hořeňovský
b0531404e4
Turn RunTests into TestRunOrder enum class 2020-08-11 17:47:00 +02:00
Martin Hořeňovský
60cc4c293d
Turn ShowDurations into an enum class 2020-08-11 15:03:37 +02:00
8 changed files with 33 additions and 33 deletions

View File

@ -70,11 +70,11 @@ namespace Catch {
bool Config::includeSuccessfulResults() const { return m_data.showSuccessfulTests; }
bool Config::warnAboutMissingAssertions() const { return !!(m_data.warnings & WarnAbout::NoAssertions); }
bool Config::warnAboutNoTests() const { return !!(m_data.warnings & WarnAbout::NoTests); }
ShowDurations::OrNot Config::showDurations() const { return m_data.showDurations; }
ShowDurations Config::showDurations() const { return m_data.showDurations; }
double Config::minDuration() const { return m_data.minDuration; }
RunTests::InWhatOrder Config::runOrder() const { return m_data.runOrder; }
TestRunOrder Config::runOrder() const { return m_data.runOrder; }
unsigned int Config::rngSeed() const { return m_data.rngSeed; }
UseColour::YesOrNo Config::useColour() const { return m_data.useColour; }
UseColour Config::useColour() const { return m_data.useColour; }
bool Config::shouldDebugBreak() const { return m_data.shouldDebugBreak; }
int Config::abortAfter() const { return m_data.abortAfter; }
bool Config::showInvisibles() const { return m_data.showInvisibles; }

View File

@ -43,10 +43,10 @@ namespace Catch {
Verbosity verbosity = Verbosity::Normal;
WarnAbout::What warnings = WarnAbout::Nothing;
ShowDurations::OrNot showDurations = ShowDurations::DefaultForReporter;
ShowDurations showDurations = ShowDurations::DefaultForReporter;
double minDuration = -1;
RunTests::InWhatOrder runOrder = RunTests::InDeclarationOrder;
UseColour::YesOrNo useColour = UseColour::Auto;
TestRunOrder runOrder = TestRunOrder::Declared;
UseColour useColour = UseColour::Auto;
WaitForKeypress::When waitForKeypress = WaitForKeypress::Never;
std::string outputFilename;
@ -94,11 +94,11 @@ namespace Catch {
bool includeSuccessfulResults() const override;
bool warnAboutMissingAssertions() const override;
bool warnAboutNoTests() const override;
ShowDurations::OrNot showDurations() const override;
ShowDurations showDurations() const override;
double minDuration() const override;
RunTests::InWhatOrder runOrder() const override;
TestRunOrder runOrder() const override;
unsigned int rngSeed() const override;
UseColour::YesOrNo useColour() const override;
UseColour useColour() const override;
bool shouldDebugBreak() const override;
int abortAfter() const override;
bool showInvisibles() const override;

View File

@ -29,21 +29,21 @@ namespace Catch {
NoTests = 0x02
}; };
struct ShowDurations { enum OrNot {
enum class ShowDurations {
DefaultForReporter,
Always,
Never
}; };
struct RunTests { enum InWhatOrder {
InDeclarationOrder,
InLexicographicalOrder,
InRandomOrder
}; };
struct UseColour { enum YesOrNo {
};
enum class TestRunOrder {
Declared,
LexicographicallySorted,
Randomized
};
enum class UseColour {
Auto,
Yes,
No
}; };
};
struct WaitForKeypress { enum When {
Never,
BeforeStart = 1,
@ -66,14 +66,14 @@ namespace Catch {
virtual bool warnAboutNoTests() const = 0;
virtual int abortAfter() const = 0;
virtual bool showInvisibles() const = 0;
virtual ShowDurations::OrNot showDurations() const = 0;
virtual ShowDurations showDurations() const = 0;
virtual double minDuration() const = 0;
virtual TestSpec const& testSpec() const = 0;
virtual bool hasTestFilters() const = 0;
virtual std::vector<std::string> const& getTestsOrTags() const = 0;
virtual RunTests::InWhatOrder runOrder() const = 0;
virtual TestRunOrder runOrder() const = 0;
virtual unsigned int rngSeed() const = 0;
virtual UseColour::YesOrNo useColour() const = 0;
virtual UseColour useColour() const = 0;
virtual std::vector<std::string> const& getSectionsToRun() const = 0;
virtual Verbosity verbosity() const = 0;

View File

@ -62,11 +62,11 @@ namespace Catch {
};
auto const setTestOrder = [&]( std::string const& order ) {
if( startsWith( "declared", order ) )
config.runOrder = RunTests::InDeclarationOrder;
config.runOrder = TestRunOrder::Declared;
else if( startsWith( "lexical", order ) )
config.runOrder = RunTests::InLexicographicalOrder;
config.runOrder = TestRunOrder::LexicographicallySorted;
else if( startsWith( "random", order ) )
config.runOrder = RunTests::InRandomOrder;
config.runOrder = TestRunOrder::Randomized;
else
return ParserResult::runtimeError( "Unrecognised ordering: '" + order + "'" );
return ParserResult::ok( ParseResultType::Matched );

View File

@ -106,7 +106,7 @@ namespace {
static Win32ColourImpl s_instance;
auto const* config = getCurrentContext().getConfig();
UseColour::YesOrNo colourMode = config?
UseColour colourMode = config?
config->useColour() : UseColour::Auto;
if( colourMode == UseColour::Auto )
colourMode = UseColour::Yes;
@ -179,7 +179,7 @@ namespace {
IColourImpl* platformColourInstance() {
ErrnoGuard guard;
auto const* config = getCurrentContext().getConfig();
UseColour::YesOrNo colourMode = config
UseColour colourMode = config
? config->useColour()
: UseColour::Auto;
if( colourMode == UseColour::Auto )

View File

@ -46,15 +46,15 @@ namespace {
std::vector<TestCaseHandle> sortTests( IConfig const& config, std::vector<TestCaseHandle> const& unsortedTestCases ) {
switch (config.runOrder()) {
case RunTests::InDeclarationOrder:
case TestRunOrder::Declared:
return unsortedTestCases;
case RunTests::InLexicographicalOrder: {
case TestRunOrder::LexicographicallySorted: {
std::vector<TestCaseHandle> sorted = unsortedTestCases;
std::sort(sorted.begin(), sorted.end());
return sorted;
}
case RunTests::InRandomOrder: {
case TestRunOrder::Randomized: {
seedRng(config);
HashTest h(rng());
std::vector<std::pair<uint64_t, TestCaseHandle>> indexed_tests;

View File

@ -47,7 +47,7 @@ namespace Catch {
std::vector<Detail::unique_ptr<ITestInvoker>> m_invokers;
std::vector<TestCaseHandle> m_handles;
mutable RunTests::InWhatOrder m_currentSortOrder = RunTests::InDeclarationOrder;
mutable TestRunOrder m_currentSortOrder = TestRunOrder::Declared;
mutable std::vector<TestCaseHandle> m_sortedFunctions;
};

View File

@ -116,17 +116,17 @@ namespace Matchers {
}
template <typename = std::enable_if_t<std::is_constructible<double, T>::value>>
ApproxMatcher& epsilon( T const& newEpsilon ) {
approx.epsilon(newEpsilon);
approx.epsilon(static_cast<double>(newEpsilon));
return *this;
}
template <typename = std::enable_if_t<std::is_constructible<double, T>::value>>
ApproxMatcher& margin( T const& newMargin ) {
approx.margin(newMargin);
approx.margin(static_cast<double>(newMargin));
return *this;
}
template <typename = std::enable_if_t<std::is_constructible<double, T>::value>>
ApproxMatcher& scale( T const& newScale ) {
approx.scale(newScale);
approx.scale(static_cast<double>(newScale));
return *this;
}