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

Side by Side Diff: cc/base/contiguous_container_unittest.cc

Issue 2932053002: Use C++11 alignment primitives (Closed)
Patch Set: Put back ALIGNAS Created 3 years, 6 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stddef.h> 5 #include <stddef.h>
6 6
7 #include <iterator> 7 #include <iterator>
8 8
9 #include "cc/base/contiguous_container.h" 9 #include "cc/base/contiguous_container.h"
10 #include "testing/gmock/include/gmock/gmock.h" 10 #include "testing/gmock/include/gmock/gmock.h"
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 list2.AllocateAndConstruct<Point2D>(); 209 list2.AllocateAndConstruct<Point2D>();
210 210
211 // Same object was created in both lists, but their memory usages grew 211 // Same object was created in both lists, but their memory usages grew
212 // differently, based on initial_size values lists were created with. 212 // differently, based on initial_size values lists were created with.
213 EXPECT_NE(list1.MemoryUsageInBytes(), list2.MemoryUsageInBytes()); 213 EXPECT_NE(list1.MemoryUsageInBytes(), list2.MemoryUsageInBytes());
214 EXPECT_GE(list1.MemoryUsageInBytes(), memory_usage1 + initial_size1); 214 EXPECT_GE(list1.MemoryUsageInBytes(), memory_usage1 + initial_size1);
215 EXPECT_GE(list2.MemoryUsageInBytes(), memory_usage2 + initial_size2); 215 EXPECT_GE(list2.MemoryUsageInBytes(), memory_usage2 + initial_size2);
216 } 216 }
217 217
218 TEST(ContiguousContainerTest, Alignment) { 218 TEST(ContiguousContainerTest, Alignment) {
219 const size_t max_align = ALIGNOF(long double); 219 const size_t max_align = alignof(long double);
220 ContiguousContainer<Point2D, max_align> list(kMaxPointSize); 220 ContiguousContainer<Point2D, max_align> list(kMaxPointSize);
221 221
222 list.AllocateAndConstruct<Point2D>(); 222 list.AllocateAndConstruct<Point2D>();
223 EXPECT_EQ(0u, reinterpret_cast<intptr_t>(&list.last()) & (max_align - 1)); 223 EXPECT_EQ(0u, reinterpret_cast<intptr_t>(&list.last()) & (max_align - 1));
224 list.AllocateAndConstruct<Point2D>(); 224 list.AllocateAndConstruct<Point2D>();
225 EXPECT_EQ(0u, reinterpret_cast<intptr_t>(&list.last()) & (max_align - 1)); 225 EXPECT_EQ(0u, reinterpret_cast<intptr_t>(&list.last()) & (max_align - 1));
226 list.AllocateAndConstruct<Point3D>(); 226 list.AllocateAndConstruct<Point3D>();
227 EXPECT_EQ(0u, reinterpret_cast<intptr_t>(&list.last()) & (max_align - 1)); 227 EXPECT_EQ(0u, reinterpret_cast<intptr_t>(&list.last()) & (max_align - 1));
228 list.AllocateAndConstruct<Point3D>(); 228 list.AllocateAndConstruct<Point3D>();
229 EXPECT_EQ(0u, reinterpret_cast<intptr_t>(&list.last()) & (max_align - 1)); 229 EXPECT_EQ(0u, reinterpret_cast<intptr_t>(&list.last()) & (max_align - 1));
230 list.AllocateAndConstruct<Point2D>(); 230 list.AllocateAndConstruct<Point2D>();
231 EXPECT_EQ(0u, reinterpret_cast<intptr_t>(&list.last()) & (max_align - 1)); 231 EXPECT_EQ(0u, reinterpret_cast<intptr_t>(&list.last()) & (max_align - 1));
232 } 232 }
233 233
234 } // namespace 234 } // namespace
235 } // namespace cc 235 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698