summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ADT/IListSentinelTest.cpp
blob: 533421e850404bed70278df33cf60da544c40a4f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//===- unittests/ADT/IListSentinelTest.cpp - ilist_sentinel unit tests ----===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#include "llvm/ADT/ilist.h"
#include "gtest/gtest.h"

using namespace llvm;

namespace {

class Node : public ilist_node<Node> {};

TEST(IListSentinelTest, DefaultConstructor) {
  ilist_sentinel<Node> S;
  EXPECT_EQ(&S, ilist_node_access::getPrev(S));
  EXPECT_EQ(&S, ilist_node_access::getNext(S));
#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
  EXPECT_TRUE(S.isKnownSentinel());
#else
  EXPECT_FALSE(S.isKnownSentinel());
#endif
}

TEST(IListSentinelTest, NormalNodeIsNotKnownSentinel) {
  Node N;
  EXPECT_EQ(nullptr, ilist_node_access::getPrev(N));
  EXPECT_EQ(nullptr, ilist_node_access::getNext(N));
  EXPECT_FALSE(N.isKnownSentinel());
}

} // end namespace
OpenPOWER on IntegriCloud