diff options
Diffstat (limited to 'unittests/ADT/ilistTest.cpp')
-rw-r--r-- | unittests/ADT/ilistTest.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/unittests/ADT/ilistTest.cpp b/unittests/ADT/ilistTest.cpp new file mode 100644 index 0000000000..3bf04dccc2 --- /dev/null +++ b/unittests/ADT/ilistTest.cpp @@ -0,0 +1,39 @@ +//===- llvm/unittest/ADT/APInt.cpp - APInt unit tests ---------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <ostream> +#include "gtest/gtest.h" +#include "llvm/ADT/ilist.h" +#include "llvm/ADT/ilist_node.h" + +using namespace llvm; + +namespace { + +struct Node : ilist_node<Node> { + int Value; + + Node() {} + Node(int _Value) : Value(_Value) {} +}; + +TEST(ilistTest, Basic) { + ilist<Node> List; + List.push_back(Node(1)); + EXPECT_EQ(1, List.back().Value); + EXPECT_EQ(0, List.back().getPrevNode()); + EXPECT_EQ(0, List.back().getNextNode()); + + List.push_back(Node(2)); + EXPECT_EQ(2, List.back().Value); + EXPECT_EQ(2, List.front().getNextNode()->Value); + EXPECT_EQ(1, List.back().getPrevNode()->Value); +} + +} |