23 std::vector<TestCase> sorted = unsortedTestCases;
25 switch(
config.runOrder() ) {
27 std::sort( sorted.begin(), sorted.end() );
31 std::shuffle( sorted.begin(), sorted.end(),
rng() );
44 std::set<TestCase> seenFunctions;
45 for(
auto const& function : functions ) {
46 auto prev = seenFunctions.insert( function );
48 "error: TEST_CASE( \"" << function.name <<
"\" ) already defined.\n"
49 <<
"\tFirst seen at " << prev.first->getTestCaseInfo().lineInfo <<
"\n"
50 <<
"\tRedefined at " << function.getTestCaseInfo().lineInfo );
55 std::vector<TestCase> filtered;
56 filtered.reserve( testCases.size() );
57 for (
auto const& testCase : testCases) {
58 if ((!testSpec.
hasFilters() && !testCase.isHidden()) ||
60 filtered.push_back(testCase);
73 rss <<
"Anonymous test case " << ++m_unnamedCount;
76 m_functions.push_back( testCase );
83 if( m_sortedFunctions.empty() )
86 if( m_currentSortOrder !=
config.runOrder() || m_sortedFunctions.empty() ) {
88 m_currentSortOrder =
config.runOrder();
90 return m_sortedFunctions;
103 std::string className = classOrQualifiedMethodName;
106 std::size_t lastColons = className.rfind(
"::" );
107 std::size_t penultimateColons = className.rfind(
"::", lastColons-1 );
108 if( penultimateColons == std::string::npos )
109 penultimateColons = 1;
110 className = className.substr( penultimateColons, lastColons-penultimateColons );
#define CATCH_ENFORCE(condition, msg)
auto str() const -> std::string
TestCase withName(std::string const &_newName) const
TestCaseInfo const & getTestCaseInfo() const
TestInvokerAsFunction(void(*testAsFunction)()) noexcept
void invoke() const override
std::vector< TestCase > const & getAllTests() const override
virtual void registerTest(TestCase const &testCase)
std::vector< TestCase > const & getAllTestsSorted(IConfig const &config) const override
bool matches(TestCaseInfo const &testCase) const
std::vector< TestCase > filterTests(std::vector< TestCase > const &testCases, TestSpec const &testSpec, IConfig const &config)
void seedRng(IConfig const &config)
IRegistryHub const & getRegistryHub()
bool startsWith(std::string const &s, std::string const &prefix)
void enforceNoDuplicateTestCases(std::vector< TestCase > const &functions)
std::vector< TestCase > const & getAllTestCasesSorted(IConfig const &config)
std::string extractClassName(StringRef const &classOrQualifiedMethodName)
std::vector< TestCase > sortTests(IConfig const &config, std::vector< TestCase > const &unsortedTestCases)
bool matchTest(TestCase const &testCase, TestSpec const &testSpec, IConfig const &config)
virtual ITestCaseRegistry const & getTestCaseRegistry() const =0
virtual std::vector< TestCase > const & getAllTestsSorted(IConfig const &config) const =0