diff options
| author | Martin Hořeňovský | 2022-05-15 09:54:27 +0200 |
|---|---|---|
| committer | Martin Hořeňovský | 2022-05-15 09:54:27 +0200 |
| commit | 33aeb603fee982d8f7d5aec3e746741e8776942e (patch) | |
| tree | d277147429c02fe98a74fc9f41491e75c86d2986 /src/catch2 | |
| parent | fc3d11b1d1090a5bcbcc9e410a460f9bf6a1f474 (diff) | |
| download | catch3-33aeb603fee982d8f7d5aec3e746741e8776942e.tar.gz | |
Add check for registering multiple reporters under same name
Diffstat (limited to 'src/catch2')
| -rw-r--r-- | src/catch2/internal/catch_reporter_registry.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/catch2/internal/catch_reporter_registry.cpp b/src/catch2/internal/catch_reporter_registry.cpp index c4aef822..01b6b3a0 100644 --- a/src/catch2/internal/catch_reporter_registry.cpp +++ b/src/catch2/internal/catch_reporter_registry.cpp @@ -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 ) { |