Remove StringRef::isNullTerminated and StringRef::c_str

Both of them were fundamentally unsafe to use and shouldn't be used
at all.
This commit is contained in:
Martin Hořeňovský
2021-03-25 20:02:47 +01:00
parent e50e10ef8f
commit f1d7a10e06
9 changed files with 26 additions and 178 deletions

View File

@@ -10494,12 +10494,7 @@ with expansion:
0 == 0
String.tests.cpp:<line number>: PASSED:
REQUIRE( empty.isNullTerminated() )
with expansion:
true
String.tests.cpp:<line number>: PASSED:
REQUIRE( std::strcmp( empty.c_str(), "" ) == 0 )
REQUIRE( std::strcmp( empty.data(), "" ) == 0 )
with expansion:
0 == 0
@@ -10520,24 +10515,11 @@ String.tests.cpp:<line number>: PASSED:
with expansion:
5 == 5
String.tests.cpp:<line number>: PASSED:
REQUIRE( s.isNullTerminated() )
with expansion:
true
String.tests.cpp:<line number>: PASSED:
REQUIRE( std::strcmp( rawChars, "hello" ) == 0 )
with expansion:
0 == 0
String.tests.cpp:<line number>: PASSED:
REQUIRE_NOTHROW( s.c_str() )
String.tests.cpp:<line number>: PASSED:
REQUIRE( s.c_str() == rawChars )
with expansion:
"hello" == "hello"
String.tests.cpp:<line number>: PASSED:
REQUIRE( s.data() == rawChars )
with expansion:
@@ -10553,14 +10535,6 @@ String.tests.cpp:<line number>
String.tests.cpp:<line number>: PASSED:
REQUIRE( original == "original" )
String.tests.cpp:<line number>: PASSED:
REQUIRE_FALSE( original.isNullTerminated() )
with expansion:
!false
String.tests.cpp:<line number>: PASSED:
REQUIRE_THROWS( original.c_str() )
String.tests.cpp:<line number>: PASSED:
REQUIRE_NOTHROW( original.data() )
@@ -10606,7 +10580,7 @@ with expansion:
6 == 6
String.tests.cpp:<line number>: PASSED:
REQUIRE( std::strcmp( ss.c_str(), "world!" ) == 0 )
REQUIRE( std::strcmp( ss.data(), "world!" ) == 0 )
with expansion:
0 == 0
@@ -10658,7 +10632,7 @@ String.tests.cpp:<line number>
...............................................................................
String.tests.cpp:<line number>: PASSED:
REQUIRE( std::strcmp(ss.c_str(), "world!") == 0 )
REQUIRE( std::strcmp(ss.data(), "world!") == 0 )
with expansion:
0 == 0
@@ -10832,10 +10806,6 @@ String.tests.cpp:<line number>: PASSED:
with message:
stringref.size() == 3
String.tests.cpp:<line number>: PASSED:
with message:
stringref.isNullTerminated()
String.tests.cpp:<line number>: PASSED:
with message:
stringref.data() == abc
@@ -10872,14 +10842,6 @@ String.tests.cpp:<line number>: PASSED:
with message:
shortened.begin() != shortened.end()
String.tests.cpp:<line number>: PASSED:
with message:
!(shortened.isNullTerminated())
String.tests.cpp:<line number>: PASSED:
with message:
!(shortened.substr(1, 3).isNullTerminated())
-------------------------------------------------------------------------------
StringRef at compilation time
UDL construction
@@ -10895,10 +10857,6 @@ String.tests.cpp:<line number>: PASSED:
with message:
sr1.size() == 3
String.tests.cpp:<line number>: PASSED:
with message:
sr1.isNullTerminated()
String.tests.cpp:<line number>: PASSED:
with message:
sr2.empty()
@@ -10907,10 +10865,6 @@ String.tests.cpp:<line number>: PASSED:
with message:
sr2.size() == 0
String.tests.cpp:<line number>: PASSED:
with message:
sr2.isNullTerminated()
-------------------------------------------------------------------------------
Stringifying std::chrono::duration helpers
-------------------------------------------------------------------------------
@@ -16769,5 +16723,5 @@ Misc.tests.cpp:<line number>: PASSED:
===============================================================================
test cases: 356 | 266 passed | 86 failed | 4 failed as expected
assertions: 2105 | 1936 passed | 148 failed | 21 failed as expected
assertions: 2094 | 1925 passed | 148 failed | 21 failed as expected