Add op+(StringRef, StringRef) -> std::string

This commit is contained in:
Martin Hořeňovský 2020-05-31 22:30:41 +02:00
parent f2b9508081
commit 317145514f
No known key found for this signature in database
GPG key ID: DE48307B8B0D381A
10 changed files with 89 additions and 7 deletions

View file

@ -4,7 +4,6 @@
#include <cstring>
TEST_CASE( "StringRef", "[Strings][StringRef]" ) {
using Catch::StringRef;
SECTION( "Empty string" ) {
@ -123,6 +122,18 @@ TEST_CASE( "StringRef", "[Strings][StringRef]" ) {
REQUIRE( stdStr.size() == sr.size() );
}
}
SECTION("std::string += StringRef") {
StringRef sr = "the stringref contents";
std::string lhs("some string += ");
lhs += sr;
REQUIRE(lhs == "some string += the stringref contents");
}
SECTION("StringRef + StringRef") {
StringRef sr1 = "abraka", sr2 = "dabra";
std::string together = sr1 + sr2;
REQUIRE(together == "abrakadabra");
}
}
TEST_CASE("StringRef at compilation time", "[Strings][StringRef][constexpr]") {