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

Side by Side Diff: tests/RecordTest.cpp

Issue 721313002: Deparameterize SkVarAlloc. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fixes: update unit test, remove unused header, start at 16 bytes Created 6 years, 1 month 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/SkVarAlloc.cpp ('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 "Test.h" 8 #include "Test.h"
9 9
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 78
79 #undef APPEND 79 #undef APPEND
80 80
81 template <typename T> 81 template <typename T>
82 static bool is_aligned(const T* p) { 82 static bool is_aligned(const T* p) {
83 return (((uintptr_t)p) & (sizeof(T) - 1)) == 0; 83 return (((uintptr_t)p) & (sizeof(T) - 1)) == 0;
84 } 84 }
85 85
86 DEF_TEST(Record_Alignment, r) { 86 DEF_TEST(Record_Alignment, r) {
87 SkRecord record; 87 SkRecord record;
88
89 // Of course a byte's always aligned.
90 REPORTER_ASSERT(r, is_aligned(record.alloc<uint8_t>())); 88 REPORTER_ASSERT(r, is_aligned(record.alloc<uint8_t>()));
91
92 // (If packed tightly, the rest below here would be off by one.)
93
94 // It happens that the first implementation always aligned to 4 bytes,
95 // so these two were always correct.
96 REPORTER_ASSERT(r, is_aligned(record.alloc<uint16_t>())); 89 REPORTER_ASSERT(r, is_aligned(record.alloc<uint16_t>()));
97 REPORTER_ASSERT(r, is_aligned(record.alloc<uint32_t>())); 90 REPORTER_ASSERT(r, is_aligned(record.alloc<uint32_t>()));
98
99 // These two are regression tests (void* only on 64-bit machines).
100 REPORTER_ASSERT(r, is_aligned(record.alloc<uint64_t>()));
101 REPORTER_ASSERT(r, is_aligned(record.alloc<void*>())); 91 REPORTER_ASSERT(r, is_aligned(record.alloc<void*>()));
102 92
103 // We're not testing beyond sizeof(void*), which is where the current implem entation will break. 93 // It's not clear if we care that 8-byte values are aligned on 32-bit machin es.
94 if (sizeof(void*) == 8) {
95 REPORTER_ASSERT(r, is_aligned(record.alloc<double>()));
96 REPORTER_ASSERT(r, is_aligned(record.alloc<uint64_t>()));
97 }
104 } 98 }
105 99
OLDNEW
« no previous file with comments | « src/core/SkVarAlloc.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698