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

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

Issue 1852433005: Convert //base to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase after r384946 Created 4 years, 8 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/memory/aligned_memory.h ('k') | base/memory/discardable_memory_allocator.h » ('j') | 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) 2012 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
7 #include <memory>
8
7 #include "build/build_config.h" 9 #include "build/build_config.h"
8 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
9 11
10 #define EXPECT_ALIGNED(ptr, align) \ 12 #define EXPECT_ALIGNED(ptr, align) \
11 EXPECT_EQ(0u, reinterpret_cast<uintptr_t>(ptr) & (align - 1)) 13 EXPECT_EQ(0u, reinterpret_cast<uintptr_t>(ptr) & (align - 1))
12 14
13 namespace { 15 namespace {
14 16
15 using base::AlignedMemory; 17 using base::AlignedMemory;
16 18
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 EXPECT_ALIGNED(p, 256); 87 EXPECT_ALIGNED(p, 256);
86 base::AlignedFree(p); 88 base::AlignedFree(p);
87 89
88 p = base::AlignedAlloc(8, 4096); 90 p = base::AlignedAlloc(8, 4096);
89 EXPECT_TRUE(p); 91 EXPECT_TRUE(p);
90 EXPECT_ALIGNED(p, 4096); 92 EXPECT_ALIGNED(p, 4096);
91 base::AlignedFree(p); 93 base::AlignedFree(p);
92 } 94 }
93 95
94 TEST(AlignedMemoryTest, ScopedDynamicAllocation) { 96 TEST(AlignedMemoryTest, ScopedDynamicAllocation) {
95 scoped_ptr<float, base::AlignedFreeDeleter> p( 97 std::unique_ptr<float, base::AlignedFreeDeleter> p(
96 static_cast<float*>(base::AlignedAlloc(8, 8))); 98 static_cast<float*>(base::AlignedAlloc(8, 8)));
97 EXPECT_TRUE(p.get()); 99 EXPECT_TRUE(p.get());
98 EXPECT_ALIGNED(p.get(), 8); 100 EXPECT_ALIGNED(p.get(), 8);
99 } 101 }
100 102
101 } // namespace 103 } // namespace
OLDNEW
« no previous file with comments | « base/memory/aligned_memory.h ('k') | base/memory/discardable_memory_allocator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698