[PATCH] D33340: [libcxx] [test] Add string nullptr asserts to erase functions.
Billy Robert O'Neal III via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu May 18 14:38:53 PDT 2017
BillyONeal created this revision.
In my perf overhaul for MSVC++'s basic_string I wrote the null at data[oldsize] instead of data[newsize]; adding asserts to catch that bug.
https://reviews.llvm.org/D33340
Files:
test/std/strings/basic.string/string.modifiers/string_erase/iter.pass.cpp
test/std/strings/basic.string/string.modifiers/string_erase/iter_iter.pass.cpp
test/std/strings/basic.string/string.modifiers/string_erase/pop_back.pass.cpp
test/std/strings/basic.string/string.modifiers/string_erase/size_size.pass.cpp
Index: test/std/strings/basic.string/string.modifiers/string_erase/size_size.pass.cpp
===================================================================
--- test/std/strings/basic.string/string.modifiers/string_erase/size_size.pass.cpp
+++ test/std/strings/basic.string/string.modifiers/string_erase/size_size.pass.cpp
@@ -29,6 +29,7 @@
{
s.erase(pos, n);
LIBCPP_ASSERT(s.__invariants());
+ assert(s[s.size()] == typename S::value_type());
assert(s == expected);
}
#ifndef TEST_HAS_NO_EXCEPTIONS
@@ -58,6 +59,7 @@
{
s.erase(pos);
LIBCPP_ASSERT(s.__invariants());
+ assert(s[s.size()] == typename S::value_type());
assert(s == expected);
}
#ifndef TEST_HAS_NO_EXCEPTIONS
@@ -83,6 +85,7 @@
{
s.erase();
LIBCPP_ASSERT(s.__invariants());
+ assert(s[s.size()] == typename S::value_type());
assert(s == expected);
}
Index: test/std/strings/basic.string/string.modifiers/string_erase/pop_back.pass.cpp
===================================================================
--- test/std/strings/basic.string/string.modifiers/string_erase/pop_back.pass.cpp
+++ test/std/strings/basic.string/string.modifiers/string_erase/pop_back.pass.cpp
@@ -23,6 +23,7 @@
{
s.pop_back();
LIBCPP_ASSERT(s.__invariants());
+ assert(s[s.size()] == typename S::value_type());
assert(s == expected);
}
Index: test/std/strings/basic.string/string.modifiers/string_erase/iter_iter.pass.cpp
===================================================================
--- test/std/strings/basic.string/string.modifiers/string_erase/iter_iter.pass.cpp
+++ test/std/strings/basic.string/string.modifiers/string_erase/iter_iter.pass.cpp
@@ -25,6 +25,7 @@
typename S::const_iterator last = s.cbegin() + pos + n;
typename S::iterator i = s.erase(first, last);
LIBCPP_ASSERT(s.__invariants());
+ assert(s[s.size()] == typename S::value_type());
assert(s == expected);
assert(i - s.begin() == pos);
}
Index: test/std/strings/basic.string/string.modifiers/string_erase/iter.pass.cpp
===================================================================
--- test/std/strings/basic.string/string.modifiers/string_erase/iter.pass.cpp
+++ test/std/strings/basic.string/string.modifiers/string_erase/iter.pass.cpp
@@ -24,6 +24,7 @@
typename S::const_iterator p = s.begin() + pos;
typename S::iterator i = s.erase(p);
LIBCPP_ASSERT(s.__invariants());
+ assert(s[s.size()] == typename S::value_type());
assert(s == expected);
assert(i - s.begin() == pos);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33340.99497.patch
Type: text/x-patch
Size: 2590 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170518/3511cd9a/attachment.bin>
More information about the cfe-commits
mailing list