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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 | 63 |
64 // Temporarily disabled while the conversion operator is being removed. | |
jamesr
2014/09/04 21:28:01
better to delete and then re-add, imo
dcheng
2014/09/04 21:36:17
Done.
| |
65 #if 0 | |
64 TEST(RefCountedUnitTest, ScopedRefPtrBooleanOperations) { | 66 TEST(RefCountedUnitTest, ScopedRefPtrBooleanOperations) { |
65 scoped_refptr<SelfAssign> p1 = new SelfAssign; | 67 scoped_refptr<SelfAssign> p1 = new SelfAssign; |
66 scoped_refptr<SelfAssign> p2; | 68 scoped_refptr<SelfAssign> p2; |
67 | 69 |
68 EXPECT_TRUE(p1); | 70 EXPECT_TRUE(p1); |
69 EXPECT_FALSE(!p1); | 71 EXPECT_FALSE(!p1); |
70 | 72 |
71 EXPECT_TRUE(!p2); | 73 EXPECT_TRUE(!p2); |
72 EXPECT_FALSE(p2); | 74 EXPECT_FALSE(p2); |
73 | 75 |
74 EXPECT_NE(p1, p2); | 76 EXPECT_NE(p1, p2); |
75 | 77 |
76 SelfAssign* raw_p = new SelfAssign; | 78 SelfAssign* raw_p = new SelfAssign; |
77 p2 = raw_p; | 79 p2 = raw_p; |
78 EXPECT_NE(p1, p2); | 80 EXPECT_NE(p1, p2); |
79 EXPECT_EQ(raw_p, p2); | 81 EXPECT_EQ(raw_p, p2); |
80 | 82 |
81 p2 = p1; | 83 p2 = p1; |
82 EXPECT_NE(raw_p, p2); | 84 EXPECT_NE(raw_p, p2); |
83 EXPECT_EQ(p1, p2); | 85 EXPECT_EQ(p1, p2); |
84 } | 86 } |
87 #endif | |
OLD | NEW |