diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2013-11-20 18:21:25 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2013-11-20 18:21:25 +0000 |
commit | aa8e535b576ecbf0cfba4caa01aaf074924ab8d6 (patch) | |
tree | 6878d5fe8f4b72242a235772b466b4ce098dd907 /unittests | |
parent | 128d90ab4a2669128492c600fa5a3f48e3dd0cea (diff) | |
download | llvm-aa8e535b576ecbf0cfba4caa01aaf074924ab8d6.tar.gz llvm-aa8e535b576ecbf0cfba4caa01aaf074924ab8d6.tar.bz2 llvm-aa8e535b576ecbf0cfba4caa01aaf074924ab8d6.tar.xz |
Add a test for assignment operator behavior which was changed in
r195239, as well as a comment about the fact that assigning over
a moved-from object was in fact tested. Addresses some of the review
feedback on r195239.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195260 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r-- | unittests/ADT/SmallPtrSetTest.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/unittests/ADT/SmallPtrSetTest.cpp b/unittests/ADT/SmallPtrSetTest.cpp index 1b564ac05a..d885f69b21 100644 --- a/unittests/ADT/SmallPtrSetTest.cpp +++ b/unittests/ADT/SmallPtrSetTest.cpp @@ -16,7 +16,30 @@ using namespace llvm; -// SmallPtrSet swapping test. +TEST(SmallPtrSetTest, Assignment) { + int buf[8]; + for (int i = 0; i < 8; ++i) + buf[i] = 0; + + SmallPtrSet<int *, 4> s1; + s1.insert(&buf[0]); + s1.insert(&buf[1]); + + SmallPtrSet<int *, 4> s2; + (s2 = s1).insert(&buf[2]); + + // Self assign as well. + (s2 = s2).insert(&buf[3]); + + s1 = s2; + EXPECT_EQ(4U, s1.size()); + for (int i = 0; i < 8; ++i) + if (i < 4) + EXPECT_TRUE(s1.count(&buf[i])); + else + EXPECT_FALSE(s1.count(&buf[i])); +} + TEST(SmallPtrSetTest, GrowthTest) { int i; int buf[8]; @@ -112,6 +135,7 @@ TEST(SmallPtrSetTest, CopyAndMoveTest) { else EXPECT_FALSE(s3.count(&buf[i])); + // Move assign to the moved-from object. s1 = llvm_move(s3); EXPECT_EQ(4U, s1.size()); for (int i = 0; i < 8; ++i) |