[llvm] r244637 - Add SmallString test trying to exercise the realloc() code path
Yaron Keren via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 11 10:35:49 PDT 2015
Author: yrnkrn
Date: Tue Aug 11 12:35:49 2015
New Revision: 244637
URL: http://llvm.org/viewvc/llvm-project?rev=244637&view=rev
Log:
Add SmallString test trying to exercise the realloc() code path
by allocating a small size (will go through malloc) and then large size.
Modified:
llvm/trunk/unittests/ADT/SmallStringTest.cpp
Modified: llvm/trunk/unittests/ADT/SmallStringTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/SmallStringTest.cpp?rev=244637&r1=244636&r2=244637&view=diff
==============================================================================
--- llvm/trunk/unittests/ADT/SmallStringTest.cpp (original)
+++ llvm/trunk/unittests/ADT/SmallStringTest.cpp Tue Aug 11 12:35:49 2015
@@ -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"));
More information about the llvm-commits
mailing list