166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman//===- llvm/unittest/ADT/APInt.cpp - APInt unit tests ---------------------===// 266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// 366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// The LLVM Compiler Infrastructure 466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// 566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// This file is distributed under the University of Illinois Open Source 666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// License. See LICENSE.TXT for details. 766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// 866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman//===----------------------------------------------------------------------===// 966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 1066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman#include <ostream> 1166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman#include "gtest/gtest.h" 1266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman#include "llvm/ADT/ilist.h" 1366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman#include "llvm/ADT/ilist_node.h" 1466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 1566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumanusing namespace llvm; 1666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 1766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumannamespace { 1866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 1966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumanstruct Node : ilist_node<Node> { 2066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman int Value; 2166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 2266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Node() {} 2366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman Node(int _Value) : Value(_Value) {} 2466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman}; 2566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 2666b8ab22586debccb1f787d4d52b7f042d4ddeb8John BaumanTEST(ilistTest, Basic) { 2766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman ilist<Node> List; 2866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman List.push_back(Node(1)); 2966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman EXPECT_EQ(1, List.back().Value); 3066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman EXPECT_EQ(0, List.back().getPrevNode()); 3166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman EXPECT_EQ(0, List.back().getNextNode()); 3266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 3366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman List.push_back(Node(2)); 3466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman EXPECT_EQ(2, List.back().Value); 3566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman EXPECT_EQ(2, List.front().getNextNode()->Value); 3666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman EXPECT_EQ(1, List.back().getPrevNode()->Value); 3766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 3866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman const ilist<Node> &ConstList = List; 3966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman EXPECT_EQ(2, ConstList.back().Value); 4066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman EXPECT_EQ(2, ConstList.front().getNextNode()->Value); 4166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman EXPECT_EQ(1, ConstList.back().getPrevNode()->Value); 4266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman} 4366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 4466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman} 45