1 //===- llvm/unittest/ADT/APInt.cpp - APInt 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 //===----------------------------------------------------------------------===//
11 #include "gtest/gtest.h"
12 #include "llvm/ADT/ilist.h"
13 #include "llvm/ADT/ilist_node.h"
19 struct Node
: ilist_node
<Node
> {
23 Node(int _Value
) : Value(_Value
) {}
26 TEST(ilistTest
, Basic
) {
28 List
.push_back(Node(1));
29 EXPECT_EQ(1, List
.back().Value
);
30 EXPECT_EQ(0, List
.back().getPrevNode());
31 EXPECT_EQ(0, List
.back().getNextNode());
33 List
.push_back(Node(2));
34 EXPECT_EQ(2, List
.back().Value
);
35 EXPECT_EQ(2, List
.front().getNextNode()->Value
);
36 EXPECT_EQ(1, List
.back().getPrevNode()->Value
);
38 const ilist
<Node
> &ConstList
= List
;
39 EXPECT_EQ(2, ConstList
.back().Value
);
40 EXPECT_EQ(2, ConstList
.front().getNextNode()->Value
);
41 EXPECT_EQ(1, ConstList
.back().getPrevNode()->Value
);