1 //===- llvm/unittest/Support/ThreadLocalTest.cpp - ThreadLocal tests ------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "llvm/Support/ThreadLocal.h"
11 #include "gtest/gtest.h"
12 #include <type_traits>
19 class ThreadLocalTest : public ::testing::Test {
26 TEST_F(ThreadLocalTest, Basics) {
27 ThreadLocal<const S> x;
30 std::is_const<std::remove_pointer<decltype(x.get())>::type>::value,
31 "ThreadLocal::get didn't return a pointer to const object");
33 EXPECT_EQ(nullptr, x.get());
37 EXPECT_EQ(&s, x.get());
40 EXPECT_EQ(nullptr, x.get());
45 !std::is_const<std::remove_pointer<decltype(y.get())>::type>::value,
46 "ThreadLocal::get returned a pointer to const object");
48 EXPECT_EQ(nullptr, y.get());
51 EXPECT_EQ(&s, y.get());
54 EXPECT_EQ(nullptr, y.get());