1 //===- unittests/ADT/IListNodeTest.cpp - ilist_node 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/ilist_node.h"
11 #include "gtest/gtest.h"
12 #include <type_traits>
13
14 using namespace llvm;
15 using namespace llvm::ilist_detail;
16
17 namespace {
18
19 struct Node;
20
21 struct TagA {};
22 struct TagB {};
23
TEST(IListNodeTest,Options)24 TEST(IListNodeTest, Options) {
25 static_assert(
26 std::is_same<compute_node_options<Node>::type,
27 compute_node_options<Node, ilist_tag<void>>::type>::value,
28 "default tag is void");
29 static_assert(
30 !std::is_same<compute_node_options<Node, ilist_tag<TagA>>::type,
31 compute_node_options<Node, ilist_tag<void>>::type>::value,
32 "default tag is void, different from TagA");
33 static_assert(
34 !std::is_same<compute_node_options<Node, ilist_tag<TagA>>::type,
35 compute_node_options<Node, ilist_tag<TagB>>::type>::value,
36 "TagA is not TagB");
37 static_assert(
38 std::is_same<
39 compute_node_options<Node, ilist_sentinel_tracking<false>>::type,
40 compute_node_options<Node, ilist_sentinel_tracking<false>,
41 ilist_tag<void>>::type>::value,
42 "default tag is void, even with sentinel tracking off");
43 static_assert(
44 std::is_same<
45 compute_node_options<Node, ilist_sentinel_tracking<false>>::type,
46 compute_node_options<Node, ilist_tag<void>,
47 ilist_sentinel_tracking<false>>::type>::value,
48 "order shouldn't matter");
49 static_assert(
50 std::is_same<
51 compute_node_options<Node, ilist_sentinel_tracking<true>>::type,
52 compute_node_options<Node, ilist_sentinel_tracking<true>,
53 ilist_tag<void>>::type>::value,
54 "default tag is void, even with sentinel tracking on");
55 static_assert(
56 std::is_same<
57 compute_node_options<Node, ilist_sentinel_tracking<true>>::type,
58 compute_node_options<Node, ilist_tag<void>,
59 ilist_sentinel_tracking<true>>::type>::value,
60 "order shouldn't matter");
61 static_assert(
62 std::is_same<
63 compute_node_options<Node, ilist_sentinel_tracking<true>,
64 ilist_tag<TagA>>::type,
65 compute_node_options<Node, ilist_tag<TagA>,
66 ilist_sentinel_tracking<true>>::type>::value,
67 "order shouldn't matter with real tags");
68 }
69
70 } // end namespace
71