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 <limits> | 9 #include <limits> |
10 | 10 |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/googletest/include/gtest/gtest.h" |
12 | 12 |
13 namespace base { | 13 namespace base { |
14 namespace bits { | 14 namespace bits { |
15 | 15 |
16 TEST(BitsTest, Log2Floor) { | 16 TEST(BitsTest, Log2Floor) { |
17 EXPECT_EQ(-1, Log2Floor(0)); | 17 EXPECT_EQ(-1, Log2Floor(0)); |
18 EXPECT_EQ(0, Log2Floor(1)); | 18 EXPECT_EQ(0, Log2Floor(1)); |
19 EXPECT_EQ(1, Log2Floor(2)); | 19 EXPECT_EQ(1, Log2Floor(2)); |
20 EXPECT_EQ(1, Log2Floor(3)); | 20 EXPECT_EQ(1, Log2Floor(3)); |
21 EXPECT_EQ(2, Log2Floor(4)); | 21 EXPECT_EQ(2, Log2Floor(4)); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 EXPECT_EQ(4096ul, Align(1, 4096)); | 54 EXPECT_EQ(4096ul, Align(1, 4096)); |
55 EXPECT_EQ(4096ul, Align(4096, 4096)); | 55 EXPECT_EQ(4096ul, Align(4096, 4096)); |
56 EXPECT_EQ(4096ul, Align(4095, 4096)); | 56 EXPECT_EQ(4096ul, Align(4095, 4096)); |
57 EXPECT_EQ(8192ul, Align(4097, 4096)); | 57 EXPECT_EQ(8192ul, Align(4097, 4096)); |
58 EXPECT_EQ(kSizeTMax - 31, Align(kSizeTMax - 62, 32)); | 58 EXPECT_EQ(kSizeTMax - 31, Align(kSizeTMax - 62, 32)); |
59 EXPECT_EQ(kSizeTMax / 2 + 1, Align(1, kSizeTMax / 2 + 1)); | 59 EXPECT_EQ(kSizeTMax / 2 + 1, Align(1, kSizeTMax / 2 + 1)); |
60 } | 60 } |
61 | 61 |
62 } // namespace bits | 62 } // namespace bits |
63 } // namespace base | 63 } // namespace base |
OLD | NEW |