Skip to content

Commit 8efee9b

Browse files
committed
Use std::string_view
1 parent a5735af commit 8efee9b

File tree

119 files changed

+913
-3430
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+913
-3430
lines changed

docs/reporter-events.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,10 @@ and then `assertionEnded` event is emitted.
109109
> [Introduced](https://github.com/catchorg/Catch2/issues/1616) in Catch2 2.9.0.
110110
111111
```cpp
112-
void benchmarkPreparing( StringRef name ) override;
112+
void benchmarkPreparing( std::string_view name ) override;
113113
void benchmarkStarting( BenchmarkInfo const& benchmarkInfo ) override;
114114
void benchmarkEnded( BenchmarkStats<> const& benchmarkStats ) override;
115-
void benchmarkFailed( StringRef error ) override;
115+
void benchmarkFailed( std::string_view error ) override;
116116
```
117117

118118
Due to the benchmark lifecycle being bit more complicated, the benchmarking
@@ -153,9 +153,9 @@ void listTags( std::vector<TagInfo> const& tagInfos );
153153
## Miscellaneous events
154154
155155
```cpp
156-
void reportInvalidTestSpec( StringRef unmatchedSpec );
157-
void fatalErrorEncountered( StringRef error );
158-
void noMatchingTestCases( StringRef unmatchedSpec );
156+
void reportInvalidTestSpec( std::string_view unmatchedSpec );
157+
void fatalErrorEncountered( std::string_view error );
158+
void noMatchingTestCases( std::string_view unmatchedSpec );
159159
```
160160

161161
These are one-off events that do not neatly fit into other categories.

examples/210-Evt-EventListeners.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ void print( std::ostream& os, int const level, std::string const& title, Catch::
131131
}
132132

133133
// struct Tag {
134-
// StringRef original, lowerCased;
134+
// std::string_view original, lowerCased;
135135
// };
136136
//
137137
//
@@ -221,9 +221,9 @@ void print( std::ostream& os, int const level, std::string const& title, Catch::
221221

222222
// struct AssertionInfo
223223
// {
224-
// StringRef macroName;
224+
// std::string_view macroName;
225225
// SourceLineInfo lineInfo;
226-
// StringRef capturedExpression;
226+
// std::string_view capturedExpression;
227227
// ResultDisposition::Flags resultDisposition;
228228
// };
229229

src/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ set(IMPL_HEADERS
124124
${SOURCES_DIR}/internal/catch_stdstreams.hpp
125125
${SOURCES_DIR}/internal/catch_stream_end_stop.hpp
126126
${SOURCES_DIR}/internal/catch_string_manip.hpp
127-
${SOURCES_DIR}/internal/catch_stringref.hpp
128127
${SOURCES_DIR}/internal/catch_tag_alias_registry.hpp
129128
${SOURCES_DIR}/internal/catch_template_test_registry.hpp
130129
${SOURCES_DIR}/internal/catch_test_case_info_hasher.hpp
@@ -201,7 +200,6 @@ set(IMPL_SOURCES
201200
${SOURCES_DIR}/internal/catch_startup_exception_registry.cpp
202201
${SOURCES_DIR}/internal/catch_stdstreams.cpp
203202
${SOURCES_DIR}/internal/catch_string_manip.cpp
204-
${SOURCES_DIR}/internal/catch_stringref.cpp
205203
${SOURCES_DIR}/internal/catch_tag_alias_registry.cpp
206204
${SOURCES_DIR}/internal/catch_test_case_info_hasher.cpp
207205
${SOURCES_DIR}/internal/catch_test_case_registry_impl.cpp

src/catch2/catch_all.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@
106106
#include <catch2/internal/catch_stdstreams.hpp>
107107
#include <catch2/internal/catch_stream_end_stop.hpp>
108108
#include <catch2/internal/catch_string_manip.hpp>
109-
#include <catch2/internal/catch_stringref.hpp>
110109
#include <catch2/internal/catch_tag_alias_registry.hpp>
111110
#include <catch2/internal/catch_template_test_registry.hpp>
112111
#include <catch2/internal/catch_test_case_info_hasher.hpp>

src/catch2/catch_assertion_info.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,17 @@
1010

1111
#include <catch2/internal/catch_result_type.hpp>
1212
#include <catch2/internal/catch_source_line_info.hpp>
13-
#include <catch2/internal/catch_stringref.hpp>
13+
14+
#include <string_view>
1415

1516
namespace Catch {
1617

1718
struct AssertionInfo {
1819
// AssertionInfo() = delete;
1920

20-
StringRef macroName;
21+
std::string_view macroName;
2122
SourceLineInfo lineInfo;
22-
StringRef capturedExpression;
23+
std::string_view capturedExpression;
2324
ResultDisposition::Flags resultDisposition;
2425
};
2526

src/catch2/catch_assertion_result.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,14 @@ namespace Catch {
9191
: expr;
9292
}
9393

94-
StringRef AssertionResult::getMessage() const {
94+
std::string_view AssertionResult::getMessage() const {
9595
return m_resultData.message;
9696
}
9797
SourceLineInfo AssertionResult::getSourceInfo() const {
9898
return m_info.lineInfo;
9999
}
100100

101-
StringRef AssertionResult::getTestMacroName() const {
101+
std::string_view AssertionResult::getTestMacroName() const {
102102
return m_info.macroName;
103103
}
104104

src/catch2/catch_assertion_result.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <catch2/catch_assertion_info.hpp>
1212
#include <catch2/internal/catch_result_type.hpp>
1313
#include <catch2/internal/catch_source_line_info.hpp>
14-
#include <catch2/internal/catch_stringref.hpp>
1514
#include <catch2/internal/catch_lazy_expr.hpp>
1615

1716
#include <string>
@@ -46,9 +45,9 @@ namespace Catch {
4645
std::string getExpressionInMacro() const;
4746
bool hasExpandedExpression() const;
4847
std::string getExpandedExpression() const;
49-
StringRef getMessage() const;
48+
std::string_view getMessage() const;
5049
SourceLineInfo getSourceInfo() const;
51-
StringRef getTestMacroName() const;
50+
std::string_view getTestMacroName() const;
5251

5352
//protected:
5453
AssertionInfo m_info;

src/catch2/catch_config.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include <catch2/internal/catch_enforce.hpp>
1111
#include <catch2/internal/catch_parse_numbers.hpp>
1212
#include <catch2/internal/catch_stdstreams.hpp>
13-
#include <catch2/internal/catch_stringref.hpp>
1413
#include <catch2/internal/catch_string_manip.hpp>
1514
#include <catch2/internal/catch_test_spec_parser.hpp>
1615
#include <catch2/interfaces/catch_interfaces_tag_alias_registry.hpp>
@@ -186,7 +185,7 @@ namespace Catch {
186185

187186
// IConfig interface
188187
bool Config::allowThrows() const { return !m_data.noThrow; }
189-
StringRef Config::name() const { return m_data.name.empty() ? m_data.processName : m_data.name; }
188+
std::string_view Config::name() const { return m_data.name.empty() ? m_data.processName : m_data.name; }
190189
bool Config::includeSuccessfulResults() const { return m_data.showSuccessfulTests; }
191190
bool Config::warnAboutMissingAssertions() const {
192191
return !!( m_data.warnings & WarnAbout::NoAssertions );

src/catch2/catch_config.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <catch2/catch_test_spec.hpp>
1212
#include <catch2/interfaces/catch_interfaces_config.hpp>
1313
#include <catch2/internal/catch_unique_ptr.hpp>
14-
#include <catch2/internal/catch_stringref.hpp>
1514
#include <catch2/internal/catch_random_seed_generation.hpp>
1615
#include <catch2/internal/catch_reporter_spec_parser.hpp>
1716

@@ -115,7 +114,7 @@ namespace Catch {
115114

116115
// IConfig interface
117116
bool allowThrows() const override;
118-
StringRef name() const override;
117+
std::string_view name() const override;
119118
bool includeSuccessfulResults() const override;
120119
bool warnAboutMissingAssertions() const override;
121120
bool warnAboutUnmatchedTestSpecs() const override;

src/catch2/catch_message.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ namespace Catch {
3535
}
3636

3737

38-
Capturer::Capturer( StringRef macroName,
38+
Capturer::Capturer( std::string_view macroName,
3939
SourceLineInfo const& lineInfo,
4040
ResultWas::OfType resultType,
41-
StringRef names ):
41+
std::string_view names ):
4242
m_resultCapture( getResultCapture() ) {
4343
auto trimmed = [&] (size_t start, size_t end) {
4444
while (names[start] == ',' || isspace(static_cast<unsigned char>(names[start]))) {
@@ -86,7 +86,7 @@ namespace Catch {
8686
if (start != pos && openings.empty()) {
8787
m_messages.emplace_back(macroName, lineInfo, resultType);
8888
m_messages.back().message += trimmed(start, pos);
89-
m_messages.back().message += " := "_sr;
89+
m_messages.back().message += " := ";
9090
start = pos;
9191
}
9292
break;
@@ -96,7 +96,7 @@ namespace Catch {
9696
assert(openings.empty() && "Mismatched openings");
9797
m_messages.emplace_back(macroName, lineInfo, resultType);
9898
m_messages.back().message += trimmed(start, names.size() - 1);
99-
m_messages.back().message += " := "_sr;
99+
m_messages.back().message += " := ";
100100
}
101101
Capturer::~Capturer() {
102102
assert( m_captured == m_messages.size() );

0 commit comments

Comments
 (0)