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

Unified Diff: tests/SmallAllocatorTest.cpp

Issue 1755293002: update SkSmallAllocator to force internal allocations to be 16-byte aligned (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 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 | « src/core/SkSmallAllocator.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/SmallAllocatorTest.cpp
diff --git a/tests/SmallAllocatorTest.cpp b/tests/SmallAllocatorTest.cpp
index 774e0c9e8982906f09def08548e98b2145ce1cf8..7c9172decc1ce5a4c482ff4e5d85737ae2ee440d 100644
--- a/tests/SmallAllocatorTest.cpp
+++ b/tests/SmallAllocatorTest.cpp
@@ -81,3 +81,16 @@ DEF_TEST(SmallAllocator_pointer, reporter) {
REPORTER_ASSERT(reporter, container != nullptr);
REPORTER_ASSERT(reporter, container->getDummy() == &d);
}
+
+#define check_alignment(reporter, ptr) \
+ REPORTER_ASSERT(reporter, SkIsAlign16((intptr_t)ptr))
+
+DEF_TEST(SmallAllocator_alignment, reporter) {
+ const size_t totalBytes = 1 + 2 + 4 + 8;
+ SkSmallAllocator<4, totalBytes> alloc;
+
+ check_alignment(reporter, alloc.reserveT<uint8_t>());
+ check_alignment(reporter, alloc.reserveT<uint16_t>());
+ check_alignment(reporter, alloc.reserveT<uint32_t>());
+ check_alignment(reporter, alloc.reserveT<uint64_t>());
+}
« no previous file with comments | « src/core/SkSmallAllocator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698