OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 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 | 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 // This file contains the unit tests for the bit utilities. | 5 // This file contains the unit tests for the bit utilities. |
6 | 6 |
7 #include "base/bits.h" | 7 #include "base/bits.h" |
8 | 8 |
| 9 #include <stddef.h> |
| 10 |
9 #include <limits> | 11 #include <limits> |
10 | 12 |
11 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
12 | 14 |
13 namespace base { | 15 namespace base { |
14 namespace bits { | 16 namespace bits { |
15 | 17 |
16 TEST(BitsTest, Log2Floor) { | 18 TEST(BitsTest, Log2Floor) { |
17 EXPECT_EQ(-1, Log2Floor(0)); | 19 EXPECT_EQ(-1, Log2Floor(0)); |
18 EXPECT_EQ(0, Log2Floor(1)); | 20 EXPECT_EQ(0, Log2Floor(1)); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 EXPECT_EQ(4096ul, Align(1, 4096)); | 56 EXPECT_EQ(4096ul, Align(1, 4096)); |
55 EXPECT_EQ(4096ul, Align(4096, 4096)); | 57 EXPECT_EQ(4096ul, Align(4096, 4096)); |
56 EXPECT_EQ(4096ul, Align(4095, 4096)); | 58 EXPECT_EQ(4096ul, Align(4095, 4096)); |
57 EXPECT_EQ(8192ul, Align(4097, 4096)); | 59 EXPECT_EQ(8192ul, Align(4097, 4096)); |
58 EXPECT_EQ(kSizeTMax - 31, Align(kSizeTMax - 62, 32)); | 60 EXPECT_EQ(kSizeTMax - 31, Align(kSizeTMax - 62, 32)); |
59 EXPECT_EQ(kSizeTMax / 2 + 1, Align(1, kSizeTMax / 2 + 1)); | 61 EXPECT_EQ(kSizeTMax / 2 + 1, Align(1, kSizeTMax / 2 + 1)); |
60 } | 62 } |
61 | 63 |
62 } // namespace bits | 64 } // namespace bits |
63 } // namespace base | 65 } // namespace base |
OLD | NEW |