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/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
686 TEST(ScopedPtrTest, LoggingDoesntConvertToBoolean) { | 686 TEST(ScopedPtrTest, LoggingDoesntConvertToBoolean) { |
687 scoped_ptr<int> x(new int); | 687 scoped_ptr<int> x(new int); |
688 std::stringstream s1; | 688 std::stringstream s1; |
689 s1 << x; | 689 s1 << x; |
690 | 690 |
691 std::stringstream s2; | 691 std::stringstream s2; |
692 s2 << x.get(); | 692 s2 << x.get(); |
693 | 693 |
694 EXPECT_EQ(s2.str(), s1.str()); | 694 EXPECT_EQ(s2.str(), s1.str()); |
695 } | 695 } |
696 | |
697 TEST(ScopedPtrTest, ReferenceCycle) { | |
698 struct StructB; | |
699 struct StructA { | |
700 scoped_ptr<StructB> b; | |
701 }; | |
702 | |
703 struct StructB { | |
704 scoped_ptr<StructA> a; | |
705 }; | |
706 | |
707 // Create a reference cycle. | |
708 StructA* a = new StructA; | |
709 a->b.reset(new StructB); | |
710 a->b->a.reset(a); | |
711 | |
712 // Break the cycle by calling |reset()|. | |
Peter Kasting
2015/09/23 03:09:44
Nit: No || around function names
I might add to t
Anand Mistry (off Chromium)
2015/09/23 04:04:21
Done and done.
| |
713 a->b.reset(); | |
714 } | |
OLD | NEW |