ADT/PointerIntPairTest.cpp: Appease msc17.
[oota-llvm.git] / unittests / ADT / MakeUniqueTest.cpp
1 //===- llvm/unittest/ADT/MakeUniqueTest.cpp - make_unique unit 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/ADT/STLExtras.h"
11 #include "gtest/gtest.h"
12 #include <tuple>
13 using namespace llvm;
14
15 namespace {
16
17 TEST(MakeUniqueTest, SingleObject) {
18   auto p0 = make_unique<int>();
19   EXPECT_TRUE((bool)p0);
20   EXPECT_EQ(0, *p0);
21
22   auto p1 = make_unique<int>(5);
23   EXPECT_TRUE((bool)p1);
24   EXPECT_EQ(5, *p1);
25
26   auto p2 = make_unique<std::tuple<int, int>>(0, 1);
27   EXPECT_TRUE((bool)p2);
28   EXPECT_EQ(std::make_tuple(0, 1), *p2);
29
30   auto p3 = make_unique<std::tuple<int, int, int>>(0, 1, 2);
31   EXPECT_TRUE((bool)p3);
32   EXPECT_EQ(std::make_tuple(0, 1, 2), *p3);
33
34   auto p4 = make_unique<std::tuple<int, int, int, int>>(0, 1, 2, 3);
35   EXPECT_TRUE((bool)p4);
36   EXPECT_EQ(std::make_tuple(0, 1, 2, 3), *p4);
37
38   auto p5 = make_unique<std::tuple<int, int, int, int, int>>(0, 1, 2, 3, 4);
39   EXPECT_TRUE((bool)p5);
40   EXPECT_EQ(std::make_tuple(0, 1, 2, 3, 4), *p5);
41
42   auto p6 =
43       make_unique<std::tuple<int, int, int, int, int, int>>(0, 1, 2, 3, 4, 5);
44   EXPECT_TRUE((bool)p6);
45   EXPECT_EQ(std::make_tuple(0, 1, 2, 3, 4, 5), *p6);
46
47   auto p7 = make_unique<std::tuple<int, int, int, int, int, int, int>>(
48       0, 1, 2, 3, 4, 5, 6);
49   EXPECT_TRUE((bool)p7);
50   EXPECT_EQ(std::make_tuple(0, 1, 2, 3, 4, 5, 6), *p7);
51
52   auto p8 = make_unique<std::tuple<int, int, int, int, int, int, int, int>>(
53       0, 1, 2, 3, 4, 5, 6, 7);
54   EXPECT_TRUE((bool)p8);
55   EXPECT_EQ(std::make_tuple(0, 1, 2, 3, 4, 5, 6, 7), *p8);
56
57   auto p9 =
58       make_unique<std::tuple<int, int, int, int, int, int, int, int, int>>(
59           0, 1, 2, 3, 4, 5, 6, 7, 8);
60   EXPECT_TRUE((bool)p9);
61   EXPECT_EQ(std::make_tuple(0, 1, 2, 3, 4, 5, 6, 7, 8), *p9);
62
63   auto p10 =
64       make_unique<std::tuple<int, int, int, int, int, int, int, int, int, int>>(
65           0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
66   EXPECT_TRUE((bool)p10);
67   EXPECT_EQ(std::make_tuple(0, 1, 2, 3, 4, 5, 6, 7, 8, 9), *p10);
68 }
69
70 TEST(MakeUniqueTest, Array) {
71   auto p1 = make_unique<int[]>(2);
72   EXPECT_TRUE((bool)p1);
73   EXPECT_EQ(0, p1[0]);
74   EXPECT_EQ(0, p1[1]);
75 }
76 }