forked from llvm-mirror/llvm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIListNodeBaseTest.cpp
60 lines (52 loc) · 1.53 KB
/
IListNodeBaseTest.cpp
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//===- unittests/ADT/IListNodeBaseTest.cpp - ilist_node_base 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_node_base.h"
#include "gtest/gtest.h"
using namespace llvm;
namespace {
TEST(IListNodeBaseTest, DefaultConstructor) {
ilist_node_base A;
EXPECT_EQ(nullptr, A.getPrev());
EXPECT_EQ(nullptr, A.getNext());
EXPECT_FALSE(A.isKnownSentinel());
}
TEST(IListNodeBaseTest, setPrevAndNext) {
ilist_node_base A, B, C;
A.setPrev(&B);
EXPECT_EQ(&B, A.getPrev());
EXPECT_EQ(nullptr, A.getNext());
EXPECT_EQ(nullptr, B.getPrev());
EXPECT_EQ(nullptr, B.getNext());
EXPECT_EQ(nullptr, C.getPrev());
EXPECT_EQ(nullptr, C.getNext());
A.setNext(&C);
EXPECT_EQ(&B, A.getPrev());
EXPECT_EQ(&C, A.getNext());
EXPECT_EQ(nullptr, B.getPrev());
EXPECT_EQ(nullptr, B.getNext());
EXPECT_EQ(nullptr, C.getPrev());
EXPECT_EQ(nullptr, C.getNext());
}
TEST(IListNodeBaseTest, isKnownSentinel) {
ilist_node_base A, B;
EXPECT_FALSE(A.isKnownSentinel());
A.setPrev(&B);
A.setNext(&B);
EXPECT_EQ(&B, A.getPrev());
EXPECT_EQ(&B, A.getNext());
A.initializeSentinel();
#ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
EXPECT_TRUE(A.isKnownSentinel());
#else
EXPECT_FALSE(A.isKnownSentinel());
#endif
EXPECT_EQ(&B, A.getPrev());
EXPECT_EQ(&B, A.getNext());
}
} // end namespace