mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-02 05:15:39 +02:00
Error out reporter registration for reporter names with '::'
This commit is contained in:
@@ -13,7 +13,9 @@
|
||||
#include <catch2/interfaces/catch_interfaces_reporter.hpp>
|
||||
#include <catch2/interfaces/catch_interfaces_reporter_factory.hpp>
|
||||
#include <catch2/interfaces/catch_interfaces_reporter_registry.hpp>
|
||||
#include <catch2/internal/catch_enforce.hpp>
|
||||
#include <catch2/internal/catch_list.hpp>
|
||||
#include <catch2/internal/catch_reporter_registry.hpp>
|
||||
#include <catch2/matchers/catch_matchers_string.hpp>
|
||||
#include <catch2/reporters/catch_reporter_helpers.hpp>
|
||||
#include <catch2/reporters/catch_reporter_event_listener.hpp>
|
||||
@@ -260,3 +262,25 @@ TEST_CASE("Multireporter updates ReporterPreferences properly",
|
||||
REQUIRE( multiReporter.getPreferences().shouldReportAllAssertions == true );
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
class TestReporterFactory : public Catch::IReporterFactory {
|
||||
Catch::IStreamingReporterPtr create( Catch::ReporterConfig const& ) const override {
|
||||
CATCH_INTERNAL_ERROR(
|
||||
"This factory should never create a reporter" );
|
||||
}
|
||||
std::string getDescription() const override {
|
||||
return "Fake test factory";
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
TEST_CASE("Registering reporter with '::' in name fails",
|
||||
"[reporters][registration]") {
|
||||
Catch::ReporterRegistry registry;
|
||||
|
||||
REQUIRE_THROWS_WITH( registry.registerReporter(
|
||||
"with::doublecolons",
|
||||
Catch::Detail::make_unique<TestReporterFactory>() ),
|
||||
"'::' is not allowed in reporter name: 'with::doublecolons'" );
|
||||
}
|
||||
|
Reference in New Issue
Block a user