1 //===- unittests/ADT/IListSentinelTest.cpp - ilist_sentinel unit tests ----===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "llvm/ADT/ilist_node.h"
11 #include "gtest/gtest.h"
17 template <class T
, class... Options
> struct PickSentinel
{
18 typedef ilist_sentinel
<
19 typename
ilist_detail::compute_node_options
<T
, Options
...>::type
>
23 class Node
: public ilist_node
<Node
> {};
24 class TrackingNode
: public ilist_node
<Node
, ilist_sentinel_tracking
<true>> {};
25 typedef PickSentinel
<Node
>::type Sentinel
;
26 typedef PickSentinel
<Node
, ilist_sentinel_tracking
<true>>::type
28 typedef PickSentinel
<Node
, ilist_sentinel_tracking
<false>>::type
31 struct LocalAccess
: ilist_detail::NodeAccess
{
32 using NodeAccess::getPrev
;
33 using NodeAccess::getNext
;
36 TEST(IListSentinelTest
, DefaultConstructor
) {
38 EXPECT_EQ(&S
, LocalAccess::getPrev(S
));
39 EXPECT_EQ(&S
, LocalAccess::getNext(S
));
40 #if LLVM_ENABLE_ABI_BREAKING_CHECKS
41 EXPECT_TRUE(S
.isKnownSentinel());
43 EXPECT_FALSE(S
.isKnownSentinel());
47 NoTrackingSentinel NTS
;
48 EXPECT_TRUE(TS
.isSentinel());
49 EXPECT_TRUE(TS
.isKnownSentinel());
50 EXPECT_FALSE(NTS
.isKnownSentinel());
53 TEST(IListSentinelTest
, NormalNodeIsNotKnownSentinel
) {
55 EXPECT_EQ(nullptr, LocalAccess::getPrev(N
));
56 EXPECT_EQ(nullptr, LocalAccess::getNext(N
));
57 EXPECT_FALSE(N
.isKnownSentinel());
60 EXPECT_FALSE(TN
.isSentinel());