summaryrefslogtreecommitdiffstats
path: root/gnu/llvm/unittests/ADT/SparseSetTest.cpp
diff options
context:
space:
mode:
authorpatrick <patrick@openbsd.org>2017-01-14 19:55:43 +0000
committerpatrick <patrick@openbsd.org>2017-01-14 19:55:43 +0000
commitbd3306aecb3a15e8967143b8cdbbccf2b1b19b74 (patch)
tree309a8132b44564b9e634c0da6815187ce8eab27c /gnu/llvm/unittests/ADT/SparseSetTest.cpp
parentkillp -a should not kill the window if only one pane. (diff)
downloadwireguard-openbsd-bd3306aecb3a15e8967143b8cdbbccf2b1b19b74.tar.xz
wireguard-openbsd-bd3306aecb3a15e8967143b8cdbbccf2b1b19b74.zip
Import LLVM 3.9.1 including clang and lld.
Diffstat (limited to 'gnu/llvm/unittests/ADT/SparseSetTest.cpp')
-rw-r--r--gnu/llvm/unittests/ADT/SparseSetTest.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/gnu/llvm/unittests/ADT/SparseSetTest.cpp b/gnu/llvm/unittests/ADT/SparseSetTest.cpp
index eb0e0db283b..4db7a7d61fb 100644
--- a/gnu/llvm/unittests/ADT/SparseSetTest.cpp
+++ b/gnu/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