summaryrefslogtreecommitdiff
path: root/chromium/base/memory/singleton_unittest.cc
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-12 14:27:29 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-13 09:35:20 +0000
commitc30a6232df03e1efbd9f3b226777b07e087a1122 (patch)
treee992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/base/memory/singleton_unittest.cc
parent7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff)
downloadqtwebengine-chromium-85-based.tar.gz
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/base/memory/singleton_unittest.cc')
-rw-r--r--chromium/base/memory/singleton_unittest.cc21
1 files changed, 12 insertions, 9 deletions
diff --git a/chromium/base/memory/singleton_unittest.cc b/chromium/base/memory/singleton_unittest.cc
index 06e53b24cd8..be2253f27f0 100644
--- a/chromium/base/memory/singleton_unittest.cc
+++ b/chromium/base/memory/singleton_unittest.cc
@@ -5,6 +5,7 @@
#include <stdint.h>
#include "base/at_exit.h"
+#include "base/memory/aligned_memory.h"
#include "base/memory/singleton.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -156,10 +157,15 @@ void SingletonStatic(CallbackFunc CallOnQuit) {
}
CallbackFunc* GetStaticSingleton() {
- return &CallbackSingletonWithStaticTrait::GetInstance()->callback_;
+ CallbackSingletonWithStaticTrait* instance =
+ CallbackSingletonWithStaticTrait::GetInstance();
+ if (instance == nullptr) {
+ return nullptr;
+ } else {
+ return &instance->callback_;
+ }
}
-
class SingletonTest : public testing::Test {
public:
SingletonTest() = default;
@@ -273,9 +279,6 @@ TEST_F(SingletonTest, Basic) {
VerifiesCallbacksNotCalled();
}
-#define EXPECT_ALIGNED(ptr, align) \
- EXPECT_EQ(0u, reinterpret_cast<uintptr_t>(ptr) & (align - 1))
-
TEST_F(SingletonTest, Alignment) {
// Create some static singletons with increasing sizes and alignment
// requirements. By ordering this way, the linker will need to do some work to
@@ -289,10 +292,10 @@ TEST_F(SingletonTest, Alignment) {
AlignedTestSingleton<AlignedData<4096>>* align4096 =
AlignedTestSingleton<AlignedData<4096>>::GetInstance();
- EXPECT_ALIGNED(align4, 4);
- EXPECT_ALIGNED(align32, 32);
- EXPECT_ALIGNED(align128, 128);
- EXPECT_ALIGNED(align4096, 4096);
+ EXPECT_TRUE(IsAligned(align4, 4));
+ EXPECT_TRUE(IsAligned(align32, 32));
+ EXPECT_TRUE(IsAligned(align128, 128));
+ EXPECT_TRUE(IsAligned(align4096, 4096));
}
} // namespace