Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Unified Diff: base/memory/scoped_nsobject_mac_unittest.mm

Issue 9349016: Update scoped_nsobject to be copyable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Correct documentation. Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« base/memory/scoped_nsobject.h ('K') | « base/memory/scoped_nsobject.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« base/memory/scoped_nsobject.h ('K') | « base/memory/scoped_nsobject.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698