Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/src/catch2/internal/catch_test_case_registry_impl.cpp
diff options
context:
space:
mode:
authorMartin Hořeňovský2023-05-12 09:50:59 +0200
committerMartin Hořeňovský2023-05-12 09:51:13 +0200
commit598895d04866c6e85f1d703a8c3d89e8d38a2311 (patch)
tree6b4b5b111f9f8b826a659e28aa75dfc7ff734394 /src/catch2/internal/catch_test_case_registry_impl.cpp
parent0dc82e08dfec25faf6c6c145f3592984db7276cc (diff)
downloadcatch3-598895d04866c6e85f1d703a8c3d89e8d38a2311.tar.gz
Fix Wredundant-decls
Closes #2682
Diffstat (limited to 'src/catch2/internal/catch_test_case_registry_impl.cpp')
-rw-r--r--src/catch2/internal/catch_test_case_registry_impl.cpp55
1 files changed, 32 insertions, 23 deletions
diff --git a/src/catch2/internal/catch_test_case_registry_impl.cpp b/src/catch2/internal/catch_test_case_registry_impl.cpp
index b66469bc..f1702979 100644
--- a/src/catch2/internal/catch_test_case_registry_impl.cpp
+++ b/src/catch2/internal/catch_test_case_registry_impl.cpp
@@ -24,6 +24,38 @@
namespace Catch {
+ namespace {
+ static void enforceNoDuplicateTestCases(
+ std::vector<TestCaseHandle> const& tests ) {
+ auto testInfoCmp = []( TestCaseInfo const* lhs,
+ TestCaseInfo const* rhs ) {
+ return *lhs < *rhs;
+ };
+ std::set<TestCaseInfo const*, decltype( testInfoCmp )&> seenTests(
+ testInfoCmp );
+ for ( auto const& test : tests ) {
+ const auto infoPtr = &test.getTestCaseInfo();
+ const auto prev = seenTests.insert( infoPtr );
+ CATCH_ENFORCE( prev.second,
+ "error: test case \""
+ << infoPtr->name << "\", with tags \""
+ << infoPtr->tagsAsString()
+ << "\" already defined.\n"
+ << "\tFirst seen at "
+ << ( *prev.first )->lineInfo << "\n"
+ << "\tRedefined at " << infoPtr->lineInfo );
+ }
+ }
+
+ static bool matchTest( TestCaseHandle const& testCase,
+ TestSpec const& testSpec,
+ IConfig const& config ) {
+ return testSpec.matches( testCase.getTestCaseInfo() ) &&
+ isThrowSafe( testCase, config );
+ }
+
+ } // end unnamed namespace
+
std::vector<TestCaseHandle> sortTests( IConfig const& config, std::vector<TestCaseHandle> const& unsortedTestCases ) {
switch (config.runOrder()) {
case TestRunOrder::Declared:
@@ -80,29 +112,6 @@ namespace Catch {
return !testCase.getTestCaseInfo().throws() || config.allowThrows();
}
- bool matchTest( TestCaseHandle const& testCase, TestSpec const& testSpec, IConfig const& config ) {
- return testSpec.matches( testCase.getTestCaseInfo() ) && isThrowSafe( testCase, config );
- }
-
- void
- enforceNoDuplicateTestCases( std::vector<TestCaseHandle> const& tests ) {
- auto testInfoCmp = []( TestCaseInfo const* lhs,
- TestCaseInfo const* rhs ) {
- return *lhs < *rhs;
- };
- std::set<TestCaseInfo const*, decltype(testInfoCmp) &> seenTests(testInfoCmp);
- for ( auto const& test : tests ) {
- const auto infoPtr = &test.getTestCaseInfo();
- const auto prev = seenTests.insert( infoPtr );
- CATCH_ENFORCE(
- prev.second,
- "error: test case \"" << infoPtr->name << "\", with tags \""
- << infoPtr->tagsAsString() << "\" already defined.\n"
- << "\tFirst seen at " << ( *prev.first )->lineInfo << "\n"
- << "\tRedefined at " << infoPtr->lineInfo );
- }
- }
-
std::vector<TestCaseHandle> filterTests( std::vector<TestCaseHandle> const& testCases, TestSpec const& testSpec, IConfig const& config ) {
std::vector<TestCaseHandle> filtered;
filtered.reserve( testCases.size() );