From ed8ba2e58e6ad9069feeba7bfca60b8873d23743 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Sun, 9 Mar 2014 06:17:01 +0000 Subject: 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 --- unittests/ADT/SmallStringTest.cpp | 24 +++++++++++++++++------- unittests/ADT/SmallVectorTest.cpp | 11 +++++++++++ 2 files changed, 28 insertions(+), 7 deletions(-) (limited to 'unittests') 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 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 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 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"); -- cgit v1.2.3