| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/memory/ref_counted.h" | 5 #include "base/memory/ref_counted.h" |
| 6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
| 7 | 7 |
| 8 namespace { | 8 namespace { |
| 9 | 9 |
| 10 class SelfAssign : public base::RefCounted<SelfAssign> { | 10 class SelfAssign : public base::RefCounted<SelfAssign> { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 TEST(RefCountedUnitTest, ScopedRefPtrMemberAccess) { | 53 TEST(RefCountedUnitTest, ScopedRefPtrMemberAccess) { |
| 54 CheckDerivedMemberAccess check; | 54 CheckDerivedMemberAccess check; |
| 55 } | 55 } |
| 56 | 56 |
| 57 TEST(RefCountedUnitTest, ScopedRefPtrToSelf) { | 57 TEST(RefCountedUnitTest, ScopedRefPtrToSelf) { |
| 58 ScopedRefPtrToSelf* check = new ScopedRefPtrToSelf(); | 58 ScopedRefPtrToSelf* check = new ScopedRefPtrToSelf(); |
| 59 EXPECT_FALSE(ScopedRefPtrToSelf::was_destroyed()); | 59 EXPECT_FALSE(ScopedRefPtrToSelf::was_destroyed()); |
| 60 check->SelfDestruct(); | 60 check->SelfDestruct(); |
| 61 EXPECT_TRUE(ScopedRefPtrToSelf::was_destroyed()); | 61 EXPECT_TRUE(ScopedRefPtrToSelf::was_destroyed()); |
| 62 } | 62 } |
| 63 |
| 64 TEST(RefCountedUnitTest, ScopedRefPtrBooleanOperations) { |
| 65 scoped_refptr<SelfAssign> p1 = new SelfAssign; |
| 66 scoped_refptr<SelfAssign> p2; |
| 67 EXPECT_TRUE(p1); |
| 68 EXPECT_FALSE(!p1); |
| 69 EXPECT_TRUE(!p2); |
| 70 EXPECT_FALSE(p2); |
| 71 EXPECT_NE(p1, p2); |
| 72 SelfAssign* raw_p = new SelfAssign; |
| 73 p2 = raw_p; |
| 74 EXPECT_NE(p1, p2); |
| 75 EXPECT_EQ(raw_p, p2); |
| 76 p2 = p1; |
| 77 EXPECT_NE(raw_p, p2); |
| 78 EXPECT_EQ(p1, p2); |
| 79 } |
| OLD | NEW |