Initialize Tizen 2.3
[external/chromium.git] / base / memory / ref_counted_unittest.cc
1 // Copyright (c) 2011 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/ref_counted.h"
6 #include "testing/gtest/include/gtest/gtest.h"
7
8 namespace {
9
10 class SelfAssign : public base::RefCounted<SelfAssign> {
11   friend class base::RefCounted<SelfAssign>;
12
13   ~SelfAssign() {}
14 };
15
16 class CheckDerivedMemberAccess : public scoped_refptr<SelfAssign> {
17  public:
18   CheckDerivedMemberAccess() {
19     // This shouldn't compile if we don't have access to the member variable.
20     SelfAssign** pptr = &ptr_;
21     EXPECT_EQ(*pptr, ptr_);
22   }
23 };
24
25 }  // end namespace
26
27 TEST(RefCountedUnitTest, TestSelfAssignment) {
28   SelfAssign* p = new SelfAssign;
29   scoped_refptr<SelfAssign> var(p);
30   var = var;
31   EXPECT_EQ(var.get(), p);
32 }
33
34 TEST(RefCountedUnitTest, ScopedRefPtrMemberAccess) {
35   CheckDerivedMemberAccess check;
36 }