| Index: base/memory/scoped_ptr_unittest.cc
|
| diff --git a/base/memory/scoped_ptr_unittest.cc b/base/memory/scoped_ptr_unittest.cc
|
| index 766f4444001e828cd077ca39b85c7dd326779c65..bc6880dba89b2b1a53e0453f07418d156b70424e 100644
|
| --- a/base/memory/scoped_ptr_unittest.cc
|
| +++ b/base/memory/scoped_ptr_unittest.cc
|
| @@ -693,3 +693,24 @@ TEST(ScopedPtrTest, LoggingDoesntConvertToBoolean) {
|
|
|
| EXPECT_EQ(s2.str(), s1.str());
|
| }
|
| +
|
| +TEST(ScopedPtrTest, ReferenceCycle) {
|
| + struct StructB;
|
| + struct StructA {
|
| + scoped_ptr<StructB> b;
|
| + };
|
| +
|
| + struct StructB {
|
| + scoped_ptr<StructA> a;
|
| + };
|
| +
|
| + // Create a reference cycle.
|
| + StructA* a = new StructA;
|
| + a->b.reset(new StructB);
|
| + a->b->a.reset(a);
|
| +
|
| + // Break the cycle by deleting a.
|
| + // Note, the cycle cannot currently be broken by calling reset, because reset
|
| + // sets the new value after deleting the object.
|
| + delete a;
|
| +}
|
|
|