summaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2014-03-09 06:17:01 +0000
committerDavid Blaikie <dblaikie@gmail.com>2014-03-09 06:17:01 +0000
commited8ba2e58e6ad9069feeba7bfca60b8873d23743 (patch)
tree7f341cfa44328fbb6456079421a9082486f16d92 /unittests
parent873c5898895cd12713e4be6dc2f115418ac4c83e (diff)
downloadllvm-ed8ba2e58e6ad9069feeba7bfca60b8873d23743.tar.gz
llvm-ed8ba2e58e6ad9069feeba7bfca60b8873d23743.tar.bz2
llvm-ed8ba2e58e6ad9069feeba7bfca60b8873d23743.tar.xz
Clean up SmallString a bit
Move a common utility (assign(iter, iter)) into SmallVector (some of the others could be moved there too, but this one seemed particularly generic) and replace repetitions overrides with using directives. And simplify SmallVector::assign(num, element) while I'm here rather than thrashing these files (that cause everyone to rebuild) again. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203374 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/ADT/SmallStringTest.cpp24
-rw-r--r--unittests/ADT/SmallVectorTest.cpp11
2 files changed, 28 insertions, 7 deletions
diff --git a/unittests/ADT/SmallStringTest.cpp b/unittests/ADT/SmallStringTest.cpp
index 9398e99c91..ff04f5bd57 100644
--- a/unittests/ADT/SmallStringTest.cpp
+++ b/unittests/ADT/SmallStringTest.cpp
@@ -50,13 +50,6 @@ TEST_F(SmallStringTest, AssignRepeated) {
EXPECT_STREQ("aaa", theString.c_str());
}
-TEST_F(SmallStringTest, AssignIterPair) {
- StringRef abc = "abc";
- theString.assign(abc.begin(), abc.end());
- EXPECT_EQ(3u, theString.size());
- EXPECT_STREQ("abc", theString.c_str());
-}
-
TEST_F(SmallStringTest, AssignStringRef) {
StringRef abc = "abc";
theString.assign(abc);
@@ -88,6 +81,23 @@ TEST_F(SmallStringTest, AppendStringRef) {
EXPECT_STREQ("abcabc", theString.c_str());
}
+TEST_F(SmallStringTest, PlusEqualsStringRef) {
+ StringRef abc = "abc";
+ theString += abc;
+ theString += abc;
+ EXPECT_EQ(6u, theString.size());
+ EXPECT_STREQ("abcabc", theString.c_str());
+}
+
+TEST_F(SmallStringTest, PlusEqualsSmallVector) {
+ StringRef abc = "abc";
+ SmallVector<char, 10> abcVec(abc.begin(), abc.end());
+ theString += abcVec;
+ theString += abcVec;
+ EXPECT_EQ(6u, theString.size());
+ EXPECT_STREQ("abcabc", theString.c_str());
+}
+
TEST_F(SmallStringTest, AppendSmallVector) {
StringRef abc = "abc";
SmallVector<char, 10> abcVec(abc.begin(), abc.end());
diff --git a/unittests/ADT/SmallVectorTest.cpp b/unittests/ADT/SmallVectorTest.cpp
index 90c7982699..0ecb798779 100644
--- a/unittests/ADT/SmallVectorTest.cpp
+++ b/unittests/ADT/SmallVectorTest.cpp
@@ -338,6 +338,17 @@ TYPED_TEST(SmallVectorTest, AssignTest) {
this->assertValuesInOrder(this->theVector, 2u, 77, 77);
}
+TYPED_TEST(SmallVectorTest, AssignIterPair) {
+ SCOPED_TRACE("AssignIterPair");
+
+ std::vector<int> v;
+ v.push_back(1);
+ v.push_back(2);
+ this->theVector.push_back(Constructable(1));
+ this->theVector.assign(v.begin(), v.end());
+ this->assertValuesInOrder(this->theVector, 2u, 1, 2);
+}
+
// Erase a single element
TYPED_TEST(SmallVectorTest, EraseTest) {
SCOPED_TRACE("EraseTest");