summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ADT/BitVectorTest.cpp
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2012-06-16 10:51:07 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2012-06-16 10:51:07 +0000
commit34d6a9e57ad03e093acefc4b33780638d07a2974 (patch)
tree19f7fae9bf28780ec673541314961ed77ad380c5 /llvm/unittests/ADT/BitVectorTest.cpp
parent3bbbeebd3351a2ef3f208544725f90f92f8ca7d4 (diff)
downloadbcm5719-llvm-34d6a9e57ad03e093acefc4b33780638d07a2974.tar.gz
bcm5719-llvm-34d6a9e57ad03e093acefc4b33780638d07a2974.zip
Merge the SmallBitVector and BitVector unit tests with gtest's typed test magic and bring SmallBitVector up to date.
llvm-svn: 158600
Diffstat (limited to 'llvm/unittests/ADT/BitVectorTest.cpp')
-rw-r--r--llvm/unittests/ADT/BitVectorTest.cpp41
1 files changed, 25 insertions, 16 deletions
diff --git a/llvm/unittests/ADT/BitVectorTest.cpp b/llvm/unittests/ADT/BitVectorTest.cpp
index 62aadf6f0e7..d836036aeae 100644
--- a/llvm/unittests/ADT/BitVectorTest.cpp
+++ b/llvm/unittests/ADT/BitVectorTest.cpp
@@ -11,14 +11,23 @@
#ifndef __ppc__
#include "llvm/ADT/BitVector.h"
+#include "llvm/ADT/SmallBitVector.h"
#include "gtest/gtest.h"
using namespace llvm;
namespace {
-TEST(BitVectorTest, TrivialOperation) {
- BitVector Vec;
+// Test fixture
+template <typename T>
+class BitVectorTest : public ::testing::Test { };
+
+// Test both BitVector and SmallBitVector with the same suite of tests.
+typedef ::testing::Types<BitVector, SmallBitVector> BitVectorTestTypes;
+TYPED_TEST_CASE(BitVectorTest, BitVectorTestTypes);
+
+TYPED_TEST(BitVectorTest, TrivialOperation) {
+ TypeParam Vec;
EXPECT_EQ(0U, Vec.count());
EXPECT_EQ(0U, Vec.size());
EXPECT_FALSE(Vec.any());
@@ -42,7 +51,7 @@ TEST(BitVectorTest, TrivialOperation) {
EXPECT_FALSE(Vec.none());
EXPECT_FALSE(Vec.empty());
- BitVector Inv = Vec;
+ TypeParam Inv = Vec;
Inv.flip();
EXPECT_EQ(6U, Inv.count());
EXPECT_EQ(11U, Inv.size());
@@ -77,8 +86,8 @@ TEST(BitVectorTest, TrivialOperation) {
EXPECT_FALSE(Vec[56]);
Vec.resize(61, false);
- BitVector Copy = Vec;
- BitVector Alt(3, false);
+ TypeParam Copy = Vec;
+ TypeParam Alt(3, false);
Alt.resize(6, true);
std::swap(Alt, Vec);
EXPECT_TRUE(Copy == Alt);
@@ -132,7 +141,7 @@ TEST(BitVectorTest, TrivialOperation) {
EXPECT_TRUE(Vec.none());
EXPECT_FALSE(Vec.empty());
- Inv = BitVector().flip();
+ Inv = TypeParam().flip();
EXPECT_EQ(0U, Inv.count());
EXPECT_EQ(0U, Inv.size());
EXPECT_FALSE(Inv.any());
@@ -149,13 +158,13 @@ TEST(BitVectorTest, TrivialOperation) {
EXPECT_TRUE(Vec.empty());
}
-TEST(BitVectorTest, CompoundAssignment) {
- BitVector A;
+TYPED_TEST(BitVectorTest, CompoundAssignment) {
+ TypeParam A;
A.resize(10);
A.set(4);
A.set(7);
- BitVector B;
+ TypeParam B;
B.resize(50);
B.set(5);
B.set(18);
@@ -188,8 +197,8 @@ TEST(BitVectorTest, CompoundAssignment) {
EXPECT_EQ(100U, A.size());
}
-TEST(BitVectorTest, ProxyIndex) {
- BitVector Vec(3);
+TYPED_TEST(BitVectorTest, ProxyIndex) {
+ TypeParam Vec(3);
EXPECT_TRUE(Vec.none());
Vec[0] = Vec[1] = Vec[2] = true;
EXPECT_EQ(Vec.size(), Vec.count());
@@ -197,8 +206,8 @@ TEST(BitVectorTest, ProxyIndex) {
EXPECT_TRUE(Vec.none());
}
-TEST(BitVectorTest, PortableBitMask) {
- BitVector A;
+TYPED_TEST(BitVectorTest, PortableBitMask) {
+ TypeParam A;
const uint32_t Mask1[] = { 0x80000000, 6, 5 };
A.resize(10);
@@ -244,9 +253,9 @@ TEST(BitVectorTest, PortableBitMask) {
EXPECT_EQ(64-4u, A.count());
}
-TEST(BitVectorTest, BinOps) {
- BitVector A;
- BitVector B;
+TYPED_TEST(BitVectorTest, BinOps) {
+ TypeParam A;
+ TypeParam B;
A.resize(65);
EXPECT_FALSE(A.anyCommon(B));
OpenPOWER on IntegriCloud