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

Unified Diff: base/memory/singleton_unittest.cc

Issue 2932053002: Use C++11 alignment primitives (Closed)
Patch Set: Fix merge Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/memory/singleton.h ('k') | base/metrics/persistent_memory_allocator.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/singleton_unittest.cc
diff --git a/base/memory/singleton_unittest.cc b/base/memory/singleton_unittest.cc
index a15145c8747145cb3f6e6774890307cc0fa46794..e1292151fab3659bf865b4aa42eea3c936f6d79a 100644
--- a/base/memory/singleton_unittest.cc
+++ b/base/memory/singleton_unittest.cc
@@ -16,6 +16,14 @@ static_assert(DefaultSingletonTraits<int>::kRegisterAtExit == true,
typedef void (*CallbackFunc)();
+template <size_t alignment>
+class AlignedData {
+ public:
+ AlignedData() {}
+ ~AlignedData() {}
+ alignas(alignment) char data_[alignment];
+};
+
class IntSingleton {
public:
static IntSingleton* GetInstance() {
@@ -269,19 +277,17 @@ TEST_F(SingletonTest, Basic) {
EXPECT_EQ(0u, reinterpret_cast<uintptr_t>(ptr) & (align - 1))
TEST_F(SingletonTest, Alignment) {
- using base::AlignedMemory;
-
// Create some static singletons with increasing sizes and alignment
// requirements. By ordering this way, the linker will need to do some work to
// ensure proper alignment of the static data.
AlignedTestSingleton<int32_t>* align4 =
AlignedTestSingleton<int32_t>::GetInstance();
- AlignedTestSingleton<AlignedMemory<32, 32> >* align32 =
- AlignedTestSingleton<AlignedMemory<32, 32> >::GetInstance();
- AlignedTestSingleton<AlignedMemory<128, 128> >* align128 =
- AlignedTestSingleton<AlignedMemory<128, 128> >::GetInstance();
- AlignedTestSingleton<AlignedMemory<4096, 4096> >* align4096 =
- AlignedTestSingleton<AlignedMemory<4096, 4096> >::GetInstance();
+ AlignedTestSingleton<AlignedData<32>>* align32 =
+ AlignedTestSingleton<AlignedData<32>>::GetInstance();
+ AlignedTestSingleton<AlignedData<128>>* align128 =
+ AlignedTestSingleton<AlignedData<128>>::GetInstance();
+ AlignedTestSingleton<AlignedData<4096>>* align4096 =
+ AlignedTestSingleton<AlignedData<4096>>::GetInstance();
EXPECT_ALIGNED(align4, 4);
EXPECT_ALIGNED(align32, 32);
« no previous file with comments | « base/memory/singleton.h ('k') | base/metrics/persistent_memory_allocator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698