Update BitVectorTest.cpp to stay in sync with SmallBitVectorTest.cpp,

and fix a bug in BitVector's reference proxy class which this exposed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@102768 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Gohman 2010-04-30 20:50:28 +00:00
parent 8fcd418d6e
commit 3f5e915652
3 changed files with 21 additions and 3 deletions

View File

@ -49,6 +49,11 @@ public:
~reference() {}
reference &operator=(reference t) {
*this = bool(t);
return *this;
}
reference& operator=(bool t) {
if (t)
*WordRef |= 1L << BitPos;

View File

@ -7,7 +7,9 @@
//
//===----------------------------------------------------------------------===//
#ifndef XFAIL
// Some of these tests fail on PowerPC for unknown reasons.
#ifndef __ppc__
#include "llvm/ADT/BitVector.h"
#include "gtest/gtest.h"
@ -56,7 +58,7 @@ TEST(BitVectorTest, TrivialOperation) {
Vec.resize(26, true);
Vec.resize(29, false);
Vec.resize(33, true);
Vec.resize(61, false);
Vec.resize(57, false);
unsigned Count = 0;
for (unsigned i = Vec.find_first(); i != -1u; i = Vec.find_next(i)) {
++Count;
@ -67,7 +69,8 @@ TEST(BitVectorTest, TrivialOperation) {
EXPECT_EQ(Count, 23u);
EXPECT_FALSE(Vec[0]);
EXPECT_TRUE(Vec[32]);
EXPECT_FALSE(Vec[60]);
EXPECT_FALSE(Vec[56]);
Vec.resize(61, false);
BitVector Copy = Vec;
BitVector Alt(3, false);
@ -177,6 +180,15 @@ TEST(BitVectorTest, CompoundAssignment) {
EXPECT_EQ(100U, A.size());
}
TEST(BitVectorTest, ProxyIndex) {
BitVector Vec(3);
EXPECT_TRUE(Vec.none());
Vec[0] = Vec[1] = Vec[2] = true;
EXPECT_EQ(Vec.size(), Vec.count());
Vec[2] = Vec[1] = Vec[0] = false;
EXPECT_TRUE(Vec.none());
}
}
#endif

View File

@ -185,4 +185,5 @@ TEST(SmallBitVectorTest, ProxyIndex) {
Vec[2] = Vec[1] = Vec[0] = false;
EXPECT_TRUE(Vec.none());
}
}