Commit 37219c87 by Shao Committed by Commit Bot

Fix missing return values in bitset_utils.h

This patch adds the missing return value *this in the operator= of class BitSetT BUG=angleproject:1814 Change-Id: I758d62e80e4ade92aac64315f1808ca1eabdc787 Reviewed-on: https://chromium-review.googlesource.com/487423 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent ffa4e611
...@@ -30,7 +30,11 @@ class BitSetT final ...@@ -30,7 +30,11 @@ class BitSetT final
{ {
public: public:
~Reference() {} ~Reference() {}
Reference &operator=(bool x) { mParent->set(mBit, x); } Reference &operator=(bool x)
{
mParent->set(mBit, x);
return *this;
}
operator bool() const { return mParent->test(mBit); } operator bool() const { return mParent->test(mBit); }
private: private:
......
...@@ -89,4 +89,24 @@ TEST_F(BitSetIteratorTest, NonLValueBitset) ...@@ -89,4 +89,24 @@ TEST_F(BitSetIteratorTest, NonLValueBitset)
EXPECT_EQ((mStateBits & otherBits).count(), seenBits.size()); EXPECT_EQ((mStateBits & otherBits).count(), seenBits.size());
} }
// Test bit assignments.
TEST_F(BitSetIteratorTest, BitAssignment)
{
std::set<size_t> originalValues;
originalValues.insert(2);
originalValues.insert(6);
originalValues.insert(8);
originalValues.insert(35);
for (size_t value : originalValues)
{
(mStateBits[value] = false) = true;
}
for (size_t value : originalValues)
{
EXPECT_TRUE(mStateBits.test(value));
}
}
} // anonymous namespace } // anonymous namespace
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment