summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ADT
diff options
context:
space:
mode:
authorQuentin Colombet <qcolombet@apple.com>2016-03-14 18:10:41 +0000
committerQuentin Colombet <qcolombet@apple.com>2016-03-14 18:10:41 +0000
commitde89d5f81fb647e9744e4583bb0d77dc6a237b42 (patch)
tree3574c5849558ead37b1e5b8ea24397e92133adea /llvm/unittests/ADT
parent7a21bb196b37132bb11c6d9e1a0e2b10cc35d183 (diff)
downloadbcm5719-llvm-de89d5f81fb647e9744e4583bb0d77dc6a237b42.tar.gz
bcm5719-llvm-de89d5f81fb647e9744e4583bb0d77dc6a237b42.zip
[ADT] Add a pop_back_val method to the SparseSet container.
The next commit will use it. llvm-svn: 263455
Diffstat (limited to 'llvm/unittests/ADT')
-rw-r--r--llvm/unittests/ADT/SparseSetTest.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/llvm/unittests/ADT/SparseSetTest.cpp b/llvm/unittests/ADT/SparseSetTest.cpp
index eb0e0db283b..4db7a7d61fb 100644
--- a/llvm/unittests/ADT/SparseSetTest.cpp
+++ b/llvm/unittests/ADT/SparseSetTest.cpp
@@ -183,4 +183,24 @@ TEST(SparseSetTest, AltStructSet) {
EXPECT_FALSE(Set.erase(5));
EXPECT_TRUE(Set.erase(6));
}
+
+TEST(SparseSetTest, PopBack) {
+ USet Set;
+ const unsigned UpperBound = 300;
+ Set.setUniverse(UpperBound);
+ for (unsigned i = 0; i < UpperBound; ++i)
+ Set.insert(i);
+
+ // Make sure pop back returns the values in the reverse order we
+ // inserted them.
+ unsigned Expected = UpperBound;
+ while (!Set.empty())
+ ASSERT_TRUE(--Expected == Set.pop_back_val());
+
+ // Insert again the same elements in the sparse set and make sure
+ // each insertion actually inserts the elements. I.e., check
+ // that the underlying data structure are properly cleared.
+ for (unsigned i = 0; i < UpperBound; ++i)
+ ASSERT_TRUE(Set.insert(i).second);
+}
} // namespace
OpenPOWER on IntegriCloud