Duncan P. N. Exon Smith | 9f5c83b | 2016-08-22 22:21:07 +0000 | [diff] [blame] | 1 | //===- unittests/ADT/IListSentinelTest.cpp - ilist_sentinel unit tests ----===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "llvm/ADT/ilist.h" |
| 11 | #include "gtest/gtest.h" |
| 12 | |
| 13 | using namespace llvm; |
| 14 | |
| 15 | namespace { |
| 16 | |
| 17 | class Node : public ilist_node<Node> {}; |
| 18 | |
Duncan P. N. Exon Smith | 34c4d2a | 2016-09-10 16:55:06 +0000 | [diff] [blame^] | 19 | struct LocalAccess : ilist_detail::NodeAccess { |
| 20 | using NodeAccess::getPrev; |
| 21 | using NodeAccess::getNext; |
| 22 | }; |
| 23 | |
Duncan P. N. Exon Smith | 9f5c83b | 2016-08-22 22:21:07 +0000 | [diff] [blame] | 24 | TEST(IListSentinelTest, DefaultConstructor) { |
| 25 | ilist_sentinel<Node> S; |
Duncan P. N. Exon Smith | 34c4d2a | 2016-09-10 16:55:06 +0000 | [diff] [blame^] | 26 | EXPECT_EQ(&S, LocalAccess::getPrev(S)); |
| 27 | EXPECT_EQ(&S, LocalAccess::getNext(S)); |
Duncan P. N. Exon Smith | 9f5c83b | 2016-08-22 22:21:07 +0000 | [diff] [blame] | 28 | #ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS |
| 29 | EXPECT_TRUE(S.isKnownSentinel()); |
| 30 | #else |
| 31 | EXPECT_FALSE(S.isKnownSentinel()); |
| 32 | #endif |
| 33 | } |
| 34 | |
| 35 | TEST(IListSentinelTest, NormalNodeIsNotKnownSentinel) { |
| 36 | Node N; |
Duncan P. N. Exon Smith | 34c4d2a | 2016-09-10 16:55:06 +0000 | [diff] [blame^] | 37 | EXPECT_EQ(nullptr, LocalAccess::getPrev(N)); |
| 38 | EXPECT_EQ(nullptr, LocalAccess::getNext(N)); |
Duncan P. N. Exon Smith | 9f5c83b | 2016-08-22 22:21:07 +0000 | [diff] [blame] | 39 | EXPECT_FALSE(N.isKnownSentinel()); |
| 40 | } |
| 41 | |
| 42 | } // end namespace |