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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« base/memory/scoped_nsobject.h ('K') | « base/memory/scoped_nsobject.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // 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.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/basictypes.h"
6 #include "base/memory/scoped_nsobject.h"
7 #include "testing/gtest/include/gtest/gtest.h"
8
9 namespace {
10
11 TEST(ScopedNsObjectTest, ScopedNSObject) {
Mark Mentovai 2012/02/07 17:13:17 ScopedNSObjectTest, capital S.
qsr 2012/02/08 14:59:41 Done.
12 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.
13 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.
14 scoped_nsobject<NSObject> p2(p1);
15 ASSERT_EQ(p1.get(), p2.get());
16 ASSERT_EQ(2, [p1 retainCount]);
17 p2.reset();
18 ASSERT_EQ(nil, p2.get());
19 ASSERT_EQ(1, [p1 retainCount]);
20 {
21 scoped_nsobject<NSObject> p3 = p1;
22 ASSERT_EQ(p1.get(), p3.get());
23 ASSERT_EQ(2, [p1 retainCount]);
24 }
25 ASSERT_EQ(1, [p1 retainCount]);
26 }
27
28 } // namespace
OLDNEW
« 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