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

Side by Side 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, 9 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 unified diff | Download patch
« no previous file with comments | « src/core/SkSmallAllocator.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google, Inc 2 * Copyright 2014 Google, Inc
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkSmallAllocator.h" 8 #include "SkSmallAllocator.h"
9 #include "SkTypes.h" 9 #include "SkTypes.h"
10 #include "Test.h" 10 #include "Test.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 74
75 // Test that using a createT with a constructor taking a pointer as a 75 // Test that using a createT with a constructor taking a pointer as a
76 // parameter works as expected. 76 // parameter works as expected.
77 DEF_TEST(SmallAllocator_pointer, reporter) { 77 DEF_TEST(SmallAllocator_pointer, reporter) {
78 SkSmallAllocator<1, 8> alloc; 78 SkSmallAllocator<1, 8> alloc;
79 Dummy d; 79 Dummy d;
80 DummyContainer* container = alloc.createT<DummyContainer>(&d); 80 DummyContainer* container = alloc.createT<DummyContainer>(&d);
81 REPORTER_ASSERT(reporter, container != nullptr); 81 REPORTER_ASSERT(reporter, container != nullptr);
82 REPORTER_ASSERT(reporter, container->getDummy() == &d); 82 REPORTER_ASSERT(reporter, container->getDummy() == &d);
83 } 83 }
84
85 #define check_alignment(reporter, ptr) \
86 REPORTER_ASSERT(reporter, SkIsAlign16((intptr_t)ptr))
87
88 DEF_TEST(SmallAllocator_alignment, reporter) {
89 const size_t totalBytes = 1 + 2 + 4 + 8;
90 SkSmallAllocator<4, totalBytes> alloc;
91
92 check_alignment(reporter, alloc.reserveT<uint8_t>());
93 check_alignment(reporter, alloc.reserveT<uint16_t>());
94 check_alignment(reporter, alloc.reserveT<uint32_t>());
95 check_alignment(reporter, alloc.reserveT<uint64_t>());
96 }
OLDNEW
« 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