summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ADT/BitVectorTest.cpp
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2017-01-23 19:06:54 +0000
committerMatthias Braun <matze@braunis.de>2017-01-23 19:06:54 +0000
commit617a1994d944ae3151c23bff1f89b56705774257 (patch)
treee7b1cf2b5b4814cf8d234232f7070a953e3086a4 /llvm/unittests/ADT/BitVectorTest.cpp
parent78916e17eacc53bdf22daa04074f892081c87924 (diff)
downloadbcm5719-llvm-617a1994d944ae3151c23bff1f89b56705774257.tar.gz
bcm5719-llvm-617a1994d944ae3151c23bff1f89b56705774257.zip
Add unittests for empty bitvectors.
Addendum to r292575 llvm-svn: 292817
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