OLD | NEW |
---|---|
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/base/bits.h" | 5 #include "src/base/bits.h" |
6 #include "src/base/macros.h" | 6 #include "src/base/macros.h" |
7 #include "testing/gtest-support.h" | 7 #include "testing/gtest-support.h" |
8 | 8 |
9 #ifdef DEBUG | 9 #ifdef DEBUG |
10 #define DISABLE_IN_RELEASE(Name) Name | 10 #define DISABLE_IN_RELEASE(Name) Name |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
77 TEST(Bits, RoundUpToPowerOfTwo32) { | 77 TEST(Bits, RoundUpToPowerOfTwo32) { |
78 TRACED_FORRANGE(uint32_t, shift, 0, 31) { | 78 TRACED_FORRANGE(uint32_t, shift, 0, 31) { |
79 EXPECT_EQ(1u << shift, RoundUpToPowerOfTwo32(1u << shift)); | 79 EXPECT_EQ(1u << shift, RoundUpToPowerOfTwo32(1u << shift)); |
80 } | 80 } |
81 EXPECT_EQ(0u, RoundUpToPowerOfTwo32(0)); | 81 EXPECT_EQ(0u, RoundUpToPowerOfTwo32(0)); |
82 EXPECT_EQ(4u, RoundUpToPowerOfTwo32(3)); | 82 EXPECT_EQ(4u, RoundUpToPowerOfTwo32(3)); |
83 EXPECT_EQ(0x80000000u, RoundUpToPowerOfTwo32(0x7fffffffu)); | 83 EXPECT_EQ(0x80000000u, RoundUpToPowerOfTwo32(0x7fffffffu)); |
84 } | 84 } |
85 | 85 |
86 | 86 |
87 #if 0 | |
88 // TODO(bmeurer): Fix this on NaCL builds. | |
87 TEST(BitsDeathTest, DISABLE_IN_RELEASE(RoundUpToPowerOfTwo32)) { | 89 TEST(BitsDeathTest, DISABLE_IN_RELEASE(RoundUpToPowerOfTwo32)) { |
tfarina
2014/09/02 16:46:02
I think you can also disable this test with:
DISA
Michael Starzinger
2014/09/02 16:55:58
Nope, it was a compile failure, needed to be ifdef
| |
88 ASSERT_DEATH({ RoundUpToPowerOfTwo32(0x80000001u); }, "0x80000000"); | 90 ASSERT_DEATH({ RoundUpToPowerOfTwo32(0x80000001u); }, "0x80000000"); |
89 } | 91 } |
92 #endif | |
90 | 93 |
91 | 94 |
92 TEST(Bits, RoundDownToPowerOfTwo32) { | 95 TEST(Bits, RoundDownToPowerOfTwo32) { |
93 TRACED_FORRANGE(uint32_t, shift, 0, 31) { | 96 TRACED_FORRANGE(uint32_t, shift, 0, 31) { |
94 EXPECT_EQ(1u << shift, RoundDownToPowerOfTwo32(1u << shift)); | 97 EXPECT_EQ(1u << shift, RoundDownToPowerOfTwo32(1u << shift)); |
95 } | 98 } |
96 EXPECT_EQ(0u, RoundDownToPowerOfTwo32(0)); | 99 EXPECT_EQ(0u, RoundDownToPowerOfTwo32(0)); |
97 EXPECT_EQ(4u, RoundDownToPowerOfTwo32(5)); | 100 EXPECT_EQ(4u, RoundDownToPowerOfTwo32(5)); |
98 EXPECT_EQ(0x80000000u, RoundDownToPowerOfTwo32(0x80000001u)); | 101 EXPECT_EQ(0x80000000u, RoundDownToPowerOfTwo32(0x80000001u)); |
99 } | 102 } |
(...skipping 14 matching lines...) Expand all Loading... | |
114 EXPECT_EQ(0u, RotateRight64(0u, shift)); | 117 EXPECT_EQ(0u, RotateRight64(0u, shift)); |
115 } | 118 } |
116 EXPECT_EQ(1u, RotateRight64(1, 0)); | 119 EXPECT_EQ(1u, RotateRight64(1, 0)); |
117 EXPECT_EQ(1u, RotateRight64(2, 1)); | 120 EXPECT_EQ(1u, RotateRight64(2, 1)); |
118 EXPECT_EQ(V8_UINT64_C(0x8000000000000000), RotateRight64(1, 1)); | 121 EXPECT_EQ(V8_UINT64_C(0x8000000000000000), RotateRight64(1, 1)); |
119 } | 122 } |
120 | 123 |
121 } // namespace bits | 124 } // namespace bits |
122 } // namespace base | 125 } // namespace base |
123 } // namespace v8 | 126 } // namespace v8 |
OLD | NEW |