Index: base/memory/scoped_nsobject_mac_unittest.mm |
diff --git a/base/memory/scoped_nsobject_mac_unittest.mm b/base/memory/scoped_nsobject_mac_unittest.mm |
new file mode 100644 |
index 0000000000000000000000000000000000000000..5102ea3fb31f2e41461570bf8a69a438dbbaa43f |
--- /dev/null |
+++ b/base/memory/scoped_nsobject_mac_unittest.mm |
@@ -0,0 +1,28 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
Mark Mentovai
2012/02/07 17:13:17
This file doesn’t need _mac in the name.
qsr
2012/02/08 14:59:41
Done.
|
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "base/basictypes.h" |
+#include "base/memory/scoped_nsobject.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+namespace { |
+ |
+TEST(ScopedNsObjectTest, ScopedNSObject) { |
Mark Mentovai
2012/02/07 17:13:17
ScopedNSObjectTest, capital S.
qsr
2012/02/08 14:59:41
Done.
|
+ scoped_nsobject<NSObject> p1([NSObject alloc]); |
Mark Mentovai
2012/02/07 17:13:17
You should also explicitly test the two-argument c
Mark Mentovai
2012/02/07 17:13:17
Technically, you should also call -init.
qsr
2012/02/08 14:59:41
Done.
qsr
2012/02/08 14:59:41
Done.
|
+ ASSERT_EQ(1, [p1 retainCount]); |
Mark Mentovai
2012/02/07 17:13:17
Before you do this, you should ASSERT_TRUE(p1) or
qsr
2012/02/08 14:59:41
Done.
|
+ scoped_nsobject<NSObject> p2(p1); |
+ ASSERT_EQ(p1.get(), p2.get()); |
+ ASSERT_EQ(2, [p1 retainCount]); |
+ p2.reset(); |
+ ASSERT_EQ(nil, p2.get()); |
+ ASSERT_EQ(1, [p1 retainCount]); |
+ { |
+ scoped_nsobject<NSObject> p3 = p1; |
+ ASSERT_EQ(p1.get(), p3.get()); |
+ ASSERT_EQ(2, [p1 retainCount]); |
+ } |
+ ASSERT_EQ(1, [p1 retainCount]); |
+} |
+ |
+} // namespace |