| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/debug/leak_tracker.h" | 5 #include "base/debug/leak_tracker.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 LeakTracker<ClassB> leak_tracker_; | 23 LeakTracker<ClassB> leak_tracker_; |
| 24 }; | 24 }; |
| 25 | 25 |
| 26 #ifndef ENABLE_LEAK_TRACKER | 26 #ifndef ENABLE_LEAK_TRACKER |
| 27 | 27 |
| 28 // If leak tracking is disabled, we should do nothing. | 28 // If leak tracking is disabled, we should do nothing. |
| 29 TEST(LeakTrackerTest, NotEnabled) { | 29 TEST(LeakTrackerTest, NotEnabled) { |
| 30 EXPECT_EQ(-1, LeakTracker<ClassA>::NumLiveInstances()); | 30 EXPECT_EQ(-1, LeakTracker<ClassA>::NumLiveInstances()); |
| 31 EXPECT_EQ(-1, LeakTracker<ClassB>::NumLiveInstances()); | 31 EXPECT_EQ(-1, LeakTracker<ClassB>::NumLiveInstances()); |
| 32 | 32 |
| 33 // Use scoped_ptr so compiler doesn't complain about unused variables. | 33 // Use unique_ptr so compiler doesn't complain about unused variables. |
| 34 std::unique_ptr<ClassA> a1(new ClassA); | 34 std::unique_ptr<ClassA> a1(new ClassA); |
| 35 std::unique_ptr<ClassB> b1(new ClassB); | 35 std::unique_ptr<ClassB> b1(new ClassB); |
| 36 std::unique_ptr<ClassB> b2(new ClassB); | 36 std::unique_ptr<ClassB> b2(new ClassB); |
| 37 | 37 |
| 38 EXPECT_EQ(-1, LeakTracker<ClassA>::NumLiveInstances()); | 38 EXPECT_EQ(-1, LeakTracker<ClassA>::NumLiveInstances()); |
| 39 EXPECT_EQ(-1, LeakTracker<ClassB>::NumLiveInstances()); | 39 EXPECT_EQ(-1, LeakTracker<ClassB>::NumLiveInstances()); |
| 40 } | 40 } |
| 41 | 41 |
| 42 #else | 42 #else |
| 43 | 43 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 // There are no live instances of ClassA, so this should do nothing. | 106 // There are no live instances of ClassA, so this should do nothing. |
| 107 LeakTracker<ClassA>::CheckForLeaks(); | 107 LeakTracker<ClassA>::CheckForLeaks(); |
| 108 } | 108 } |
| 109 | 109 |
| 110 #endif // ENABLE_LEAK_TRACKER | 110 #endif // ENABLE_LEAK_TRACKER |
| 111 | 111 |
| 112 } // namespace | 112 } // namespace |
| 113 | 113 |
| 114 } // namespace debug | 114 } // namespace debug |
| 115 } // namespace base | 115 } // namespace base |
| OLD | NEW |