1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 10:42:39 +01:00

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
This commit is contained in:
Yaron Keren 2015-08-11 17:35:49 +00:00
parent 680373b126
commit 89e34e6618

View File

@ -159,6 +159,17 @@ TEST_F(SmallStringTest, Count) {
EXPECT_EQ(0U, theString.count("zz")); 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) { TEST(StringRefTest, Comparisons) {
EXPECT_EQ(-1, SmallString<10>("aab").compare("aad")); EXPECT_EQ(-1, SmallString<10>("aab").compare("aad"));
EXPECT_EQ( 0, SmallString<10>("aab").compare("aab")); EXPECT_EQ( 0, SmallString<10>("aab").compare("aab"));