projects
/
oota-llvm.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
a5ccfee
)
Add SmallString test trying to exercise the realloc() code path
author
Yaron Keren
<yaron.keren@gmail.com>
Tue, 11 Aug 2015 17:35:49 +0000
(17:35 +0000)
committer
Yaron Keren
<yaron.keren@gmail.com>
Tue, 11 Aug 2015 17:35:49 +0000
(17:35 +0000)
by allocating a small size (will go through malloc) and then large size.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@244637
91177308
-0d34-0410-b5e6-
96231b3b80d8
unittests/ADT/SmallStringTest.cpp
patch
|
blob
|
history
diff --git
a/unittests/ADT/SmallStringTest.cpp
b/unittests/ADT/SmallStringTest.cpp
index 9398e99c91193a8199dde8bb08d00dcebec3e908..995ef8e812781f9c76a701dd2bf49fe086e61011 100644
(file)
--- a/
unittests/ADT/SmallStringTest.cpp
+++ b/
unittests/ADT/SmallStringTest.cpp
@@
-159,6
+159,17
@@
TEST_F(SmallStringTest, Count) {
EXPECT_EQ(0U, theString.count("zz"));
}
+TEST_F(SmallStringTest, Realloc) {
+ theString = "abcd";
+ theString.reserve(100);
+ EXPECT_EQ("abcd", theString);
+ unsigned const N = 100000;
+ theString.reserve(N);
+ for (unsigned i = 0; i < N - 4; ++i)
+ theString.push_back('y');
+ EXPECT_EQ("abcdyyy", theString.slice(0, 7));
+}
+
TEST(StringRefTest, Comparisons) {
EXPECT_EQ(-1, SmallString<10>("aab").compare("aad"));
EXPECT_EQ( 0, SmallString<10>("aab").compare("aab"));