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

Unified Diff: third_party/WebKit/Source/platform/graphics/ContiguousContainerTest.cpp

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 | « third_party/WebKit/Source/platform/graphics/ContiguousContainer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/graphics/ContiguousContainerTest.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/ContiguousContainerTest.cpp b/third_party/WebKit/Source/platform/graphics/ContiguousContainerTest.cpp
index 656218bec359e6cf451826de31b5b1dcf669c5f3..c037d7d96389150c8d63ccbcb4e53088a62ba46b 100644
--- a/third_party/WebKit/Source/platform/graphics/ContiguousContainerTest.cpp
+++ b/third_party/WebKit/Source/platform/graphics/ContiguousContainerTest.cpp
@@ -524,5 +524,33 @@ TEST(ContiguousContainerTest, CapacityInBytesAfterClear)
EXPECT_EQ(emptyCapacity, list.capacityInBytes());
}
+TEST(ContiguousContainerTest, Alignment)
+{
+ const size_t maxAlign = WTF_ALIGN_OF(long double);
+ ContiguousContainer<Point2D, maxAlign> list(kMaxPointSize);
+
+ list.allocateAndConstruct<Point2D>();
+ EXPECT_EQ(0u, reinterpret_cast<intptr_t>(&list.last()) & (maxAlign - 1));
+ list.allocateAndConstruct<Point2D>();
+ EXPECT_EQ(0u, reinterpret_cast<intptr_t>(&list.last()) & (maxAlign - 1));
+ list.allocateAndConstruct<Point3D>();
+ EXPECT_EQ(0u, reinterpret_cast<intptr_t>(&list.last()) & (maxAlign - 1));
+ list.allocateAndConstruct<Point3D>();
+ EXPECT_EQ(0u, reinterpret_cast<intptr_t>(&list.last()) & (maxAlign - 1));
+ list.allocateAndConstruct<Point2D>();
+ EXPECT_EQ(0u, reinterpret_cast<intptr_t>(&list.last()) & (maxAlign - 1));
+
+ list.appendByMoving(list[0], sizeof(Point2D));
+ EXPECT_EQ(0u, reinterpret_cast<intptr_t>(&list.last()) & (maxAlign - 1));
+ list.appendByMoving(list[1], sizeof(Point2D));
+ EXPECT_EQ(0u, reinterpret_cast<intptr_t>(&list.last()) & (maxAlign - 1));
+ list.appendByMoving(list[2], sizeof(Point3D));
+ EXPECT_EQ(0u, reinterpret_cast<intptr_t>(&list.last()) & (maxAlign - 1));
+ list.appendByMoving(list[3], sizeof(Point3D));
+ EXPECT_EQ(0u, reinterpret_cast<intptr_t>(&list.last()) & (maxAlign - 1));
+ list.appendByMoving(list[4], sizeof(Point2D));
+ EXPECT_EQ(0u, reinterpret_cast<intptr_t>(&list.last()) & (maxAlign - 1));
+}
+
} // namespace
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/ContiguousContainer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698