mirror of
https://github.com/Gericom/teak-llvm.git
synced 2025-06-20 03:55:48 -04:00

I'm working on a lower-level intrusive list that can be used stand-alone, and splitting the files up a bit will make the code easier to organize. Explode the ilist headers in advance to improve blame lists in the future. - Move ilist_node_base from ilist_node.h to ilist_node_base.h. - Move ilist_base from ilist.h to ilist_base.h. - Move ilist_iterator from ilist.h to ilist_iterator.h. - Move ilist_node_access from ilist.h to ilist_node.h to support ilist_iterator. - Update unit tests to #include smaller headers. - Clang-format the moved things. I noticed in transit that there is a simplify_type specialization for ilist_iterator. Since there is no longer an implicit conversion from ilist<T>::iterator to T*, this doesn't make sense (effectively it's a form of implicit conversion). For now I've added a FIXME. llvm-svn: 280047
61 lines
1.5 KiB
C++
61 lines
1.5 KiB
C++
//===- 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
|