Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2564)

Unified Diff: base/bits_unittest.cc

Issue 1249643007: Align base::Pickle allocations to 4k boundaries (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@accounting_fix
Patch Set: Nits test Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/bits.h ('k') | base/memory/discardable_shared_memory.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « base/bits.h ('k') | base/memory/discardable_shared_memory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698