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

Side by Side Diff: base/memory/singleton_unittest.cc

Issue 1308823002: Move Singleton and related structs to namespace base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix more errors Created 5 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/at_exit.h" 5 #include "base/at_exit.h"
6 #include "base/memory/singleton.h" 6 #include "base/memory/singleton.h"
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8 namespace base {
rvargas (doing something else) 2015/08/21 19:43:05 Don't remove this line
rvargas (doing something else) 2015/08/21 19:43:05 I don't like to place tests inside the namespace o
9 namespace { 9 namespace {
10 10
11 COMPILE_ASSERT(DefaultSingletonTraits<int>::kRegisterAtExit == true, a); 11 COMPILE_ASSERT(DefaultSingletonTraits<int>::kRegisterAtExit == true, a);
12 12
13 typedef void (*CallbackFunc)(); 13 typedef void (*CallbackFunc)();
14 14
15 class IntSingleton { 15 class IntSingleton {
16 public: 16 public:
17 static IntSingleton* GetInstance() { 17 static IntSingleton* GetInstance() {
18 return Singleton<IntSingleton>::get(); 18 return Singleton<IntSingleton>::get();
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 } 140 }
141 141
142 void SingletonStatic(CallbackFunc CallOnQuit) { 142 void SingletonStatic(CallbackFunc CallOnQuit) {
143 CallbackSingletonWithStaticTrait::GetInstance()->callback_ = CallOnQuit; 143 CallbackSingletonWithStaticTrait::GetInstance()->callback_ = CallOnQuit;
144 } 144 }
145 145
146 CallbackFunc* GetStaticSingleton() { 146 CallbackFunc* GetStaticSingleton() {
147 return &CallbackSingletonWithStaticTrait::GetInstance()->callback_; 147 return &CallbackSingletonWithStaticTrait::GetInstance()->callback_;
148 } 148 }
149 149
150 } // namespace
rvargas (doing something else) 2015/08/21 19:43:05 nit: Keep the tests outside of the anon namespace?
151 150
152 class SingletonTest : public testing::Test { 151 class SingletonTest : public testing::Test {
153 public: 152 public:
154 SingletonTest() {} 153 SingletonTest() {}
155 154
156 void SetUp() override { 155 void SetUp() override {
157 non_leak_called_ = false; 156 non_leak_called_ = false;
158 leaky_called_ = false; 157 leaky_called_ = false;
159 static_called_ = false; 158 static_called_ = false;
160 } 159 }
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 AlignedTestSingleton<AlignedMemory<128, 128> >* align128 = 277 AlignedTestSingleton<AlignedMemory<128, 128> >* align128 =
279 AlignedTestSingleton<AlignedMemory<128, 128> >::GetInstance(); 278 AlignedTestSingleton<AlignedMemory<128, 128> >::GetInstance();
280 AlignedTestSingleton<AlignedMemory<4096, 4096> >* align4096 = 279 AlignedTestSingleton<AlignedMemory<4096, 4096> >* align4096 =
281 AlignedTestSingleton<AlignedMemory<4096, 4096> >::GetInstance(); 280 AlignedTestSingleton<AlignedMemory<4096, 4096> >::GetInstance();
282 281
283 EXPECT_ALIGNED(align4, 4); 282 EXPECT_ALIGNED(align4, 4);
284 EXPECT_ALIGNED(align32, 32); 283 EXPECT_ALIGNED(align32, 32);
285 EXPECT_ALIGNED(align128, 128); 284 EXPECT_ALIGNED(align128, 128);
286 EXPECT_ALIGNED(align4096, 4096); 285 EXPECT_ALIGNED(align4096, 4096);
287 } 286 }
287
288 } // namespace
289 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698