Use StringRef as the argument to benchmark{Failed,Preparing}

This commit is contained in:
Martin Hořeňovský 2021-05-30 23:45:55 +02:00
parent 5741de9ccd
commit c9371865d4
No known key found for this signature in database
GPG Key ID: DE48307B8B0D381A
10 changed files with 25 additions and 23 deletions

View File

@ -44,10 +44,10 @@ namespace Catch {
virtual auto acquireGeneratorTracker( StringRef generatorName, SourceLineInfo const& lineInfo ) -> IGeneratorTracker& = 0;
virtual void benchmarkPreparing( std::string const& name ) = 0;
virtual void benchmarkPreparing( StringRef name ) = 0;
virtual void benchmarkStarting( BenchmarkInfo const& info ) = 0;
virtual void benchmarkEnded( BenchmarkStats<> const& stats ) = 0;
virtual void benchmarkFailed( std::string const& error ) = 0;
virtual void benchmarkFailed( StringRef error ) = 0;
virtual void pushScopedMessage( MessageInfo const& message ) = 0;
virtual void popScopedMessage( MessageInfo const& message ) = 0;

View File

@ -201,10 +201,10 @@ namespace Catch {
virtual void testCaseStarting( TestCaseInfo const& testInfo ) = 0;
virtual void sectionStarting( SectionInfo const& sectionInfo ) = 0;
virtual void benchmarkPreparing( std::string const& ) {}
virtual void benchmarkPreparing( StringRef ) {}
virtual void benchmarkStarting( BenchmarkInfo const& ) {}
virtual void benchmarkEnded( BenchmarkStats<> const& ) {}
virtual void benchmarkFailed( std::string const& ) {}
virtual void benchmarkFailed( StringRef ) {}
virtual void assertionStarting( AssertionInfo const& assertionInfo ) = 0;

View File

@ -316,7 +316,7 @@ namespace Catch {
m_unfinishedSections.push_back(endInfo);
}
void RunContext::benchmarkPreparing(std::string const& name) {
void RunContext::benchmarkPreparing( StringRef name ) {
m_reporter->benchmarkPreparing(name);
}
void RunContext::benchmarkStarting( BenchmarkInfo const& info ) {
@ -325,7 +325,7 @@ namespace Catch {
void RunContext::benchmarkEnded( BenchmarkStats<> const& stats ) {
m_reporter->benchmarkEnded( stats );
}
void RunContext::benchmarkFailed(std::string const & error) {
void RunContext::benchmarkFailed( StringRef error ) {
m_reporter->benchmarkFailed( error );
}

View File

@ -77,10 +77,10 @@ namespace Catch {
auto acquireGeneratorTracker( StringRef generatorName, SourceLineInfo const& lineInfo ) -> IGeneratorTracker& override;
void benchmarkPreparing( std::string const& name ) override;
void benchmarkPreparing( StringRef name ) override;
void benchmarkStarting( BenchmarkInfo const& info ) override;
void benchmarkEnded( BenchmarkStats<> const& stats ) override;
void benchmarkFailed( std::string const& error ) override;
void benchmarkFailed( StringRef error ) override;
void pushScopedMessage( MessageInfo const& message ) override;
void popScopedMessage( MessageInfo const& message ) override;

View File

@ -434,10 +434,12 @@ void ConsoleReporter::sectionEnded(SectionStats const& _sectionStats) {
StreamingReporterBase::sectionEnded(_sectionStats);
}
void ConsoleReporter::benchmarkPreparing(std::string const& name) {
void ConsoleReporter::benchmarkPreparing( StringRef name ) {
lazyPrintWithoutClosingBenchmarkTable();
auto nameCol = TextFlow::Column(name).width(static_cast<std::size_t>(m_tablePrinter->columnInfos()[0].width - 2));
auto nameCol = TextFlow::Column( static_cast<std::string>( name ) )
.width( static_cast<std::size_t>(
m_tablePrinter->columnInfos()[0].width - 2 ) );
bool firstLine = true;
for (auto line : nameCol) {
@ -473,7 +475,7 @@ void ConsoleReporter::benchmarkEnded(BenchmarkStats<> const& stats) {
}
}
void ConsoleReporter::benchmarkFailed(std::string const& error) {
void ConsoleReporter::benchmarkFailed( StringRef error ) {
Colour colour(Colour::Red);
(*m_tablePrinter)
<< "Benchmark failed (" << error << ')'

View File

@ -42,10 +42,10 @@ namespace Catch {
void sectionStarting(SectionInfo const& _sectionInfo) override;
void sectionEnded(SectionStats const& _sectionStats) override;
void benchmarkPreparing(std::string const& name) override;
void benchmarkPreparing( StringRef name ) override;
void benchmarkStarting(BenchmarkInfo const& info) override;
void benchmarkEnded(BenchmarkStats<> const& stats) override;
void benchmarkFailed(std::string const& error) override;
void benchmarkFailed( StringRef error ) override;
void testCaseEnded(TestCaseStats const& _testCaseStats) override;
void testGroupEnded(TestGroupStats const& _testGroupStats) override;

View File

@ -35,7 +35,7 @@ namespace Catch {
m_reporter->reportInvalidArguments( arg );
}
void ListeningReporter::benchmarkPreparing( std::string const& name ) {
void ListeningReporter::benchmarkPreparing( StringRef name ) {
for (auto& listener : m_listeners) {
listener->benchmarkPreparing(name);
}
@ -54,7 +54,7 @@ namespace Catch {
m_reporter->benchmarkEnded( benchmarkStats );
}
void ListeningReporter::benchmarkFailed( std::string const& error ) {
void ListeningReporter::benchmarkFailed( StringRef error ) {
for (auto& listener : m_listeners) {
listener->benchmarkFailed(error);
}

View File

@ -34,10 +34,10 @@ namespace Catch {
void reportInvalidArguments(std::string const&arg) override;
void benchmarkPreparing(std::string const& name) override;
void benchmarkPreparing( StringRef name ) override;
void benchmarkStarting( BenchmarkInfo const& benchmarkInfo ) override;
void benchmarkEnded( BenchmarkStats<> const& benchmarkStats ) override;
void benchmarkFailed(std::string const&) override;
void benchmarkFailed( StringRef error ) override;
void testRunStarting( TestRunInfo const& testRunInfo ) override;
void testGroupStarting( GroupInfo const& groupInfo ) override;

View File

@ -229,7 +229,7 @@ namespace Catch {
m_xml.endElement();
}
void XmlReporter::benchmarkPreparing(std::string const& name) {
void XmlReporter::benchmarkPreparing( StringRef name ) {
m_xml.startElement("BenchmarkResults")
.writeAttribute("name"_sr, name);
}
@ -266,7 +266,7 @@ namespace Catch {
m_xml.endElement();
}
void XmlReporter::benchmarkFailed(std::string const &error) {
void XmlReporter::benchmarkFailed(StringRef error) {
m_xml.scopedElement("failed").
writeAttribute("message"_sr, error);
m_xml.endElement();

View File

@ -51,10 +51,10 @@ namespace Catch {
void testRunEnded(TestRunStats const& testRunStats) override;
void benchmarkPreparing(std::string const& name) override;
void benchmarkPreparing( StringRef name ) override;
void benchmarkStarting(BenchmarkInfo const&) override;
void benchmarkEnded(BenchmarkStats<> const&) override;
void benchmarkFailed(std::string const&) override;
void benchmarkFailed( StringRef error ) override;
void listReporters(std::vector<ReporterDescription> const& descriptions) override;
void listTests(std::vector<TestCaseHandle> const& tests) override;