blob: ba392d6c470a6a12f6bde0a0ce6d79b065f5fffd [file] [log] [blame]
license.botbf09a502008-08-24 00:55:551// 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
3// found in the LICENSE file.
initial.commitd7cae122008-07-26 21:49:384
5#include "testing/gtest/include/gtest/gtest.h"
6#include "base/ref_counted.h"
7
[email protected]935f7762009-01-10 00:53:138namespace {
9
initial.commitd7cae122008-07-26 21:49:3810class SelfAssign : public base::RefCounted<SelfAssign> {
11};
12
[email protected]935f7762009-01-10 00:53:1313class CheckDerivedMemberAccess : public scoped_refptr<SelfAssign> {
14 public:
15 CheckDerivedMemberAccess() {
16 // This shouldn't compile if we don't have access to the member variable.
17 SelfAssign** pptr = &ptr_;
18 EXPECT_EQ(*pptr, ptr_);
19 }
20};
21
22} // end namespace
23
initial.commitd7cae122008-07-26 21:49:3824TEST(RefCountedUnitTest, TestSelfAssignment) {
25 SelfAssign* p = new SelfAssign;
26 scoped_refptr<SelfAssign> var = p;
27 var = var;
28 EXPECT_EQ(var.get(), p);
29}
license.botbf09a502008-08-24 00:55:5530
[email protected]935f7762009-01-10 00:53:1331TEST(RefCountedUnitTest, ScopedRefPtrMemberAccess) {
32 CheckDerivedMemberAccess check;
33}