| Index: base/memory/scoped_ptr_unittest.cc
|
| diff --git a/base/memory/scoped_ptr_unittest.cc b/base/memory/scoped_ptr_unittest.cc
|
| index 7cec70e8a99315d7f6cb240e0e4c5e0674fa8097..697c0b7f9b75acb302becf14ef643ed8e6f31c96 100644
|
| --- a/base/memory/scoped_ptr_unittest.cc
|
| +++ b/base/memory/scoped_ptr_unittest.cc
|
| @@ -656,3 +656,25 @@ TEST(ScopedPtrTest, Conversion) {
|
| scoped_ptr<Super> super2 = SubClassReturn();
|
| super2 = SubClassReturn();
|
| }
|
| +
|
| +TEST(ScopedPtrTest, SelfResetAbortsWithDefaultDeleters) {
|
| + scoped_ptr<int> x(new int);
|
| + EXPECT_DEATH(x.reset(x.get()), "");
|
| +
|
| + scoped_ptr<int[]> y(new int[4]);
|
| + EXPECT_DEATH(y.reset(y.get()), "");
|
| +
|
| + scoped_ptr<int, base::FreeDeleter> z(static_cast<int*>(malloc(sizeof(int))));
|
| + EXPECT_DEATH(z.reset(z.get()), "");
|
| +}
|
| +
|
| +TEST(ScopedPtrTest, SelfResetWithCustomDeleter) {
|
| + // A custom deleter should be able to opt out of self-reset abort behavior.
|
| + struct NoOpDeleter {
|
| + typedef void AllowSelfReset;
|
| + inline void operator()(int*) {}
|
| + };
|
| + scoped_ptr<int> owner(new int);
|
| + scoped_ptr<int, NoOpDeleter> x(owner.get());
|
| + x.reset(x.get());
|
| +}
|
|
|