From 3f5e91565273e3f4639d37ee5a5b856699e8c9e5 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 30 Apr 2010 20:50:28 +0000 Subject: [PATCH] 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 --- include/llvm/ADT/BitVector.h | 5 +++++ unittests/ADT/BitVectorTest.cpp | 18 +++++++++++++++--- unittests/ADT/SmallBitVectorTest.cpp | 1 + 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/include/llvm/ADT/BitVector.h b/include/llvm/ADT/BitVector.h index 3a86b0d3436..9dcb9e106f2 100644 --- a/include/llvm/ADT/BitVector.h +++ b/include/llvm/ADT/BitVector.h @@ -49,6 +49,11 @@ public: ~reference() {} + reference &operator=(reference t) { + *this = bool(t); + return *this; + } + reference& operator=(bool t) { if (t) *WordRef |= 1L << BitPos; diff --git a/unittests/ADT/BitVectorTest.cpp b/unittests/ADT/BitVectorTest.cpp index 4fe11c1d17a..a9fc133c72e 100644 --- a/unittests/ADT/BitVectorTest.cpp +++ b/unittests/ADT/BitVectorTest.cpp @@ -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 diff --git a/unittests/ADT/SmallBitVectorTest.cpp b/unittests/ADT/SmallBitVectorTest.cpp index e12abfe20da..9c69aad5a97 100644 --- a/unittests/ADT/SmallBitVectorTest.cpp +++ b/unittests/ADT/SmallBitVectorTest.cpp @@ -185,4 +185,5 @@ TEST(SmallBitVectorTest, ProxyIndex) { Vec[2] = Vec[1] = Vec[0] = false; EXPECT_TRUE(Vec.none()); } + } -- 2.34.1