Upstreaming browser/ui/uikit_ui_util from iOS.
[chromium-blink-merge.git] / gpu / command_buffer / common / bitfield_helpers_test.cc
blob705e9337e4f2dddfb1eb3e735a18a2ed59714208
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // Tests for the bitfield helper class.
7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "gpu/command_buffer/common/bitfield_helpers.h"
10 namespace gpu {
12 // Tests that BitField<>::Get returns the right bits.
13 TEST(BitFieldTest, TestGet) {
14 unsigned int value = 0x12345678u;
15 EXPECT_EQ(0x8u, (BitField<0, 4>::Get(value)));
16 EXPECT_EQ(0x45u, (BitField<12, 8>::Get(value)));
17 EXPECT_EQ(0x12345678u, (BitField<0, 32>::Get(value)));
20 // Tests that BitField<>::MakeValue generates the right bits.
21 TEST(BitFieldTest, TestMakeValue) {
22 EXPECT_EQ(0x00000003u, (BitField<0, 4>::MakeValue(0x3)));
23 EXPECT_EQ(0x00023000u, (BitField<12, 8>::MakeValue(0x123)));
24 EXPECT_EQ(0x87654321u, (BitField<0, 32>::MakeValue(0x87654321)));
27 // Tests that BitField<>::Set modifies the right bits.
28 TEST(BitFieldTest, TestSet) {
29 unsigned int value = 0x12345678u;
30 BitField<0, 4>::Set(&value, 0x9);
31 EXPECT_EQ(0x12345679u, value);
32 BitField<12, 8>::Set(&value, 0x123);
33 EXPECT_EQ(0x12323679u, value);
34 BitField<0, 32>::Set(&value, 0x87654321);
35 EXPECT_EQ(0x87654321u, value);
38 } // namespace gpu