mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 21:36:11 +01:00
Use unique_ptr for passing around exception translators
This commit is contained in:
parent
28a33497be
commit
a7533707ff
@ -56,8 +56,8 @@ namespace Catch {
|
||||
void registerTest( Detail::unique_ptr<TestCaseInfo>&& testInfo, Detail::unique_ptr<ITestInvoker>&& invoker ) override {
|
||||
m_testCaseRegistry.registerTest( std::move(testInfo), std::move(invoker) );
|
||||
}
|
||||
void registerTranslator( const IExceptionTranslator* translator ) override {
|
||||
m_exceptionTranslatorRegistry.registerTranslator( translator );
|
||||
void registerTranslator( Detail::unique_ptr<IExceptionTranslator>&& translator ) override {
|
||||
m_exceptionTranslatorRegistry.registerTranslator( std::move(translator) );
|
||||
}
|
||||
void registerTagAlias( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) override {
|
||||
m_tagAliasRegistry.add( alias, tag, lineInfo );
|
||||
|
@ -48,8 +48,11 @@ namespace Catch {
|
||||
public:
|
||||
template<typename T>
|
||||
ExceptionTranslatorRegistrar( std::string(*translateFunction)( T const& ) ) {
|
||||
getMutableRegistryHub().registerTranslator
|
||||
( new ExceptionTranslator<T>( translateFunction ) );
|
||||
getMutableRegistryHub().registerTranslator(
|
||||
Detail::unique_ptr<IExceptionTranslator>(
|
||||
new ExceptionTranslator<T>( translateFunction )
|
||||
)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -47,7 +47,7 @@ namespace Catch {
|
||||
virtual void registerReporter( std::string const& name, IReporterFactoryPtr factory ) = 0;
|
||||
virtual void registerListener( IReporterFactoryPtr factory ) = 0;
|
||||
virtual void registerTest(Detail::unique_ptr<TestCaseInfo>&& testInfo, Detail::unique_ptr<ITestInvoker>&& invoker) = 0;
|
||||
virtual void registerTranslator( const IExceptionTranslator* translator ) = 0;
|
||||
virtual void registerTranslator( Detail::unique_ptr<IExceptionTranslator>&& translator ) = 0;
|
||||
virtual void registerTagAlias( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) = 0;
|
||||
virtual void registerStartupException() noexcept = 0;
|
||||
virtual IMutableEnumValuesRegistry& getMutableEnumValuesRegistry() = 0;
|
||||
|
@ -15,8 +15,8 @@ namespace Catch {
|
||||
ExceptionTranslatorRegistry::~ExceptionTranslatorRegistry() {
|
||||
}
|
||||
|
||||
void ExceptionTranslatorRegistry::registerTranslator( const IExceptionTranslator* translator ) {
|
||||
m_translators.push_back( Detail::unique_ptr<const IExceptionTranslator>( translator ) );
|
||||
void ExceptionTranslatorRegistry::registerTranslator( Detail::unique_ptr<IExceptionTranslator>&& translator ) {
|
||||
m_translators.push_back( std::move( translator ) );
|
||||
}
|
||||
|
||||
#if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS)
|
||||
|
@ -9,6 +9,8 @@
|
||||
#define CATCH_EXCEPTION_TRANSLATOR_REGISTRY_HPP_INCLUDED
|
||||
|
||||
#include <catch2/interfaces/catch_interfaces_exception.hpp>
|
||||
#include <catch2/internal/catch_unique_ptr.hpp>
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
@ -17,7 +19,7 @@ namespace Catch {
|
||||
class ExceptionTranslatorRegistry : public IExceptionTranslatorRegistry {
|
||||
public:
|
||||
~ExceptionTranslatorRegistry() override;
|
||||
void registerTranslator( const IExceptionTranslator* translator );
|
||||
void registerTranslator( Detail::unique_ptr<IExceptionTranslator>&& translator );
|
||||
std::string translateActiveException() const override;
|
||||
std::string tryTranslators() const;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user