1085bbf1eSDuncan P. N. Exon Smith //===- unittests/ADT/IListNodeTest.cpp - ilist_node unit tests ------------===//
2085bbf1eSDuncan P. N. Exon Smith //
3*2946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*2946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
5*2946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6085bbf1eSDuncan P. N. Exon Smith //
7085bbf1eSDuncan P. N. Exon Smith //===----------------------------------------------------------------------===//
8085bbf1eSDuncan P. N. Exon Smith 
9085bbf1eSDuncan P. N. Exon Smith #include "llvm/ADT/ilist_node.h"
10085bbf1eSDuncan P. N. Exon Smith #include "gtest/gtest.h"
11085bbf1eSDuncan P. N. Exon Smith #include <type_traits>
12085bbf1eSDuncan P. N. Exon Smith 
13085bbf1eSDuncan P. N. Exon Smith using namespace llvm;
14085bbf1eSDuncan P. N. Exon Smith using namespace llvm::ilist_detail;
15085bbf1eSDuncan P. N. Exon Smith 
16085bbf1eSDuncan P. N. Exon Smith namespace {
17085bbf1eSDuncan P. N. Exon Smith 
18085bbf1eSDuncan P. N. Exon Smith struct Node;
19085bbf1eSDuncan P. N. Exon Smith 
20085bbf1eSDuncan P. N. Exon Smith struct TagA {};
21085bbf1eSDuncan P. N. Exon Smith struct TagB {};
22085bbf1eSDuncan P. N. Exon Smith 
TEST(IListNodeTest,Options)23085bbf1eSDuncan P. N. Exon Smith TEST(IListNodeTest, Options) {
24085bbf1eSDuncan P. N. Exon Smith   static_assert(
25085bbf1eSDuncan P. N. Exon Smith       std::is_same<compute_node_options<Node>::type,
26085bbf1eSDuncan P. N. Exon Smith                    compute_node_options<Node, ilist_tag<void>>::type>::value,
27085bbf1eSDuncan P. N. Exon Smith       "default tag is void");
28085bbf1eSDuncan P. N. Exon Smith   static_assert(
29085bbf1eSDuncan P. N. Exon Smith       !std::is_same<compute_node_options<Node, ilist_tag<TagA>>::type,
30085bbf1eSDuncan P. N. Exon Smith                     compute_node_options<Node, ilist_tag<void>>::type>::value,
31085bbf1eSDuncan P. N. Exon Smith       "default tag is void, different from TagA");
32085bbf1eSDuncan P. N. Exon Smith   static_assert(
33085bbf1eSDuncan P. N. Exon Smith       !std::is_same<compute_node_options<Node, ilist_tag<TagA>>::type,
34085bbf1eSDuncan P. N. Exon Smith                     compute_node_options<Node, ilist_tag<TagB>>::type>::value,
35085bbf1eSDuncan P. N. Exon Smith       "TagA is not TagB");
36085bbf1eSDuncan P. N. Exon Smith   static_assert(
37085bbf1eSDuncan P. N. Exon Smith       std::is_same<
38085bbf1eSDuncan P. N. Exon Smith           compute_node_options<Node, ilist_sentinel_tracking<false>>::type,
39085bbf1eSDuncan P. N. Exon Smith           compute_node_options<Node, ilist_sentinel_tracking<false>,
40085bbf1eSDuncan P. N. Exon Smith                                ilist_tag<void>>::type>::value,
41085bbf1eSDuncan P. N. Exon Smith       "default tag is void, even with sentinel tracking off");
42085bbf1eSDuncan P. N. Exon Smith   static_assert(
43085bbf1eSDuncan P. N. Exon Smith       std::is_same<
44085bbf1eSDuncan P. N. Exon Smith           compute_node_options<Node, ilist_sentinel_tracking<false>>::type,
45085bbf1eSDuncan P. N. Exon Smith           compute_node_options<Node, ilist_tag<void>,
46085bbf1eSDuncan P. N. Exon Smith                                ilist_sentinel_tracking<false>>::type>::value,
47085bbf1eSDuncan P. N. Exon Smith       "order shouldn't matter");
48085bbf1eSDuncan P. N. Exon Smith   static_assert(
49085bbf1eSDuncan P. N. Exon Smith       std::is_same<
50085bbf1eSDuncan P. N. Exon Smith           compute_node_options<Node, ilist_sentinel_tracking<true>>::type,
51085bbf1eSDuncan P. N. Exon Smith           compute_node_options<Node, ilist_sentinel_tracking<true>,
52085bbf1eSDuncan P. N. Exon Smith                                ilist_tag<void>>::type>::value,
53085bbf1eSDuncan P. N. Exon Smith       "default tag is void, even with sentinel tracking on");
54085bbf1eSDuncan P. N. Exon Smith   static_assert(
55085bbf1eSDuncan P. N. Exon Smith       std::is_same<
56085bbf1eSDuncan P. N. Exon Smith           compute_node_options<Node, ilist_sentinel_tracking<true>>::type,
57085bbf1eSDuncan P. N. Exon Smith           compute_node_options<Node, ilist_tag<void>,
58085bbf1eSDuncan P. N. Exon Smith                                ilist_sentinel_tracking<true>>::type>::value,
59085bbf1eSDuncan P. N. Exon Smith       "order shouldn't matter");
60085bbf1eSDuncan P. N. Exon Smith   static_assert(
61085bbf1eSDuncan P. N. Exon Smith       std::is_same<
62085bbf1eSDuncan P. N. Exon Smith           compute_node_options<Node, ilist_sentinel_tracking<true>,
63085bbf1eSDuncan P. N. Exon Smith                                ilist_tag<TagA>>::type,
64085bbf1eSDuncan P. N. Exon Smith           compute_node_options<Node, ilist_tag<TagA>,
65085bbf1eSDuncan P. N. Exon Smith                                ilist_sentinel_tracking<true>>::type>::value,
66085bbf1eSDuncan P. N. Exon Smith       "order shouldn't matter with real tags");
67085bbf1eSDuncan P. N. Exon Smith }
68085bbf1eSDuncan P. N. Exon Smith 
69085bbf1eSDuncan P. N. Exon Smith } // end namespace
70