Edit

kc3-lang/angle/src/common/BitSetIterator_unittest.cpp

Branch :

  • Show log

    Commit

  • Author : Jamie Madill
    Date : 2015-08-03 14:15:08
    Hash : 6b2a0b0c
    Message : Reland of "Add Iterable bitset class." This helper allows us to quickly iterate state bits from the Impl/Renderer layers. Re-land with no C++11 usage. BUG=angleproject:1040 TEST=angle_unittests (Mac/Win/Linux) Change-Id: I3b6d5beb2bcff7fa3d45c9220d7c026c64c45d2e Reviewed-on: https://chromium-review.googlesource.com/290153 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org>

  • src/common/BitSetIterator_unittest.cpp
  • //
    // Copyright 2015 The ANGLE Project Authors. All rights reserved.
    // Use of this source code is governed by a BSD-style license that can be
    // found in the LICENSE file.
    //
    // BitSetIteratorTest:
    //   Test the IterableBitSet class.
    //
    
    #include <gtest/gtest.h>
    
    #include "common/BitSetIterator.h"
    
    using namespace angle;
    
    namespace
    {
    class BitSetIteratorTest : public testing::Test
    {
      protected:
        std::bitset<40> mStateBits;
    };
    
    TEST_F(BitSetIteratorTest, Iterator)
    {
        std::set<unsigned long> originalValues;
        originalValues.insert(2);
        originalValues.insert(6);
        originalValues.insert(8);
        originalValues.insert(35);
    
        for (unsigned long value : originalValues)
        {
            mStateBits.set(value);
        }
    
        std::set<unsigned long> readValues;
        for (unsigned long bit : IterateBitSet(mStateBits))
        {
            EXPECT_EQ(1u, originalValues.count(bit));
            EXPECT_EQ(0u, readValues.count(bit));
            readValues.insert(bit);
        }
    
        EXPECT_EQ(originalValues.size(), readValues.size());
    }
    
    }  // anonymous namespace