mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 13:26:10 +01:00
Add check for registering multiple reporters under same name
This commit is contained in:
parent
fc3d11b1d1
commit
33aeb603fe
@ -47,7 +47,8 @@ namespace Catch {
|
||||
void ReporterRegistry::registerReporter( std::string const& name, IReporterFactoryPtr factory ) {
|
||||
CATCH_ENFORCE( name.find( "::" ) == name.npos,
|
||||
"'::' is not allowed in reporter name: '" + name + '\'' );
|
||||
m_factories.emplace(name, CATCH_MOVE(factory));
|
||||
auto ret = m_factories.emplace(name, CATCH_MOVE(factory));
|
||||
CATCH_ENFORCE( ret.second, "reporter using '" + name + "' as name was already registered" );
|
||||
}
|
||||
void ReporterRegistry::registerListener(
|
||||
Detail::unique_ptr<EventListenerFactory> factory ) {
|
||||
|
@ -312,3 +312,18 @@ TEST_CASE("Registering reporter with '::' in name fails",
|
||||
Catch::Detail::make_unique<TestReporterFactory>() ),
|
||||
"'::' is not allowed in reporter name: 'with::doublecolons'" );
|
||||
}
|
||||
|
||||
TEST_CASE("Registering multiple reporters with the same name fails",
|
||||
"[reporters][registration][approvals]") {
|
||||
Catch::ReporterRegistry registry;
|
||||
|
||||
registry.registerReporter(
|
||||
"some-reporter-name",
|
||||
Catch::Detail::make_unique<TestReporterFactory>() );
|
||||
|
||||
REQUIRE_THROWS_WITH(
|
||||
registry.registerReporter(
|
||||
"some-reporter-name",
|
||||
Catch::Detail::make_unique<TestReporterFactory>() ),
|
||||
"reporter using 'some-reporter-name' as name was already registered" );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user