| 1 |
|
| 2 |
// Copyright Catch2 Authors |
| 3 |
// Distributed under the Boost Software License, Version 1.0. |
| 4 |
// (See accompanying file LICENSE.txt or copy at |
| 5 |
// https://www.boost.org/LICENSE_1_0.txt) |
| 6 |
|
| 7 |
// SPDX-License-Identifier: BSL-1.0 |
| 8 |
|
| 9 |
/**\file |
| 10 |
* Test that reporter is not passed passing assertions when it |
| 11 |
* doesn't ask for it. |
| 12 |
*/ |
| 13 |
|
| 14 |
#include <catch2/catch_test_macros.hpp> |
| 15 |
#include <catch2/reporters/catch_reporter_streaming_base.hpp> |
| 16 |
#include <catch2/reporters/catch_reporter_registrars.hpp> |
| 17 |
|
| 18 |
#include <iostream> |
| 19 |
#include <utility> |
| 20 |
|
| 21 |
namespace { |
| 22 |
|
| 23 |
class TestReporter : public Catch::StreamingReporterBase { |
| 24 |
public: |
| 25 |
TestReporter(Catch::ReporterConfig&& _config): |
| 26 |
StreamingReporterBase(std::move(_config)) { |
| 27 |
m_preferences.shouldReportAllAssertions = false; |
| 28 |
std::cout << "X26 - TestReporter constructed\n"; |
| 29 |
} |
| 30 |
|
| 31 |
static std::string getDescription() { |
| 32 |
return "X26 - test reporter that opts out of passing assertions"; |
| 33 |
} |
| 34 |
|
| 35 |
void |
| 36 |
assertionEnded( Catch::AssertionStats const& ) override { |
| 37 |
std::cerr << "X26 - assertionEnded\n"; |
| 38 |
} |
| 39 |
|
| 40 |
~TestReporter() override; |
| 41 |
}; |
| 42 |
|
| 43 |
TestReporter::~TestReporter() = default; |
| 44 |
|
| 45 |
} |
| 46 |
|
| 47 |
CATCH_REGISTER_REPORTER("test-reporter", TestReporter) |
| 48 |
|
| 49 |
TEST_CASE( "Test with only passing assertions" ) { |
| 50 |
REQUIRE( 1 == 1 ); |
| 51 |
REQUIRE( 2 == 2 ); |
| 52 |
} |