catch3
Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.
Clonegit clone https://git.progmasoft.com/catch3
Cleanup visibility in CumulativeReporterBase
- Commit
b892ab133c32d7fd82290467b46ba3c4a32527ae- Author
- Martin Hořeňovský ·
- Parents
0c9fe16537cd
Changes
.../reporters/catch_reporter_cumulative_base.cpp | 6 +++--- .../reporters/catch_reporter_cumulative_base.hpp | 18 ++++++++++++------ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/catch2/reporters/catch_reporter_cumulative_base.cpp b/src/catch2/reporters/catch_reporter_cumulative_base.cpp index 85e9c156..9dd1eb78 100644 --- a/src/catch2/reporters/catch_reporter_cumulative_base.cpp +++ b/src/catch2/reporters/catch_reporter_cumulative_base.cpp @@ -146,18 +146,18 @@ namespace Catch { } void CumulativeReporterBase::listReporters(std::vector<ReporterDescription> const& descriptions) { - defaultListReporters(stream, descriptions, m_config->verbosity()); + defaultListReporters(m_stream, descriptions, m_config->verbosity()); } void CumulativeReporterBase::listTests(std::vector<TestCaseHandle> const& tests) { - defaultListTests(stream, + defaultListTests(m_stream, tests, m_config->hasTestFilters(), m_config->verbosity()); } void CumulativeReporterBase::listTags(std::vector<TagInfo> const& tags) { - defaultListTags( stream, tags, m_config->hasTestFilters() ); + defaultListTags( m_stream, tags, m_config->hasTestFilters() ); } bool CumulativeReporterBase::SectionNode::hasAnyAssertions() const { diff --git a/src/catch2/reporters/catch_reporter_cumulative_base.hpp b/src/catch2/reporters/catch_reporter_cumulative_base.hpp index 55abd1e1..732a9469 100644 --- a/src/catch2/reporters/catch_reporter_cumulative_base.hpp +++ b/src/catch2/reporters/catch_reporter_cumulative_base.hpp @@ -59,7 +59,8 @@ namespace Catch { * performance. **Accessing the assertion expansions if it wasn't stored is * UB.** */ - struct CumulativeReporterBase : IStreamingReporter { + class CumulativeReporterBase : public IStreamingReporter { + public: template<typename T, typename ChildNodeT> struct Node { explicit Node( T const& _value ) : value( _value ) {} @@ -90,7 +91,7 @@ namespace Catch { CumulativeReporterBase( ReporterConfig const& _config ): IStreamingReporter( _config.fullConfig() ), - stream( _config.stream() ) {} + m_stream( _config.stream() ) {} ~CumulativeReporterBase() override; void benchmarkPreparing( StringRef ) override {} @@ -131,17 +132,22 @@ namespace Catch { bool m_shouldStoreFailedAssertions = true; //! Stream to write the output to - std::ostream& stream; + std::ostream& m_stream; - // Note: We rely on pointer identity being stable, which is why - // we store pointers to the nodes rather than the values. - std::vector<Detail::unique_ptr<TestCaseNode>> m_testCases; // We need lazy construction here. We should probably refactor it // later, after the events are redone. + //! The root node of the test run tree. Detail::unique_ptr<TestRunNode> m_testRun; + private: + // Note: We rely on pointer identity being stable, which is why + // we store pointers to the nodes rather than the values. + std::vector<Detail::unique_ptr<TestCaseNode>> m_testCases; + // Root section of the _current_ test case Detail::unique_ptr<SectionNode> m_rootSection; + // Deepest section of the _current_ test case SectionNode* m_deepestSection = nullptr; + // Stack of _active_ sections in the _current_ test case std::vector<SectionNode*> m_sectionStack; };