Turn RunTests into TestRunOrder enum class

This commit is contained in:
Martin Hořeňovský 2020-08-11 15:46:03 +02:00
parent 60cc4c293d
commit b0531404e4
No known key found for this signature in database
GPG Key ID: DE48307B8B0D381A
6 changed files with 16 additions and 16 deletions

View File

@ -72,7 +72,7 @@ namespace Catch {
bool Config::warnAboutNoTests() const { return !!(m_data.warnings & WarnAbout::NoTests); }
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; }
bool Config::shouldDebugBreak() const { return m_data.shouldDebugBreak; }

View File

@ -45,7 +45,7 @@ namespace Catch {
WarnAbout::What warnings = WarnAbout::Nothing;
ShowDurations showDurations = ShowDurations::DefaultForReporter;
double minDuration = -1;
RunTests::InWhatOrder runOrder = RunTests::InDeclarationOrder;
TestRunOrder runOrder = TestRunOrder::Declared;
UseColour::YesOrNo useColour = UseColour::Auto;
WaitForKeypress::When waitForKeypress = WaitForKeypress::Never;
@ -96,7 +96,7 @@ namespace Catch {
bool warnAboutNoTests() 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;
bool shouldDebugBreak() const override;

View File

@ -34,11 +34,11 @@ namespace Catch {
Always,
Never
};
struct RunTests { enum InWhatOrder {
InDeclarationOrder,
InLexicographicalOrder,
InRandomOrder
}; };
enum class TestRunOrder {
Declared,
LexicographicallySorted,
Randomized
};
struct UseColour { enum YesOrNo {
Auto,
Yes,
@ -71,7 +71,7 @@ namespace Catch {
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 std::vector<std::string> const& getSectionsToRun() 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

@ -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;
};