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

Side by Side Diff: base/linked_ptr_unittest.cc

Issue 3119022: Header cleanup in base.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 4 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
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <string> 5 #include <string>
6 6
7 #include "base/linked_ptr.h" 7 #include "base/linked_ptr.h"
8 8
9 #include "base/string_util.h"
10 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
11 10
12 namespace { 11 namespace {
13 12
14 int num = 0; 13 int num = 0;
15 14
16 std::string history; 15 std::string history;
17 16
18 // Class which tracks allocation/deallocation 17 // Class which tracks allocation/deallocation
19 struct A { 18 struct A {
20 A(): mynum(num++) { history += StringPrintf("A%d ctor\n", mynum); } 19 A(): mynum(num++) { history += base::StringPrintf("A%d ctor\n", mynum); }
21 virtual ~A() { history += StringPrintf("A%d dtor\n", mynum); } 20 virtual ~A() { history += base::StringPrintf("A%d dtor\n", mynum); }
22 virtual void Use() { history += StringPrintf("A%d use\n", mynum); } 21 virtual void Use() { history += base::StringPrintf("A%d use\n", mynum); }
23 int mynum; 22 int mynum;
24 }; 23 };
25 24
26 // Subclass 25 // Subclass
27 struct B: public A { 26 struct B: public A {
28 B() { history += StringPrintf("B%d ctor\n", mynum); } 27 B() { history += base::StringPrintf("B%d ctor\n", mynum); }
29 ~B() { history += StringPrintf("B%d dtor\n", mynum); } 28 ~B() { history += base::StringPrintf("B%d dtor\n", mynum); }
30 virtual void Use() { history += StringPrintf("B%d use\n", mynum); } 29 virtual void Use() { history += base::StringPrintf("B%d use\n", mynum); }
31 }; 30 };
32 31
33 } // namespace 32 } // namespace
34 33
35 TEST(LinkedPtrTest, Test) { 34 TEST(LinkedPtrTest, Test) {
36 { 35 {
37 linked_ptr<A> a0, a1, a2; 36 linked_ptr<A> a0, a1, a2;
38 a0 = a0; 37 a0 = a0;
39 a1 = a2; 38 a1 = a2;
40 ASSERT_EQ(a0.get(), static_cast<A*>(NULL)); 39 ASSERT_EQ(a0.get(), static_cast<A*>(NULL));
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 "A2 dtor\n" 99 "A2 dtor\n"
101 "A0 use\n" 100 "A0 use\n"
102 "A0 use\n" 101 "A0 use\n"
103 "A1 use\n" 102 "A1 use\n"
104 "A3 ctor\n" 103 "A3 ctor\n"
105 "A0 dtor\n" 104 "A0 dtor\n"
106 "A3 dtor\n" 105 "A3 dtor\n"
107 "A1 dtor\n" 106 "A1 dtor\n"
108 ); 107 );
109 } 108 }
OLDNEW
« no previous file with comments | « base/histogram_unittest.cc ('k') | base/logging.cc » ('j') | base/logging.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698