diff options
| author | Martin Hořeňovský | 2022-01-09 19:01:14 +0100 |
|---|---|---|
| committer | Martin Hořeňovský | 2022-01-09 19:01:14 +0100 |
| commit | b6ff2c3dda9e071d8fa7acd2fa2518a7139e6386 (patch) | |
| tree | b92e4d9040120f9e52b0456d4bbd7db5ac7411db /tests/SelfTest/IntrospectiveTests/Reporters.tests.cpp | |
| parent | 875299cff05560f186eb34e26f7576da61cba65e (diff) | |
| download | catch3-b6ff2c3dda9e071d8fa7acd2fa2518a7139e6386.tar.gz | |
Error out reporter registration for reporter names with '::'
Diffstat (limited to 'tests/SelfTest/IntrospectiveTests/Reporters.tests.cpp')
| -rw-r--r-- | tests/SelfTest/IntrospectiveTests/Reporters.tests.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/SelfTest/IntrospectiveTests/Reporters.tests.cpp b/tests/SelfTest/IntrospectiveTests/Reporters.tests.cpp index 8bb04352..40ae0179 100644 --- a/tests/SelfTest/IntrospectiveTests/Reporters.tests.cpp +++ b/tests/SelfTest/IntrospectiveTests/Reporters.tests.cpp @@ -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'" ); +} |