Move extractClassName to the single calling TU and make it static

This commit is contained in:
Martin Hořeňovský 2021-06-18 23:36:08 +02:00
parent 70f5392210
commit 28a33497be
No known key found for this signature in database
GPG Key ID: DE48307B8B0D381A
3 changed files with 17 additions and 17 deletions

View File

@ -12,7 +12,6 @@
#include <catch2/interfaces/catch_interfaces_registry_hub.hpp>
#include <catch2/internal/catch_random_number_generator.hpp>
#include <catch2/internal/catch_run_context.hpp>
#include <catch2/internal/catch_string_manip.hpp>
#include <catch2/catch_test_case_info.hpp>
#include <catch2/catch_test_spec.hpp>
@ -149,17 +148,4 @@ namespace {
m_testAsFunction();
}
std::string extractClassName( StringRef classOrQualifiedMethodName ) {
std::string className(classOrQualifiedMethodName);
if( startsWith( className, '&' ) )
{
std::size_t lastColons = className.rfind( "::" );
std::size_t penultimateColons = className.rfind( "::", lastColons-1 );
if( penultimateColons == std::string::npos )
penultimateColons = 1;
className = className.substr( penultimateColons, lastColons-penultimateColons );
}
return className;
}
} // end namespace Catch

View File

@ -63,9 +63,6 @@ namespace Catch {
void invoke() const override;
};
std::string extractClassName( StringRef classOrQualifiedMethodName );
///////////////////////////////////////////////////////////////////////////

View File

@ -10,9 +10,26 @@
#include <catch2/catch_test_case_info.hpp>
#include <catch2/internal/catch_test_case_registry_impl.hpp>
#include <catch2/interfaces/catch_interfaces_registry_hub.hpp>
#include <catch2/internal/catch_string_manip.hpp>
namespace Catch {
namespace {
std::string extractClassName( StringRef classOrQualifiedMethodName ) {
std::string className( classOrQualifiedMethodName );
if ( startsWith( className, '&' ) ) {
std::size_t lastColons = className.rfind( "::" );
std::size_t penultimateColons =
className.rfind( "::", lastColons - 1 );
if ( penultimateColons == std::string::npos )
penultimateColons = 1;
className = className.substr( penultimateColons,
lastColons - penultimateColons );
}
return className;
}
} // namespace
Detail::unique_ptr<ITestInvoker> makeTestInvoker( void(*testAsFunction)() ) {
return Detail::make_unique<TestInvokerAsFunction>( testAsFunction );
}