| Index: test/unittests/base/bits-unittest.cc
|
| diff --git a/test/unittests/base/bits-unittest.cc b/test/unittests/base/bits-unittest.cc
|
| index 06c1183586732d9e59abafbe3827eb2c2764c203..caedae2408e16f4579f84560b65b1b6996a93f87 100644
|
| --- a/test/unittests/base/bits-unittest.cc
|
| +++ b/test/unittests/base/bits-unittest.cc
|
| @@ -28,6 +28,21 @@ TEST(Bits, CountPopulation32) {
|
| }
|
|
|
|
|
| +TEST(Bits, CountPopulation64) {
|
| + EXPECT_EQ(0u, CountPopulation64(0));
|
| + EXPECT_EQ(1u, CountPopulation64(1));
|
| + EXPECT_EQ(2u, CountPopulation64(0x8000000000000001));
|
| + EXPECT_EQ(8u, CountPopulation64(0x11111111));
|
| + EXPECT_EQ(16u, CountPopulation64(0xf0f0f0f0));
|
| + EXPECT_EQ(24u, CountPopulation64(0xfff0f0ff));
|
| + EXPECT_EQ(32u, CountPopulation64(0xffffffff));
|
| + EXPECT_EQ(16u, CountPopulation64(0x1111111111111111));
|
| + EXPECT_EQ(32u, CountPopulation64(0xf0f0f0f0f0f0f0f0));
|
| + EXPECT_EQ(48u, CountPopulation64(0xfff0f0fffff0f0ff));
|
| + EXPECT_EQ(64u, CountPopulation64(0xffffffffffffffff));
|
| +}
|
| +
|
| +
|
| TEST(Bits, CountLeadingZeros32) {
|
| EXPECT_EQ(32u, CountLeadingZeros32(0));
|
| EXPECT_EQ(31u, CountLeadingZeros32(1));
|
| @@ -38,6 +53,17 @@ TEST(Bits, CountLeadingZeros32) {
|
| }
|
|
|
|
|
| +TEST(Bits, CountLeadingZeros64) {
|
| + EXPECT_EQ(64u, CountLeadingZeros64(0));
|
| + EXPECT_EQ(63u, CountLeadingZeros64(1));
|
| + TRACED_FORRANGE(uint32_t, shift, 0, 63) {
|
| + EXPECT_EQ(63u - shift, CountLeadingZeros64(V8_UINT64_C(1) << shift));
|
| + }
|
| + EXPECT_EQ(36u, CountLeadingZeros64(0x0f0f0f0f));
|
| + EXPECT_EQ(4u, CountLeadingZeros64(0x0f0f0f0f00000000));
|
| +}
|
| +
|
| +
|
| TEST(Bits, CountTrailingZeros32) {
|
| EXPECT_EQ(32u, CountTrailingZeros32(0));
|
| EXPECT_EQ(31u, CountTrailingZeros32(0x80000000));
|
| @@ -48,6 +74,17 @@ TEST(Bits, CountTrailingZeros32) {
|
| }
|
|
|
|
|
| +TEST(Bits, CountTrailingZeros64) {
|
| + EXPECT_EQ(64u, CountTrailingZeros64(0));
|
| + EXPECT_EQ(63u, CountTrailingZeros64(0x8000000000000000));
|
| + TRACED_FORRANGE(uint32_t, shift, 0, 63) {
|
| + EXPECT_EQ(shift, CountTrailingZeros64(V8_UINT64_C(1) << shift));
|
| + }
|
| + EXPECT_EQ(4u, CountTrailingZeros64(0xf0f0f0f0));
|
| + EXPECT_EQ(36u, CountTrailingZeros64(0xf0f0f0f000000000));
|
| +}
|
| +
|
| +
|
| TEST(Bits, IsPowerOfTwo32) {
|
| EXPECT_FALSE(IsPowerOfTwo32(0U));
|
| TRACED_FORRANGE(uint32_t, shift, 0, 31) {
|
|
|