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

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

Issue 1513423002: Add WrapUnique helper to wrap a raw pointer in a std::unique_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments and add comments. Created 5 years 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/ptr_util.h ('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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/memory/ptr_util.h"
6
7 #include "testing/gtest/include/gtest/gtest.h"
8
9 namespace base {
10
11 namespace {
12
13 class DeleteCounter {
14 public:
15 DeleteCounter() { ++count_; }
16 ~DeleteCounter() { --count_; }
17
18 static size_t count() { return count_; }
19
20 private:
21 static size_t count_;
22 };
23
24 size_t DeleteCounter::count_ = 0;
25
26 } // namespace
27
28 TEST(PtrUtilTest, WrapUnique) {
29 EXPECT_EQ(0u, DeleteCounter::count());
30 DeleteCounter* counter = new DeleteCounter;
31 EXPECT_EQ(1u, DeleteCounter::count());
32 std::unique_ptr<DeleteCounter> owned_counter = WrapUnique(counter);
33 EXPECT_EQ(1u, DeleteCounter::count());
34 owned_counter.reset();
35 EXPECT_EQ(0u, DeleteCounter::count());
36 }
37
38 } // namespace base
OLDNEW
« no previous file with comments | « base/memory/ptr_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698