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

Unified Diff: cc/base/contiguous_container_unittest.cc

Issue 2122573002: Correct alignment in ContiguousContainer::appendByMoving() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 0u Created 4 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 | « cc/base/contiguous_container.h ('k') | third_party/WebKit/Source/platform/graphics/ContiguousContainer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/base/contiguous_container_unittest.cc
diff --git a/cc/base/contiguous_container_unittest.cc b/cc/base/contiguous_container_unittest.cc
index dde2e62e56c5ab66d10a2317e650a17eb0f399f3..158b787d28dc4a584748e32b8861dc5e3decbc85 100644
--- a/cc/base/contiguous_container_unittest.cc
+++ b/cc/base/contiguous_container_unittest.cc
@@ -511,5 +511,32 @@ TEST(ContiguousContainerTest, CapacityInBytesAfterClear) {
EXPECT_EQ(empty_capacity, list.GetCapacityInBytes());
}
+TEST(ContiguousContainerTest, Alignment) {
+ const size_t max_align = ALIGNOF(long double);
+ ContiguousContainer<Point2D, max_align> list(kMaxPointSize);
+
+ list.AllocateAndConstruct<Point2D>();
+ EXPECT_EQ(0u, reinterpret_cast<intptr_t>(&list.last()) & (max_align - 1));
+ list.AllocateAndConstruct<Point2D>();
+ EXPECT_EQ(0u, reinterpret_cast<intptr_t>(&list.last()) & (max_align - 1));
+ list.AllocateAndConstruct<Point3D>();
+ EXPECT_EQ(0u, reinterpret_cast<intptr_t>(&list.last()) & (max_align - 1));
+ list.AllocateAndConstruct<Point3D>();
+ EXPECT_EQ(0u, reinterpret_cast<intptr_t>(&list.last()) & (max_align - 1));
+ list.AllocateAndConstruct<Point2D>();
+ EXPECT_EQ(0u, reinterpret_cast<intptr_t>(&list.last()) & (max_align - 1));
+
+ list.AppendByMoving(&list[0], sizeof(Point2D));
+ EXPECT_EQ(0u, reinterpret_cast<intptr_t>(&list.last()) & (max_align - 1));
+ list.AppendByMoving(&list[1], sizeof(Point2D));
+ EXPECT_EQ(0u, reinterpret_cast<intptr_t>(&list.last()) & (max_align - 1));
+ list.AppendByMoving(&list[2], sizeof(Point3D));
+ EXPECT_EQ(0u, reinterpret_cast<intptr_t>(&list.last()) & (max_align - 1));
+ list.AppendByMoving(&list[3], sizeof(Point3D));
+ EXPECT_EQ(0u, reinterpret_cast<intptr_t>(&list.last()) & (max_align - 1));
+ list.AppendByMoving(&list[4], sizeof(Point2D));
+ EXPECT_EQ(0u, reinterpret_cast<intptr_t>(&list.last()) & (max_align - 1));
+}
+
} // namespace
} // namespace cc
« no previous file with comments | « cc/base/contiguous_container.h ('k') | third_party/WebKit/Source/platform/graphics/ContiguousContainer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698