diff options
| author | Phil Nash | 2019-05-21 00:04:19 +0100 |
|---|---|---|
| committer | Phil Nash | 2019-05-21 00:04:44 +0100 |
| commit | 96355da34edf51cc813400115984050bd7c50630 (patch) | |
| tree | cb154679a962f6c437e8d169a97516be574e5905 /projects/SelfTest/IntrospectiveTests/String.tests.cpp | |
| parent | 71fce429afcebba7c32b6c46aced1013c6df9c0b (diff) | |
| download | catch3-96355da34edf51cc813400115984050bd7c50630.tar.gz | |
StringRef no longer repoints m_start to m_data after c_str() on a substring.
This fixes an issue where a self-assignment of a StringRef copy would point into internally (and now dangling) data.
(now self-assignment check is no longer needed)
Diffstat (limited to 'projects/SelfTest/IntrospectiveTests/String.tests.cpp')
| -rw-r--r-- | projects/SelfTest/IntrospectiveTests/String.tests.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/projects/SelfTest/IntrospectiveTests/String.tests.cpp b/projects/SelfTest/IntrospectiveTests/String.tests.cpp index 8bf2ffb3..876d4a09 100644 --- a/projects/SelfTest/IntrospectiveTests/String.tests.cpp +++ b/projects/SelfTest/IntrospectiveTests/String.tests.cpp @@ -65,7 +65,6 @@ TEST_CASE( "StringRef", "[Strings][StringRef]" ) { original.c_str(); // Forces it to take ownership - REQUIRE( isSubstring( original ) == false ); REQUIRE( isOwned( original ) ); } @@ -88,14 +87,13 @@ TEST_CASE( "StringRef", "[Strings][StringRef]" ) { REQUIRE( rawChars == s.currentData() ); // same pointer value REQUIRE( ss.c_str() != rawChars ); - REQUIRE( isSubstring( ss ) == false ); REQUIRE( isOwned( ss ) ); - REQUIRE( ss.currentData() != s.currentData() ); // different pointer value - SECTION( "Self-assignment after substring" ) { ss = *&ss; // the *& are there to suppress warnings (see: "Improvements to Clang's diagnostics" in https://rev.ng/gitlab/revng-bar-2019/clang/raw/master/docs/ReleaseNotes.rst) - REQUIRE(isOwned(ss) == true); + REQUIRE( isOwned(ss) == false ); + REQUIRE( ss == "hello" ); + REQUIRE( rawChars == ss.currentData() ); // same pointer value } } |