Jamie Madill | 6b2a0b0 | 2015-08-03 14:15:08 -0400 | [diff] [blame^] | 1 | // |
| 2 | // Copyright 2015 The ANGLE Project Authors. All rights reserved. |
| 3 | // Use of this source code is governed by a BSD-style license that can be |
| 4 | // found in the LICENSE file. |
| 5 | // |
| 6 | // BitSetIteratorTest: |
| 7 | // Test the IterableBitSet class. |
| 8 | // |
| 9 | |
| 10 | #include <gtest/gtest.h> |
| 11 | |
| 12 | #include "common/BitSetIterator.h" |
| 13 | |
| 14 | using namespace angle; |
| 15 | |
| 16 | namespace |
| 17 | { |
| 18 | class BitSetIteratorTest : public testing::Test |
| 19 | { |
| 20 | protected: |
| 21 | std::bitset<40> mStateBits; |
| 22 | }; |
| 23 | |
| 24 | TEST_F(BitSetIteratorTest, Iterator) |
| 25 | { |
| 26 | std::set<unsigned long> originalValues; |
| 27 | originalValues.insert(2); |
| 28 | originalValues.insert(6); |
| 29 | originalValues.insert(8); |
| 30 | originalValues.insert(35); |
| 31 | |
| 32 | for (unsigned long value : originalValues) |
| 33 | { |
| 34 | mStateBits.set(value); |
| 35 | } |
| 36 | |
| 37 | std::set<unsigned long> readValues; |
| 38 | for (unsigned long bit : IterateBitSet(mStateBits)) |
| 39 | { |
| 40 | EXPECT_EQ(1u, originalValues.count(bit)); |
| 41 | EXPECT_EQ(0u, readValues.count(bit)); |
| 42 | readValues.insert(bit); |
| 43 | } |
| 44 | |
| 45 | EXPECT_EQ(originalValues.size(), readValues.size()); |
| 46 | } |
| 47 | |
| 48 | } // anonymous namespace |