Chromium Code Reviews| Index: base/bits_unittest.cc |
| diff --git a/base/bits_unittest.cc b/base/bits_unittest.cc |
| index e913d6ae598f393f4d2b8ff1b3abaa173b4d3a64..1dad0f453199dac37a2c45da57765f72a2a15f82 100644 |
| --- a/base/bits_unittest.cc |
| +++ b/base/bits_unittest.cc |
| @@ -5,6 +5,9 @@ |
| // This file contains the unit tests for the bit utilities. |
| #include "base/bits.h" |
| + |
| +#include <limits> |
| + |
| #include "testing/gtest/include/gtest/gtest.h" |
| namespace base { |
| @@ -44,5 +47,17 @@ TEST(BitsTest, Log2Ceiling) { |
| EXPECT_EQ(32, Log2Ceiling(0xffffffffU)); |
| } |
| +TEST(BitsTest, Align) { |
|
Lei Zhang
2015/07/24 18:59:55
Thanks!
|
| + const size_t kSizeTMax = std::numeric_limits<size_t>::max(); |
| + EXPECT_EQ(0ul, Align(0, 4)); |
| + EXPECT_EQ(4ul, Align(1, 4)); |
| + EXPECT_EQ(4096ul, Align(1, 4096)); |
| + EXPECT_EQ(4096ul, Align(4096, 4096)); |
| + EXPECT_EQ(4096ul, Align(4095, 4096)); |
| + EXPECT_EQ(8192ul, Align(4097, 4096)); |
| + EXPECT_EQ(kSizeTMax - 31, Align(kSizeTMax - 62, 32)); |
| + EXPECT_EQ(kSizeTMax / 2 + 1, Align(1, kSizeTMax / 2 + 1)); |
| +} |
| + |
| } // namespace bits |
| } // namespace base |