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