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

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

Issue 2425683003: Change RefCountedObject to use perfect forwarding. (Closed)
Patch Set: Created 4 years, 2 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
« webrtc/base/refcount.h.pump ('K') | « webrtc/base/refcount.h.pump ('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 /*
2 * Copyright 2016 The WebRTC Project Authors. All rights reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include <string>
12
13 #include "webrtc/base/gunit.h"
14 #include "webrtc/base/refcount.h"
15
16 namespace rtc {
17
18 namespace {
19
20 class A {
21 public:
22 A() {}
23
24 RTC_DISALLOW_COPY_AND_ASSIGN(A);
tommi 2016/10/18 15:57:58 private
perkj_webrtc 2016/10/19 00:43:14 Done.
25 };
26
27 class Aref : public RefCountInterface {
28 public:
29 Aref() {}
30
31 protected:
32 virtual ~Aref() {}
33 };
34
35 class Bref : public RefCountInterface {
36 public:
37 Bref(std::unique_ptr<A> a) : a_(std::move(a)) {}
38
39 protected:
40 virtual ~Bref() {}
41
42 public:
43 std::unique_ptr<A> a_;
44 };
45
46 } // namespace
47
48 TEST(RefCountedObject, Basic) {
49 scoped_refptr<RefCountedObject<Aref>> aref(new RefCountedObject<Aref>());
hbos 2016/10/18 17:50:04 Can you add more tests to make sure a constructor
perkj_webrtc 2016/10/19 00:43:14 done. Since we use pump we don't need to test all
50 EXPECT_TRUE(aref->HasOneRef());
51 EXPECT_EQ(2, aref->AddRef());
52 EXPECT_EQ(1, aref->Release());
53 }
54
55 TEST(RefCountedObject, SupportRValuesInCtor) {
56 std::unique_ptr<A> a(new A());
57 scoped_refptr<Bref> bref(new RefCountedObject<Bref>(std::move(a)));
58 EXPECT_TRUE(bref->a_.get() != nullptr);
59 EXPECT_TRUE(a.get() == nullptr);
60 }
61
62 } // namespace rtc
OLDNEW
« webrtc/base/refcount.h.pump ('K') | « webrtc/base/refcount.h.pump ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698