Fix test failures introduced by PR #113697 (#116941)
[llvm-project.git] / llvm / unittests / ADT / IListSentinelTest.cpp
blob1f4a8311370a6d5beed7ddcf15df12ea756e48be
1 //===- unittests/ADT/IListSentinelTest.cpp - ilist_sentinel 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/ilist_node.h"
10 #include "gtest/gtest.h"
12 using namespace llvm;
14 namespace {
16 template <class T, class... Options> struct PickSentinel {
17 typedef ilist_sentinel<
18 typename ilist_detail::compute_node_options<T, Options...>::type>
19 type;
22 class Node : public ilist_node<Node> {};
23 class TrackingNode : public ilist_node<Node, ilist_sentinel_tracking<true>> {};
24 typedef PickSentinel<Node>::type Sentinel;
25 typedef PickSentinel<Node, ilist_sentinel_tracking<true>>::type
26 TrackingSentinel;
27 typedef PickSentinel<Node, ilist_sentinel_tracking<false>>::type
28 NoTrackingSentinel;
30 struct LocalAccess : ilist_detail::NodeAccess {
31 using NodeAccess::getPrev;
32 using NodeAccess::getNext;
35 TEST(IListSentinelTest, DefaultConstructor) {
36 Sentinel S;
37 EXPECT_EQ(&S, LocalAccess::getPrev(S));
38 EXPECT_EQ(&S, LocalAccess::getNext(S));
39 #if LLVM_ENABLE_ABI_BREAKING_CHECKS
40 EXPECT_TRUE(S.isKnownSentinel());
41 #else
42 EXPECT_FALSE(S.isKnownSentinel());
43 #endif
45 TrackingSentinel TS;
46 NoTrackingSentinel NTS;
47 EXPECT_TRUE(TS.isSentinel());
48 EXPECT_TRUE(TS.isKnownSentinel());
49 EXPECT_FALSE(NTS.isKnownSentinel());
52 TEST(IListSentinelTest, NormalNodeIsNotKnownSentinel) {
53 Node N;
54 EXPECT_EQ(nullptr, LocalAccess::getPrev(N));
55 EXPECT_EQ(nullptr, LocalAccess::getNext(N));
56 EXPECT_FALSE(N.isKnownSentinel());
58 TrackingNode TN;
59 EXPECT_FALSE(TN.isSentinel());
62 } // end namespace