Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/tests/SelfTest/IntrospectiveTests
diff options
context:
space:
mode:
authorMartin Hořeňovský2022-02-23 23:46:45 +0100
committerMartin Hořeňovský2022-03-06 16:34:13 +0100
commit61d0f7a9afb88c12f8931f80321e58f2cfbc62db (patch)
treecdb5f8f3a86c99dd56c5dcb14a05b3f5751b1e9b /tests/SelfTest/IntrospectiveTests
parent9b01c404f514782383ec064c57a0a8e7d326f476 (diff)
downloadcatch3-61d0f7a9afb88c12f8931f80321e58f2cfbc62db.tar.gz
Pass the whole IStream wrapper into reporter
This will become useful when reworking colour support, because Win32 colour support requires checking whether the output is stdout, which is done through the `IStream` wrapper.
Diffstat (limited to 'tests/SelfTest/IntrospectiveTests')
-rw-r--r--tests/SelfTest/IntrospectiveTests/Reporters.tests.cpp23
1 files changed, 17 insertions, 6 deletions
diff --git a/tests/SelfTest/IntrospectiveTests/Reporters.tests.cpp b/tests/SelfTest/IntrospectiveTests/Reporters.tests.cpp
index 40ae0179..a2416042 100644
--- a/tests/SelfTest/IntrospectiveTests/Reporters.tests.cpp
+++ b/tests/SelfTest/IntrospectiveTests/Reporters.tests.cpp
@@ -16,6 +16,7 @@
#include <catch2/internal/catch_enforce.hpp>
#include <catch2/internal/catch_list.hpp>
#include <catch2/internal/catch_reporter_registry.hpp>
+#include <catch2/internal/catch_stream.hpp>
#include <catch2/matchers/catch_matchers_string.hpp>
#include <catch2/reporters/catch_reporter_helpers.hpp>
#include <catch2/reporters/catch_reporter_event_listener.hpp>
@@ -24,6 +25,16 @@
#include <sstream>
+namespace {
+ class StringIStream : public Catch::IStream {
+ public:
+ std::ostream& stream() const override { return sstr; }
+ std::string str() const { return sstr.str(); }
+ private:
+ mutable std::stringstream sstr;
+ };
+}
+
TEST_CASE( "The default listing implementation write to provided stream",
"[reporters][reporter-helpers]" ) {
using Catch::Matchers::ContainsSubstring;
@@ -72,11 +83,11 @@ TEST_CASE( "Reporter's write listings to provided stream", "[reporters]" ) {
for (auto const& factory : factories) {
INFO("Tested reporter: " << factory.first);
- std::stringstream sstream;
+ StringIStream sstream;
Catch::ConfigData config_data;
Catch::Config config( config_data );
- Catch::ReporterConfig rep_config( &config, sstream );
+ Catch::ReporterConfig rep_config( &config, &sstream );
auto reporter = factory.second->create( rep_config );
DYNAMIC_SECTION( factory.first << " reporter lists tags" ) {
@@ -162,8 +173,8 @@ TEST_CASE("Multireporter calls reporters and listeners in correct order",
Catch::ConfigData config_data;
Catch::Config config( config_data );
- std::stringstream sstream;
- Catch::ReporterConfig rep_config( &config, sstream );
+ StringIStream sstream;
+ Catch::ReporterConfig rep_config( &config, &sstream );
// We add reporters before listeners, to check that internally they
// get sorted properly, and listeners are called first anyway.
@@ -215,8 +226,8 @@ TEST_CASE("Multireporter updates ReporterPreferences properly",
Catch::ConfigData config_data;
Catch::Config config( config_data );
- std::stringstream sstream;
- Catch::ReporterConfig rep_config( &config, sstream );
+ StringIStream sstream;
+ Catch::ReporterConfig rep_config( &config, &sstream );
Catch::MultiReporter multiReporter( &config );
// Post init defaults