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

summaryrefslogtreecommitdiffhomepage
path: root/src/catch2
diff options
context:
space:
mode:
authorMartin Hořeňovský2021-05-19 11:00:53 +0200
committerMartin Hořeňovský2021-05-19 11:00:53 +0200
commit023b5306b444ebe3c20a008cdd150cf5510ff36d (patch)
treef309c0846f78aed4495b9f2d56145f2cceffd30d /src/catch2
parent9137e591fa7d7fee2e8c1d3bfeb55068deb2c665 (diff)
downloadcatch3-023b5306b444ebe3c20a008cdd150cf5510ff36d.tar.gz
Add deep const to unique_ptr::operator->
Diffstat (limited to 'src/catch2')
-rw-r--r--src/catch2/internal/catch_unique_ptr.hpp6
-rw-r--r--src/catch2/reporters/catch_reporter_listening.cpp40
2 files changed, 25 insertions, 21 deletions
diff --git a/src/catch2/internal/catch_unique_ptr.hpp b/src/catch2/internal/catch_unique_ptr.hpp
index 758b22da..d3bc8417 100644
--- a/src/catch2/internal/catch_unique_ptr.hpp
+++ b/src/catch2/internal/catch_unique_ptr.hpp
@@ -64,7 +64,11 @@ namespace Detail {
assert(m_ptr);
return *m_ptr;
}
- T* operator->() const noexcept {
+ T* operator->() noexcept {
+ assert(m_ptr);
+ return m_ptr;
+ }
+ T const* operator->() const noexcept {
assert(m_ptr);
return m_ptr;
}
diff --git a/src/catch2/reporters/catch_reporter_listening.cpp b/src/catch2/reporters/catch_reporter_listening.cpp
index d189388b..e048a656 100644
--- a/src/catch2/reporters/catch_reporter_listening.cpp
+++ b/src/catch2/reporters/catch_reporter_listening.cpp
@@ -22,54 +22,54 @@ namespace Catch {
}
void ListeningReporter::noMatchingTestCases( std::string const& spec ) {
- for ( auto const& listener : m_listeners ) {
+ for ( auto& listener : m_listeners ) {
listener->noMatchingTestCases( spec );
}
m_reporter->noMatchingTestCases( spec );
}
void ListeningReporter::reportInvalidArguments(std::string const&arg){
- for ( auto const& listener : m_listeners ) {
+ for ( auto& listener : m_listeners ) {
listener->reportInvalidArguments( arg );
}
m_reporter->reportInvalidArguments( arg );
}
void ListeningReporter::benchmarkPreparing( std::string const& name ) {
- for (auto const& listener : m_listeners) {
+ for (auto& listener : m_listeners) {
listener->benchmarkPreparing(name);
}
m_reporter->benchmarkPreparing(name);
}
void ListeningReporter::benchmarkStarting( BenchmarkInfo const& benchmarkInfo ) {
- for ( auto const& listener : m_listeners ) {
+ for ( auto& listener : m_listeners ) {
listener->benchmarkStarting( benchmarkInfo );
}
m_reporter->benchmarkStarting( benchmarkInfo );
}
void ListeningReporter::benchmarkEnded( BenchmarkStats<> const& benchmarkStats ) {
- for ( auto const& listener : m_listeners ) {
+ for ( auto& listener : m_listeners ) {
listener->benchmarkEnded( benchmarkStats );
}
m_reporter->benchmarkEnded( benchmarkStats );
}
void ListeningReporter::benchmarkFailed( std::string const& error ) {
- for (auto const& listener : m_listeners) {
+ for (auto& listener : m_listeners) {
listener->benchmarkFailed(error);
}
m_reporter->benchmarkFailed(error);
}
void ListeningReporter::testRunStarting( TestRunInfo const& testRunInfo ) {
- for ( auto const& listener : m_listeners ) {
+ for ( auto& listener : m_listeners ) {
listener->testRunStarting( testRunInfo );
}
m_reporter->testRunStarting( testRunInfo );
}
void ListeningReporter::testGroupStarting( GroupInfo const& groupInfo ) {
- for ( auto const& listener : m_listeners ) {
+ for ( auto& listener : m_listeners ) {
listener->testGroupStarting( groupInfo );
}
m_reporter->testGroupStarting( groupInfo );
@@ -77,21 +77,21 @@ namespace Catch {
void ListeningReporter::testCaseStarting( TestCaseInfo const& testInfo ) {
- for ( auto const& listener : m_listeners ) {
+ for ( auto& listener : m_listeners ) {
listener->testCaseStarting( testInfo );
}
m_reporter->testCaseStarting( testInfo );
}
void ListeningReporter::sectionStarting( SectionInfo const& sectionInfo ) {
- for ( auto const& listener : m_listeners ) {
+ for ( auto& listener : m_listeners ) {
listener->sectionStarting( sectionInfo );
}
m_reporter->sectionStarting( sectionInfo );
}
void ListeningReporter::assertionStarting( AssertionInfo const& assertionInfo ) {
- for ( auto const& listener : m_listeners ) {
+ for ( auto& listener : m_listeners ) {
listener->assertionStarting( assertionInfo );
}
m_reporter->assertionStarting( assertionInfo );
@@ -99,35 +99,35 @@ namespace Catch {
// The return value indicates if the messages buffer should be cleared:
bool ListeningReporter::assertionEnded( AssertionStats const& assertionStats ) {
- for( auto const& listener : m_listeners ) {
+ for( auto& listener : m_listeners ) {
static_cast<void>( listener->assertionEnded( assertionStats ) );
}
return m_reporter->assertionEnded( assertionStats );
}
void ListeningReporter::sectionEnded( SectionStats const& sectionStats ) {
- for ( auto const& listener : m_listeners ) {
+ for ( auto& listener : m_listeners ) {
listener->sectionEnded( sectionStats );
}
m_reporter->sectionEnded( sectionStats );
}
void ListeningReporter::testCaseEnded( TestCaseStats const& testCaseStats ) {
- for ( auto const& listener : m_listeners ) {
+ for ( auto& listener : m_listeners ) {
listener->testCaseEnded( testCaseStats );
}
m_reporter->testCaseEnded( testCaseStats );
}
void ListeningReporter::testGroupEnded( TestGroupStats const& testGroupStats ) {
- for ( auto const& listener : m_listeners ) {
+ for ( auto& listener : m_listeners ) {
listener->testGroupEnded( testGroupStats );
}
m_reporter->testGroupEnded( testGroupStats );
}
void ListeningReporter::testRunEnded( TestRunStats const& testRunStats ) {
- for ( auto const& listener : m_listeners ) {
+ for ( auto& listener : m_listeners ) {
listener->testRunEnded( testRunStats );
}
m_reporter->testRunEnded( testRunStats );
@@ -135,28 +135,28 @@ namespace Catch {
void ListeningReporter::skipTest( TestCaseInfo const& testInfo ) {
- for ( auto const& listener : m_listeners ) {
+ for ( auto& listener : m_listeners ) {
listener->skipTest( testInfo );
}
m_reporter->skipTest( testInfo );
}
void ListeningReporter::listReporters(std::vector<ReporterDescription> const& descriptions) {
- for (auto const& listener : m_listeners) {
+ for (auto& listener : m_listeners) {
listener->listReporters(descriptions);
}
m_reporter->listReporters(descriptions);
}
void ListeningReporter::listTests(std::vector<TestCaseHandle> const& tests) {
- for (auto const& listener : m_listeners) {
+ for (auto& listener : m_listeners) {
listener->listTests(tests);
}
m_reporter->listTests(tests);
}
void ListeningReporter::listTags(std::vector<TagInfo> const& tags) {
- for (auto const& listener : m_listeners) {
+ for (auto& listener : m_listeners) {
listener->listTags(tags);
}
m_reporter->listTags(tags);