summaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2013-11-20 18:29:56 +0000
committerChandler Carruth <chandlerc@gmail.com>2013-11-20 18:29:56 +0000
commitfd03357c25eee9f911a8005eb5945fc99d05debb (patch)
treeb8bd3157814f2f867f673d08aff6a541a122a5b9 /unittests
parentaa8e535b576ecbf0cfba4caa01aaf074924ab8d6 (diff)
downloadllvm-fd03357c25eee9f911a8005eb5945fc99d05debb.tar.gz
llvm-fd03357c25eee9f911a8005eb5945fc99d05debb.tar.bz2
llvm-fd03357c25eee9f911a8005eb5945fc99d05debb.tar.xz
Make the moved-from SmallPtrSet be a valid, empty, small-state object.
Enhance the tests to actually require moves in C++11 mode, in addition to testing the moved-from state. Further enhance the tests to cover copy-assignment into a moved-from object and moving a large-state object. (Note that we can't really test small-state vs. large-state as that isn't an observable property of the API really.) This should finish addressing review on r195239. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195261 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/ADT/SmallPtrSetTest.cpp28
1 files changed, 21 insertions, 7 deletions
diff --git a/unittests/ADT/SmallPtrSetTest.cpp b/unittests/ADT/SmallPtrSetTest.cpp
index d885f69b21..9b71cf07f2 100644
--- a/unittests/ADT/SmallPtrSetTest.cpp
+++ b/unittests/ADT/SmallPtrSetTest.cpp
@@ -121,28 +121,42 @@ TEST(SmallPtrSetTest, CopyAndMoveTest) {
s1 = s2;
EXPECT_EQ(4U, s1.size());
+ EXPECT_EQ(4U, s2.size());
for (int i = 0; i < 8; ++i)
if (i < 4)
EXPECT_TRUE(s1.count(&buf[i]));
else
EXPECT_FALSE(s1.count(&buf[i]));
- SmallPtrSet<int *, 4> s3(llvm_move(s1));
+#if LLVM_HAS_RVALUE_REFERENCES
+ SmallPtrSet<int *, 4> s3(std::move(s1));
EXPECT_EQ(4U, s3.size());
+ EXPECT_TRUE(s1.empty());
for (int i = 0; i < 8; ++i)
if (i < 4)
EXPECT_TRUE(s3.count(&buf[i]));
else
EXPECT_FALSE(s3.count(&buf[i]));
- // Move assign to the moved-from object.
+ // Move assign into the moved-from object. Also test move of a non-small
+ // container.
+ s3.insert(&buf[4]);
+ s3.insert(&buf[5]);
+ s3.insert(&buf[6]);
+ s3.insert(&buf[7]);
s1 = llvm_move(s3);
- EXPECT_EQ(4U, s1.size());
+ EXPECT_EQ(8U, s1.size());
+ EXPECT_TRUE(s3.empty());
for (int i = 0; i < 8; ++i)
- if (i < 4)
- EXPECT_TRUE(s1.count(&buf[i]));
- else
- EXPECT_FALSE(s1.count(&buf[i]));
+ EXPECT_TRUE(s1.count(&buf[i]));
+
+ // Copy assign into a moved-from object.
+ s3 = s1;
+ EXPECT_EQ(8U, s3.size());
+ EXPECT_EQ(8U, s1.size());
+ for (int i = 0; i < 8; ++i)
+ EXPECT_TRUE(s3.count(&buf[i]));
+#endif
}
TEST(SmallPtrSetTest, SwapTest) {