Pass around the test suite name by StringRef

This commit is contained in:
Martin Hořeňovský 2021-09-08 00:01:31 +02:00
parent ea49210eae
commit 29caae5ce5
No known key found for this signature in database
GPG Key ID: DE48307B8B0D381A
6 changed files with 8 additions and 10 deletions

View File

@ -65,7 +65,7 @@ namespace Catch {
// IConfig interface
bool Config::allowThrows() const { return !m_data.noThrow; }
std::ostream& Config::stream() const { return m_stream->stream(); }
std::string Config::name() const { return m_data.name.empty() ? m_data.processName : m_data.name; }
StringRef Config::name() const { return m_data.name.empty() ? m_data.processName : m_data.name; }
bool Config::includeSuccessfulResults() const { return m_data.showSuccessfulTests; }
bool Config::warnAboutMissingAssertions() const { return !!(m_data.warnings & WarnAbout::NoAssertions); }
bool Config::warnAboutNoTests() const { return !!(m_data.warnings & WarnAbout::NoTests); }

View File

@ -89,7 +89,7 @@ namespace Catch {
// IConfig interface
bool allowThrows() const override;
std::ostream& stream() const override;
std::string name() const override;
StringRef name() const override;
bool includeSuccessfulResults() const override;
bool warnAboutMissingAssertions() const override;
bool warnAboutNoTests() const override;

View File

@ -9,6 +9,7 @@
#define CATCH_INTERFACES_CONFIG_HPP_INCLUDED
#include <catch2/internal/catch_noncopyable.hpp>
#include <catch2/internal/catch_stringref.hpp>
#include <chrono>
#include <iosfwd>
@ -59,7 +60,7 @@ namespace Catch {
virtual bool allowThrows() const = 0;
virtual std::ostream& stream() const = 0;
virtual std::string name() const = 0;
virtual StringRef name() const = 0;
virtual bool includeSuccessfulResults() const = 0;
virtual bool shouldDebugBreak() const = 0;
virtual bool warnAboutMissingAssertions() const = 0;

View File

@ -29,9 +29,6 @@ namespace Catch {
std::ostream& ReporterConfig::stream() const { return *m_stream; }
IConfig const * ReporterConfig::fullConfig() const { return m_fullConfig; }
TestRunInfo::TestRunInfo( std::string const& _name ) : name( _name ) {}
AssertionStats::AssertionStats( AssertionResult const& _assertionResult,
std::vector<MessageInfo> const& _infoMessages,
Totals const& _totals )

View File

@ -45,8 +45,8 @@ namespace Catch {
};
struct TestRunInfo {
TestRunInfo( std::string const& _name );
std::string name;
TestRunInfo(StringRef _name) : name(_name) {}
StringRef name;
};
struct AssertionStats {

View File

@ -31,8 +31,8 @@ namespace Catch {
.initialIndent(indent) << '\n';
}
std::string escape(std::string const& str) {
std::string escaped = str;
std::string escape(StringRef str) {
std::string escaped = static_cast<std::string>(str);
replaceInPlace(escaped, "|", "||");
replaceInPlace(escaped, "'", "|'");
replaceInPlace(escaped, "\n", "|n");