brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.3 KiB · c5f39d7 Raw
83 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9#include "llvm/ADT/ilist_node.h"10#include "gtest/gtest.h"11#include <type_traits>12 13using namespace llvm;14using namespace llvm::ilist_detail;15 16namespace {17 18struct Node;19 20struct TagA {};21struct TagB {};22struct ParentA {};23struct ParentB {};24 25TEST(IListNodeTest, Options) {26  static_assert(27      std::is_same_v<compute_node_options<Node>::type,28                     compute_node_options<Node, ilist_tag<void>>::type>,29      "default tag is void");30  static_assert(31      !std::is_same_v<compute_node_options<Node, ilist_tag<TagA>>::type,32                      compute_node_options<Node, ilist_tag<void>>::type>,33      "default tag is void, different from TagA");34  static_assert(35      !std::is_same_v<compute_node_options<Node, ilist_tag<TagA>>::type,36                      compute_node_options<Node, ilist_tag<TagB>>::type>,37      "TagA is not TagB");38  static_assert(39      std::is_same_v<40          compute_node_options<Node, ilist_sentinel_tracking<false>>::type,41          compute_node_options<Node, ilist_sentinel_tracking<false>,42                               ilist_tag<void>>::type>,43      "default tag is void, even with sentinel tracking off");44  static_assert(45      std::is_same_v<46          compute_node_options<Node, ilist_sentinel_tracking<false>>::type,47          compute_node_options<Node, ilist_tag<void>,48                               ilist_sentinel_tracking<false>>::type>,49      "order shouldn't matter");50  static_assert(51      std::is_same_v<52          compute_node_options<Node, ilist_sentinel_tracking<true>>::type,53          compute_node_options<Node, ilist_sentinel_tracking<true>,54                               ilist_tag<void>>::type>,55      "default tag is void, even with sentinel tracking on");56  static_assert(57      std::is_same_v<58          compute_node_options<Node, ilist_sentinel_tracking<true>>::type,59          compute_node_options<Node, ilist_tag<void>,60                               ilist_sentinel_tracking<true>>::type>,61      "order shouldn't matter");62  static_assert(63      std::is_same_v<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>,67      "order shouldn't matter with real tags");68  static_assert(69      std::is_same_v<compute_node_options<Node>::type,70                     compute_node_options<Node, ilist_parent<void>>::type>,71      "default parent is void");72  static_assert(73      !std::is_same_v<compute_node_options<Node, ilist_parent<ParentA>>::type,74                      compute_node_options<Node, ilist_parent<void>>::type>,75      "ParentA is not void");76  static_assert(77      !std::is_same_v<compute_node_options<Node, ilist_parent<ParentA>>::type,78                      compute_node_options<Node, ilist_parent<ParentB>>::type>,79      "ParentA is not ParentB");80}81 82} // end namespace83