OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2009, Google Inc. | 2 * Copyright 2009, Google Inc. |
3 * All rights reserved. | 3 * All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 17 matching lines...) Expand all Loading... |
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
30 */ | 30 */ |
31 | 31 |
32 | 32 |
33 // Tests for the bitfield helper class. | 33 // Tests for the bitfield helper class. |
34 | 34 |
35 #include "testing/gtest/include/gtest/gtest.h" | 35 #include "testing/gtest/include/gtest/gtest.h" |
36 #include "gpu/command_buffer/common/bitfield_helpers.h" | 36 #include "gpu/command_buffer/common/bitfield_helpers.h" |
37 | 37 |
38 namespace command_buffer { | 38 namespace gpu { |
39 | 39 |
40 // Tests that BitField<>::Get returns the right bits. | 40 // Tests that BitField<>::Get returns the right bits. |
41 TEST(BitFieldTest, TestGet) { | 41 TEST(BitFieldTest, TestGet) { |
42 unsigned int value = 0x12345678u; | 42 unsigned int value = 0x12345678u; |
43 EXPECT_EQ(0x8u, (BitField<0, 4>::Get(value))); | 43 EXPECT_EQ(0x8u, (BitField<0, 4>::Get(value))); |
44 EXPECT_EQ(0x45u, (BitField<12, 8>::Get(value))); | 44 EXPECT_EQ(0x45u, (BitField<12, 8>::Get(value))); |
45 EXPECT_EQ(0x12345678u, (BitField<0, 32>::Get(value))); | 45 EXPECT_EQ(0x12345678u, (BitField<0, 32>::Get(value))); |
46 } | 46 } |
47 | 47 |
48 // Tests that BitField<>::MakeValue generates the right bits. | 48 // Tests that BitField<>::MakeValue generates the right bits. |
49 TEST(BitFieldTest, TestMakeValue) { | 49 TEST(BitFieldTest, TestMakeValue) { |
50 EXPECT_EQ(0x00000003u, (BitField<0, 4>::MakeValue(0x3))); | 50 EXPECT_EQ(0x00000003u, (BitField<0, 4>::MakeValue(0x3))); |
51 EXPECT_EQ(0x00023000u, (BitField<12, 8>::MakeValue(0x123))); | 51 EXPECT_EQ(0x00023000u, (BitField<12, 8>::MakeValue(0x123))); |
52 EXPECT_EQ(0x87654321u, (BitField<0, 32>::MakeValue(0x87654321))); | 52 EXPECT_EQ(0x87654321u, (BitField<0, 32>::MakeValue(0x87654321))); |
53 } | 53 } |
54 | 54 |
55 // Tests that BitField<>::Set modifies the right bits. | 55 // Tests that BitField<>::Set modifies the right bits. |
56 TEST(BitFieldTest, TestSet) { | 56 TEST(BitFieldTest, TestSet) { |
57 unsigned int value = 0x12345678u; | 57 unsigned int value = 0x12345678u; |
58 BitField<0, 4>::Set(&value, 0x9); | 58 BitField<0, 4>::Set(&value, 0x9); |
59 EXPECT_EQ(0x12345679u, value); | 59 EXPECT_EQ(0x12345679u, value); |
60 BitField<12, 8>::Set(&value, 0x123); | 60 BitField<12, 8>::Set(&value, 0x123); |
61 EXPECT_EQ(0x12323679u, value); | 61 EXPECT_EQ(0x12323679u, value); |
62 BitField<0, 32>::Set(&value, 0x87654321); | 62 BitField<0, 32>::Set(&value, 0x87654321); |
63 EXPECT_EQ(0x87654321u, value); | 63 EXPECT_EQ(0x87654321u, value); |
64 } | 64 } |
65 | 65 |
66 } // namespace command_buffer | 66 } // namespace gpu |
OLD | NEW |