dd4d706f5cf5223084cbb9cec78cc3cfcc2ca12e
[oota-llvm.git] / unittests / Support / ThreadLocalTest.cpp
1 //===- llvm/unittest/Support/ThreadLocalTest.cpp - Therad Local tests   ---===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #include "llvm/Support/ThreadLocal.h"
11 #include "gtest/gtest.h"
12
13 using namespace llvm;
14 using namespace sys;
15
16 namespace {
17
18 class ThreadLocalTest : public ::testing::Test {
19 };
20
21 struct S {
22   int i;
23 };
24
25 TEST_F(ThreadLocalTest, Basics) {
26   ThreadLocal<const S> x;
27
28   EXPECT_EQ(0, x.get());
29
30   S s;
31   x.set(&s);
32   EXPECT_EQ(&s, x.get());
33
34   x.erase();
35   EXPECT_EQ(0, x.get());
36 }
37
38 }