Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/projects/SelfTest/IntrospectiveTests/String.tests.cpp
diff options
context:
space:
mode:
authorMartin Hořeňovský2019-09-08 14:49:40 +0200
committerMartin Hořeňovský2019-09-08 15:58:10 +0200
commit7b865daccc7bba2dcc25a4f0b9ea7348b1b4d61f (patch)
treed6964f2f65b8fbcd70e8041e16677339f675f261 /projects/SelfTest/IntrospectiveTests/String.tests.cpp
parent14362533bb50596049f1b46bcc6d333208576a87 (diff)
downloadcatch3-7b865daccc7bba2dcc25a4f0b9ea7348b1b4d61f.tar.gz
Make StringRef's operator std::string explicit
This way it is explicit when there is a `StringRef` -> `std::string` conversion and makes it easier to look for allocations that could be avoided. Doing this has already removed one allocation per registered test case, as there was a completely pointless `StringRef` -> `std::string` conversion when parsing tags of a test case.
Diffstat (limited to 'projects/SelfTest/IntrospectiveTests/String.tests.cpp')
-rw-r--r--projects/SelfTest/IntrospectiveTests/String.tests.cpp7
1 files changed, 1 insertions, 6 deletions
diff --git a/projects/SelfTest/IntrospectiveTests/String.tests.cpp b/projects/SelfTest/IntrospectiveTests/String.tests.cpp
index 6a888f90..77c16dcb 100644
--- a/projects/SelfTest/IntrospectiveTests/String.tests.cpp
+++ b/projects/SelfTest/IntrospectiveTests/String.tests.cpp
@@ -142,11 +142,6 @@ TEST_CASE( "StringRef", "[Strings][StringRef]" ) {
SECTION( "to std::string" ) {
StringRef sr = "a stringref";
- SECTION( "implicitly constructed" ) {
- std::string stdStr = sr;
- REQUIRE( stdStr == "a stringref" );
- REQUIRE( stdStr.size() == sr.size() );
- }
SECTION( "explicitly constructed" ) {
std::string stdStr( sr );
REQUIRE( stdStr == "a stringref" );
@@ -154,7 +149,7 @@ TEST_CASE( "StringRef", "[Strings][StringRef]" ) {
}
SECTION( "assigned" ) {
std::string stdStr;
- stdStr = sr;
+ stdStr = static_cast<std::string>(sr);
REQUIRE( stdStr == "a stringref" );
REQUIRE( stdStr.size() == sr.size() );
}