diff options
author | Yaron Keren <yaron.keren@gmail.com> | 2015-08-11 17:35:49 +0000 |
---|---|---|
committer | Yaron Keren <yaron.keren@gmail.com> | 2015-08-11 17:35:49 +0000 |
commit | 6a0fc73bdb36d029bc37965cc0d350fa2d28b009 (patch) | |
tree | 5d36e6fe3afbeab5eb7c5fa600cd398cc8202902 /llvm/unittests/ADT/SmallStringTest.cpp | |
parent | b13df6582a6a7802d4e0675a4ae7545c09a766a9 (diff) | |
download | bcm5719-llvm-6a0fc73bdb36d029bc37965cc0d350fa2d28b009.tar.gz bcm5719-llvm-6a0fc73bdb36d029bc37965cc0d350fa2d28b009.zip |
Add SmallString test trying to exercise the realloc() code path
by allocating a small size (will go through malloc) and then large size.
llvm-svn: 244637
Diffstat (limited to 'llvm/unittests/ADT/SmallStringTest.cpp')
-rw-r--r-- | llvm/unittests/ADT/SmallStringTest.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/unittests/ADT/SmallStringTest.cpp b/llvm/unittests/ADT/SmallStringTest.cpp index 9398e99c911..995ef8e8127 100644 --- a/llvm/unittests/ADT/SmallStringTest.cpp +++ b/llvm/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")); |