OLD | NEW |
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 Loading... |
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 } |
OLD | NEW |