summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ADT/BitVectorTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/unittests/ADT/BitVectorTest.cpp')
-rw-r--r--llvm/unittests/ADT/BitVectorTest.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/llvm/unittests/ADT/BitVectorTest.cpp b/llvm/unittests/ADT/BitVectorTest.cpp
index 78fd5ce6567..76e796be9eb 100644
--- a/llvm/unittests/ADT/BitVectorTest.cpp
+++ b/llvm/unittests/ADT/BitVectorTest.cpp
@@ -425,5 +425,42 @@ TYPED_TEST(BitVectorTest, MoveAssignment) {
EXPECT_EQ(C, B);
}
+template<class TypeParam>
+static void testEmpty(const TypeParam &A) {
+ EXPECT_TRUE(A.empty());
+ EXPECT_EQ((size_t)0, A.size());
+ EXPECT_EQ((size_t)0, A.count());
+ EXPECT_FALSE(A.any());
+ EXPECT_TRUE(A.all());
+ EXPECT_TRUE(A.none());
+ EXPECT_EQ(-1, A.find_first());
+ EXPECT_EQ(A, TypeParam());
+}
+
+/// Tests whether BitVector behaves well with Bits==nullptr, Capacity==0
+TYPED_TEST(BitVectorTest, EmptyVector) {
+ TypeParam A;
+ testEmpty(A);
+
+ TypeParam B;
+ B.reset();
+ testEmpty(B);
+
+ TypeParam C;
+ C.clear();
+ testEmpty(C);
+
+ TypeParam D(A);
+ testEmpty(D);
+
+ TypeParam E;
+ E = A;
+ testEmpty(E);
+
+ TypeParam F;
+ E.reset(A);
+ testEmpty(E);
+}
+
}
#endif
OpenPOWER on IntegriCloud