OLD | NEW |
---|---|
(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 | |
OLD | NEW |