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

Side by Side Diff: base/ref_counted_unittest.cc

Issue 4192012: Convert implicit scoped_refptr constructor calls to explicit ones, part 1 (Closed) Base URL: http://git.chromium.org/git/chromium.git
Patch Set: fix presubmit Created 10 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "testing/gtest/include/gtest/gtest.h" 5 #include "testing/gtest/include/gtest/gtest.h"
6 #include "base/ref_counted.h" 6 #include "base/ref_counted.h"
7 7
8 namespace { 8 namespace {
9 9
10 class SelfAssign : public base::RefCounted<SelfAssign> { 10 class SelfAssign : public base::RefCounted<SelfAssign> {
11 friend class base::RefCounted<SelfAssign>; 11 friend class base::RefCounted<SelfAssign>;
12 12
13 ~SelfAssign() {} 13 ~SelfAssign() {}
14 }; 14 };
15 15
16 class CheckDerivedMemberAccess : public scoped_refptr<SelfAssign> { 16 class CheckDerivedMemberAccess : public scoped_refptr<SelfAssign> {
17 public: 17 public:
18 CheckDerivedMemberAccess() { 18 CheckDerivedMemberAccess() {
19 // This shouldn't compile if we don't have access to the member variable. 19 // This shouldn't compile if we don't have access to the member variable.
20 SelfAssign** pptr = &ptr_; 20 SelfAssign** pptr = &ptr_;
21 EXPECT_EQ(*pptr, ptr_); 21 EXPECT_EQ(*pptr, ptr_);
22 } 22 }
23 }; 23 };
24 24
25 } // end namespace 25 } // end namespace
26 26
27 TEST(RefCountedUnitTest, TestSelfAssignment) { 27 TEST(RefCountedUnitTest, TestSelfAssignment) {
28 SelfAssign* p = new SelfAssign; 28 SelfAssign* p = new SelfAssign;
29 scoped_refptr<SelfAssign> var = p; 29 scoped_refptr<SelfAssign> var(p);
30 var = var; 30 var = var;
31 EXPECT_EQ(var.get(), p); 31 EXPECT_EQ(var.get(), p);
32 } 32 }
33 33
34 TEST(RefCountedUnitTest, ScopedRefPtrMemberAccess) { 34 TEST(RefCountedUnitTest, ScopedRefPtrMemberAccess) {
35 CheckDerivedMemberAccess check; 35 CheckDerivedMemberAccess check;
36 } 36 }
OLDNEW
« no previous file with comments | « base/metrics/field_trial_unittest.cc ('k') | chrome/browser/automation/automation_resource_message_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698