From e7962c9897cf3ac5fc731702d5e5d8963fc5c723 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Wed, 10 Feb 2010 05:54:04 +0000 Subject: Implement operators |=, &=, and ^= for SmallBitVector, and remove the restriction in BitVector for |= and ^= that the operand must be the same length. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95768 91177308-0d34-0410-b5e6-96231b3b80d8 --- unittests/ADT/BitVectorTest.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'unittests/ADT/BitVectorTest.cpp') diff --git a/unittests/ADT/BitVectorTest.cpp b/unittests/ADT/BitVectorTest.cpp index f04eb60179..4d4f5fd63c 100644 --- a/unittests/ADT/BitVectorTest.cpp +++ b/unittests/ADT/BitVectorTest.cpp @@ -138,5 +138,45 @@ TEST(BitVectorTest, TrivialOperation) { EXPECT_TRUE(Vec.empty()); } +TEST(BitVectorTest, CompoundAssignment) { + BitVector A; + A.resize(10); + A.set(4); + A.set(7); + + BitVector B; + B.resize(50); + B.set(5); + B.set(18); + + A |= B; + EXPECT_TRUE(A.test(4)); + EXPECT_TRUE(A.test(5)); + EXPECT_TRUE(A.test(7)); + EXPECT_TRUE(A.test(18)); + EXPECT_EQ(A.count(), 4); + EXPECT_EQ(A.size(), 50); + + B.resize(10); + B.set(); + B.reset(2); + B.reset(7); + A &= B; + EXPECT_FALSE(A.test(2)); + EXPECT_FALSE(A.test(7)); + EXPECT_EQ(A.size(), 50); + EXPECT_EQ(A.count(), 2); + + B.resize(100); + B.set(); + + A ^= B; + EXPECT_TRUE(A.test(2)); + EXPECT_TRUE(A.test(7)); + EXPECT_EQ(A.size(), 100); + EXPECT_EQ(A.count(), 98); } + +} + #endif -- cgit v1.2.3-70-g09d2