Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
Catch::ConsoleReporter Struct Reference

#include <catch_reporter_console.h>

Inheritance diagram for Catch::ConsoleReporter:
Collaboration diagram for Catch::ConsoleReporter:

Public Member Functions

 ConsoleReporter (ReporterConfig const &config)
 
 ~ConsoleReporter () override
 
void noMatchingTestCases (std::string const &spec) override
 
void assertionStarting (AssertionInfo const &) override
 
bool assertionEnded (AssertionStats const &_assertionStats) override
 
void sectionStarting (SectionInfo const &_sectionInfo) override
 
void sectionEnded (SectionStats const &_sectionStats) override
 
void benchmarkStarting (BenchmarkInfo const &info) override
 
void benchmarkEnded (BenchmarkStats const &stats) override
 
void testCaseEnded (TestCaseStats const &_testCaseStats) override
 
void testGroupEnded (TestGroupStats const &_testGroupStats) override
 
void testRunEnded (TestRunStats const &_testRunStats) override
 
void testRunStarting (TestRunInfo const &_testRunInfo) override
 
- Public Member Functions inherited from Catch::StreamingReporterBase< ConsoleReporter >
 StreamingReporterBase (ReporterConfig const &_config)
 
ReporterPreferences getPreferences () const override
 
 ~StreamingReporterBase () override=default
 
void noMatchingTestCases (std::string const &) override
 
void testRunStarting (TestRunInfo const &_testRunInfo) override
 
void testGroupStarting (GroupInfo const &_groupInfo) override
 
void testCaseStarting (TestCaseInfo const &_testInfo) override
 
void sectionStarting (SectionInfo const &_sectionInfo) override
 
void sectionEnded (SectionStats const &) override
 
void testCaseEnded (TestCaseStats const &) override
 
void testGroupEnded (TestGroupStats const &) override
 
void testRunEnded (TestRunStats const &) override
 
void skipTest (TestCaseInfo const &) override
 
- Public Member Functions inherited from Catch::IStreamingReporter
virtual ~IStreamingReporter ()=default
 
virtual void fatalErrorEncountered (StringRef name)
 
virtual bool isMulti () const
 

Static Public Member Functions

static std::string getDescription ()
 
- Static Public Member Functions inherited from Catch::StreamingReporterBase< ConsoleReporter >
static std::set< VerbositygetSupportedVerbosities ()
 

Public Attributes

std::unique_ptr< TablePrinterm_tablePrinter
 
- Public Attributes inherited from Catch::StreamingReporterBase< ConsoleReporter >
IConfigPtr m_config
 
std::ostream & stream
 
LazyStat< TestRunInfocurrentTestRunInfo
 
LazyStat< GroupInfocurrentGroupInfo
 
LazyStat< TestCaseInfocurrentTestCaseInfo
 
std::vector< SectionInfom_sectionStack
 
ReporterPreferences m_reporterPrefs
 

Detailed Description

Definition at line 26 of file catch_reporter_console.h.

Constructor & Destructor Documentation

◆ ConsoleReporter()

Catch::ConsoleReporter::ConsoleReporter ( ReporterConfig const & config)

Definition at line 338 of file catch_reporter_console.cpp.

340 m_tablePrinter(new TablePrinter(config.stream(),
341 {
342 { "benchmark name", CATCH_CONFIG_CONSOLE_WIDTH - 32, ColumnInfo::Left },
343 { "iters", 8, ColumnInfo::Right },
344 { "elapsed ns", 14, ColumnInfo::Right },
345 { "average", 14, ColumnInfo::Right }
346 })) {}
std::unique_ptr< TablePrinter > m_tablePrinter

◆ ~ConsoleReporter()

Catch::ConsoleReporter::~ConsoleReporter ( )
overridedefault

Member Function Documentation

◆ assertionEnded()

bool Catch::ConsoleReporter::assertionEnded ( AssertionStats const & _assertionStats)
overridevirtual

Implements Catch::IStreamingReporter.

Definition at line 359 of file catch_reporter_console.cpp.

359 {
360 AssertionResult const& result = _assertionStats.assertionResult;
361
362 bool includeResults = m_config->includeSuccessfulResults() || !result.isOk();
363
364 // Drop out if result was successful but we're not printing them.
365 if (!includeResults && result.getResultType() != ResultWas::Warning)
366 return false;
367
368 lazyPrint();
369
370 ConsoleAssertionPrinter printer(stream, _assertionStats, includeResults);
371 printer.print();
372 stream << std::endl;
373 return true;
374}

◆ assertionStarting()

void Catch::ConsoleReporter::assertionStarting ( AssertionInfo const & )
overridevirtual

Implements Catch::IStreamingReporter.

Definition at line 357 of file catch_reporter_console.cpp.

357{}

◆ benchmarkEnded()

void Catch::ConsoleReporter::benchmarkEnded ( BenchmarkStats const & stats)
overridevirtual

Reimplemented from Catch::IStreamingReporter.

Definition at line 416 of file catch_reporter_console.cpp.

416 {
417 Duration average(stats.elapsedTimeInNanoseconds / stats.iterations);
418 (*m_tablePrinter)
419 << stats.iterations << ColumnBreak()
420 << stats.elapsedTimeInNanoseconds << ColumnBreak()
421 << average << ColumnBreak();
422}

◆ benchmarkStarting()

void Catch::ConsoleReporter::benchmarkStarting ( BenchmarkInfo const & info)
overridevirtual

Reimplemented from Catch::IStreamingReporter.

Definition at line 401 of file catch_reporter_console.cpp.

401 {
402 lazyPrintWithoutClosingBenchmarkTable();
403
404 auto nameCol = Column( info.name ).width( static_cast<std::size_t>( m_tablePrinter->columnInfos()[0].width - 2 ) );
405
406 bool firstLine = true;
407 for (auto line : nameCol) {
408 if (!firstLine)
409 (*m_tablePrinter) << ColumnBreak() << ColumnBreak() << ColumnBreak();
410 else
411 firstLine = false;
412
413 (*m_tablePrinter) << line << ColumnBreak();
414 }
415}
Here is the call graph for this function:

◆ getDescription()

std::string Catch::ConsoleReporter::getDescription ( )
static

Definition at line 349 of file catch_reporter_console.cpp.

349 {
350 return "Reports test results as plain lines of text";
351}

◆ noMatchingTestCases()

void Catch::ConsoleReporter::noMatchingTestCases ( std::string const & spec)
overridevirtual

Implements Catch::IStreamingReporter.

Definition at line 353 of file catch_reporter_console.cpp.

353 {
354 stream << "No test cases matched '" << spec << '\'' << std::endl;
355}

◆ sectionEnded()

void Catch::ConsoleReporter::sectionEnded ( SectionStats const & _sectionStats)
overridevirtual

Implements Catch::IStreamingReporter.

Definition at line 380 of file catch_reporter_console.cpp.

380 {
381 m_tablePrinter->close();
382 if (_sectionStats.missingAssertions) {
383 lazyPrint();
384 Colour colour(Colour::ResultError);
385 if (m_sectionStack.size() > 1)
386 stream << "\nNo assertions in section";
387 else
388 stream << "\nNo assertions in test case";
389 stream << " '" << _sectionStats.sectionInfo.name << "'\n" << std::endl;
390 }
391 if (m_config->showDurations() == ShowDurations::Always) {
392 stream << getFormattedDuration(_sectionStats.durationInSeconds) << " s: " << _sectionStats.sectionInfo.name << std::endl;
393 }
394 if (m_headerPrinted) {
395 m_headerPrinted = false;
396 }
398}
std::string getFormattedDuration(double duration)
void sectionEnded(SectionStats const &) override
Here is the call graph for this function:

◆ sectionStarting()

void Catch::ConsoleReporter::sectionStarting ( SectionInfo const & _sectionInfo)
overridevirtual

Implements Catch::IStreamingReporter.

Definition at line 376 of file catch_reporter_console.cpp.

376 {
377 m_headerPrinted = false;
379}
void sectionStarting(SectionInfo const &_sectionInfo) override
Here is the call graph for this function:

◆ testCaseEnded()

void Catch::ConsoleReporter::testCaseEnded ( TestCaseStats const & _testCaseStats)
overridevirtual

Implements Catch::IStreamingReporter.

Definition at line 424 of file catch_reporter_console.cpp.

424 {
425 m_tablePrinter->close();
427 m_headerPrinted = false;
428}
void testCaseEnded(TestCaseStats const &) override
Here is the call graph for this function:

◆ testGroupEnded()

void Catch::ConsoleReporter::testGroupEnded ( TestGroupStats const & _testGroupStats)
overridevirtual

Implements Catch::IStreamingReporter.

Definition at line 429 of file catch_reporter_console.cpp.

429 {
430 if (currentGroupInfo.used) {
431 printSummaryDivider();
432 stream << "Summary for group '" << _testGroupStats.groupInfo.name << "':\n";
433 printTotals(_testGroupStats.totals);
434 stream << '\n' << std::endl;
435 }
437}
void testGroupEnded(TestGroupStats const &) override
Here is the call graph for this function:

◆ testRunEnded()

void Catch::ConsoleReporter::testRunEnded ( TestRunStats const & _testRunStats)
overridevirtual

Implements Catch::IStreamingReporter.

Definition at line 438 of file catch_reporter_console.cpp.

438 {
439 printTotalsDivider(_testRunStats.totals);
440 printTotals(_testRunStats.totals);
441 stream << std::endl;
443}
void testRunEnded(TestRunStats const &) override
Here is the call graph for this function:

◆ testRunStarting()

void Catch::ConsoleReporter::testRunStarting ( TestRunInfo const & _testRunInfo)
overridevirtual

Implements Catch::IStreamingReporter.

Definition at line 444 of file catch_reporter_console.cpp.

444 {
446 printTestFilters();
447}
void testRunStarting(TestRunInfo const &_testRunInfo) override
Here is the call graph for this function:

Member Data Documentation

◆ m_tablePrinter

std::unique_ptr<TablePrinter> Catch::ConsoleReporter::m_tablePrinter

Definition at line 27 of file catch_reporter_console.h.


The documentation for this struct was generated from the following files: