1 //===- llvm/unittest/Support/ThreadLocalTest.cpp - ThreadLocal tests ------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "llvm/Support/ThreadLocal.h"
10 #include "gtest/gtest.h"
11 #include <type_traits>
18 class ThreadLocalTest
: public ::testing::Test
{
25 TEST_F(ThreadLocalTest
, Basics
) {
26 ThreadLocal
<const S
> x
;
29 std::is_const
<std::remove_pointer
<decltype(x
.get())>::type
>::value
,
30 "ThreadLocal::get didn't return a pointer to const object");
32 EXPECT_EQ(nullptr, x
.get());
36 EXPECT_EQ(&s
, x
.get());
39 EXPECT_EQ(nullptr, x
.get());
44 !std::is_const
<std::remove_pointer
<decltype(y
.get())>::type
>::value
,
45 "ThreadLocal::get returned a pointer to const object");
47 EXPECT_EQ(nullptr, y
.get());
50 EXPECT_EQ(&s
, y
.get());
53 EXPECT_EQ(nullptr, y
.get());