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

Side by Side Diff: base/memory/aligned_memory_unittest.cc

Issue 10785019: Enable aligned_memory_unittest.cc on iOS. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Remove logging_unittest from CL Created 8 years, 5 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 | « base/base.gyp ('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 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/memory/aligned_memory.h" 5 #include "base/memory/aligned_memory.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 #define EXPECT_ALIGNED(ptr, align) \ 9 #define EXPECT_ALIGNED(ptr, align) \
10 EXPECT_EQ(0u, reinterpret_cast<uintptr_t>(ptr) & (align - 1)) 10 EXPECT_EQ(0u, reinterpret_cast<uintptr_t>(ptr) & (align - 1))
11 11
12 namespace { 12 namespace {
13 13
14 using base::AlignedMemory; 14 using base::AlignedMemory;
15 15
16 TEST(AlignedMemoryTest, StaticAlignment) { 16 TEST(AlignedMemoryTest, StaticAlignment) {
17 static AlignedMemory<8, 8> raw8; 17 static AlignedMemory<8, 8> raw8;
18 static AlignedMemory<8, 16> raw16; 18 static AlignedMemory<8, 16> raw16;
19 static AlignedMemory<8, 256> raw256; 19 static AlignedMemory<8, 256> raw256;
20 static AlignedMemory<8, 4096> raw4096;
21 20
22 EXPECT_EQ(8u, ALIGNOF(raw8)); 21 EXPECT_EQ(8u, ALIGNOF(raw8));
23 EXPECT_EQ(16u, ALIGNOF(raw16)); 22 EXPECT_EQ(16u, ALIGNOF(raw16));
24 EXPECT_EQ(256u, ALIGNOF(raw256)); 23 EXPECT_EQ(256u, ALIGNOF(raw256));
25 EXPECT_EQ(4096u, ALIGNOF(raw4096));
26 24
27 EXPECT_ALIGNED(raw8.void_data(), 8); 25 EXPECT_ALIGNED(raw8.void_data(), 8);
28 EXPECT_ALIGNED(raw16.void_data(), 16); 26 EXPECT_ALIGNED(raw16.void_data(), 16);
29 EXPECT_ALIGNED(raw256.void_data(), 256); 27 EXPECT_ALIGNED(raw256.void_data(), 256);
28
29 // TODO(ios): These two tests hit an armv7 bug in clang. crbug.com/138066
30 #if !defined(OS_IOS)
Mark Mentovai 2012/07/19 16:20:33 Can you put CPU_ARCH_ARM or whatever it’s called i
leng 2012/07/19 17:07:36 Good idea. Done.
31 static AlignedMemory<8, 4096> raw4096;
32 EXPECT_EQ(4096u, ALIGNOF(raw4096));
30 EXPECT_ALIGNED(raw4096.void_data(), 4096); 33 EXPECT_ALIGNED(raw4096.void_data(), 4096);
34 #endif
31 } 35 }
32 36
37
33 TEST(AlignedMemoryTest, StackAlignment) { 38 TEST(AlignedMemoryTest, StackAlignment) {
34 AlignedMemory<8, 8> raw8; 39 AlignedMemory<8, 8> raw8;
35 AlignedMemory<8, 16> raw16; 40 AlignedMemory<8, 16> raw16;
36 AlignedMemory<8, 256> raw256; 41 AlignedMemory<8, 256> raw256;
37 AlignedMemory<8, 4096> raw4096;
38 42
39 EXPECT_EQ(8u, ALIGNOF(raw8)); 43 EXPECT_EQ(8u, ALIGNOF(raw8));
40 EXPECT_EQ(16u, ALIGNOF(raw16)); 44 EXPECT_EQ(16u, ALIGNOF(raw16));
41 EXPECT_EQ(256u, ALIGNOF(raw256)); 45 EXPECT_EQ(256u, ALIGNOF(raw256));
42 EXPECT_EQ(4096u, ALIGNOF(raw4096));
43 46
44 EXPECT_ALIGNED(raw8.void_data(), 8); 47 EXPECT_ALIGNED(raw8.void_data(), 8);
45 EXPECT_ALIGNED(raw16.void_data(), 16); 48 EXPECT_ALIGNED(raw16.void_data(), 16);
46 EXPECT_ALIGNED(raw256.void_data(), 256); 49 EXPECT_ALIGNED(raw256.void_data(), 256);
50
51 // TODO(ios): These two tests hit an armv7 bug in clang. crbug.com/138066
52 #if !defined(OS_IOS)
53 AlignedMemory<8, 4096> raw4096;
54 EXPECT_EQ(4096u, ALIGNOF(raw4096));
47 EXPECT_ALIGNED(raw4096.void_data(), 4096); 55 EXPECT_ALIGNED(raw4096.void_data(), 4096);
56 #endif // !OS_IOS
48 } 57 }
49 58
50 } // namespace 59 } // namespace
OLDNEW
« no previous file with comments | « base/base.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698