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

Side by Side Diff: webrtc/base/scopedptrcollection_unittest.cc

Issue 1920043002: Replace scoped_ptr with unique_ptr in webrtc/base/ (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebased Created 4 years, 7 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 /* 1 /*
2 * Copyright 2014 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2014 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include <memory>
12
11 #include "webrtc/base/scopedptrcollection.h" 13 #include "webrtc/base/scopedptrcollection.h"
12 #include "webrtc/base/gunit.h" 14 #include "webrtc/base/gunit.h"
13 15
14 namespace rtc { 16 namespace rtc {
15 17
16 namespace { 18 namespace {
17 19
18 class InstanceCounter { 20 class InstanceCounter {
19 public: 21 public:
20 explicit InstanceCounter(int* num_instances) 22 explicit InstanceCounter(int* num_instances)
(...skipping 13 matching lines...) Expand all
34 } // namespace 36 } // namespace
35 37
36 class ScopedPtrCollectionTest : public testing::Test { 38 class ScopedPtrCollectionTest : public testing::Test {
37 protected: 39 protected:
38 ScopedPtrCollectionTest() 40 ScopedPtrCollectionTest()
39 : num_instances_(0), 41 : num_instances_(0),
40 collection_(new ScopedPtrCollection<InstanceCounter>()) { 42 collection_(new ScopedPtrCollection<InstanceCounter>()) {
41 } 43 }
42 44
43 int num_instances_; 45 int num_instances_;
44 scoped_ptr<ScopedPtrCollection<InstanceCounter> > collection_; 46 std::unique_ptr<ScopedPtrCollection<InstanceCounter> > collection_;
45 }; 47 };
46 48
47 TEST_F(ScopedPtrCollectionTest, PushBack) { 49 TEST_F(ScopedPtrCollectionTest, PushBack) {
48 EXPECT_EQ(0u, collection_->collection().size()); 50 EXPECT_EQ(0u, collection_->collection().size());
49 EXPECT_EQ(0, num_instances_); 51 EXPECT_EQ(0, num_instances_);
50 const int kNum = 100; 52 const int kNum = 100;
51 for (int i = 0; i < kNum; ++i) { 53 for (int i = 0; i < kNum; ++i) {
52 collection_->PushBack(new InstanceCounter(&num_instances_)); 54 collection_->PushBack(new InstanceCounter(&num_instances_));
53 } 55 }
54 EXPECT_EQ(static_cast<size_t>(kNum), collection_->collection().size()); 56 EXPECT_EQ(static_cast<size_t>(kNum), collection_->collection().size());
55 EXPECT_EQ(kNum, num_instances_); 57 EXPECT_EQ(kNum, num_instances_);
56 collection_.reset(); 58 collection_.reset();
57 EXPECT_EQ(0, num_instances_); 59 EXPECT_EQ(0, num_instances_);
58 } 60 }
59 61
60 TEST_F(ScopedPtrCollectionTest, Remove) { 62 TEST_F(ScopedPtrCollectionTest, Remove) {
61 InstanceCounter* ic = new InstanceCounter(&num_instances_); 63 InstanceCounter* ic = new InstanceCounter(&num_instances_);
62 collection_->PushBack(ic); 64 collection_->PushBack(ic);
63 EXPECT_EQ(1u, collection_->collection().size()); 65 EXPECT_EQ(1u, collection_->collection().size());
64 collection_->Remove(ic); 66 collection_->Remove(ic);
65 EXPECT_EQ(1, num_instances_); 67 EXPECT_EQ(1, num_instances_);
66 collection_.reset(); 68 collection_.reset();
67 EXPECT_EQ(1, num_instances_); 69 EXPECT_EQ(1, num_instances_);
68 delete ic; 70 delete ic;
69 EXPECT_EQ(0, num_instances_); 71 EXPECT_EQ(0, num_instances_);
70 } 72 }
71 73
72 74
73 } // namespace rtc 75 } // namespace rtc
OLDNEW
« no previous file with comments | « webrtc/base/rtccertificategenerator_unittest.cc ('k') | webrtc/base/sharedexclusivelock_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698