[LLVM][NFC] remove unused fields
[llvm-complete.git] / unittests / ADT / MakeUniqueTest.cpp
blobd643d09df7ad30c883de1722aca0538bd18245c2
1 //===- llvm/unittest/ADT/MakeUniqueTest.cpp - std::make_unique unit tests ------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
9 #include "llvm/ADT/STLExtras.h"
10 #include "gtest/gtest.h"
11 #include <tuple>
12 using namespace llvm;
14 namespace {
16 TEST(MakeUniqueTest, SingleObject) {
17 auto p0 = std::make_unique<int>();
18 EXPECT_TRUE((bool)p0);
19 EXPECT_EQ(0, *p0);
21 auto p1 = std::make_unique<int>(5);
22 EXPECT_TRUE((bool)p1);
23 EXPECT_EQ(5, *p1);
25 auto p2 = std::make_unique<std::tuple<int, int>>(0, 1);
26 EXPECT_TRUE((bool)p2);
27 EXPECT_EQ(std::make_tuple(0, 1), *p2);
29 auto p3 = std::make_unique<std::tuple<int, int, int>>(0, 1, 2);
30 EXPECT_TRUE((bool)p3);
31 EXPECT_EQ(std::make_tuple(0, 1, 2), *p3);
33 auto p4 = std::make_unique<std::tuple<int, int, int, int>>(0, 1, 2, 3);
34 EXPECT_TRUE((bool)p4);
35 EXPECT_EQ(std::make_tuple(0, 1, 2, 3), *p4);
37 auto p5 = std::make_unique<std::tuple<int, int, int, int, int>>(0, 1, 2, 3, 4);
38 EXPECT_TRUE((bool)p5);
39 EXPECT_EQ(std::make_tuple(0, 1, 2, 3, 4), *p5);
41 auto p6 =
42 std::make_unique<std::tuple<int, int, int, int, int, int>>(0, 1, 2, 3, 4, 5);
43 EXPECT_TRUE((bool)p6);
44 EXPECT_EQ(std::make_tuple(0, 1, 2, 3, 4, 5), *p6);
46 auto p7 = std::make_unique<std::tuple<int, int, int, int, int, int, int>>(
47 0, 1, 2, 3, 4, 5, 6);
48 EXPECT_TRUE((bool)p7);
49 EXPECT_EQ(std::make_tuple(0, 1, 2, 3, 4, 5, 6), *p7);
51 auto p8 = std::make_unique<std::tuple<int, int, int, int, int, int, int, int>>(
52 0, 1, 2, 3, 4, 5, 6, 7);
53 EXPECT_TRUE((bool)p8);
54 EXPECT_EQ(std::make_tuple(0, 1, 2, 3, 4, 5, 6, 7), *p8);
56 auto p9 =
57 std::make_unique<std::tuple<int, int, int, int, int, int, int, int, int>>(
58 0, 1, 2, 3, 4, 5, 6, 7, 8);
59 EXPECT_TRUE((bool)p9);
60 EXPECT_EQ(std::make_tuple(0, 1, 2, 3, 4, 5, 6, 7, 8), *p9);
62 auto p10 =
63 std::make_unique<std::tuple<int, int, int, int, int, int, int, int, int, int>>(
64 0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
65 EXPECT_TRUE((bool)p10);
66 EXPECT_EQ(std::make_tuple(0, 1, 2, 3, 4, 5, 6, 7, 8, 9), *p10);
69 TEST(MakeUniqueTest, Array) {
70 auto p1 = std::make_unique<int[]>(2);
71 EXPECT_TRUE((bool)p1);
72 EXPECT_EQ(0, p1[0]);
73 EXPECT_EQ(0, p1[1]);