//===-- list_test.cpp -------------------------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "tests/scudo_unit_test.h" #include "list.h" #include struct ListItemLinkedWithPtr { ListItemLinkedWithPtr *Next; ListItemLinkedWithPtr *Prev; }; struct ListItemLinkedWithIndex { scudo::uptr Next; scudo::uptr Prev; static constexpr scudo::uptr EndOfListVal = 1ULL << 30; }; template static void setList(ListT *L, ListItemTy *I1 = nullptr, ListItemTy *I2 = nullptr, ListItemTy *I3 = nullptr) { L->clear(); if (I1) L->push_back(I1); if (I2) L->push_back(I2); if (I3) L->push_back(I3); } template static void checkList(ListT *L, ListItemTy *I1, ListItemTy *I2 = nullptr, ListItemTy *I3 = nullptr, ListItemTy *I4 = nullptr, ListItemTy *I5 = nullptr, ListItemTy *I6 = nullptr) { if (I1) { EXPECT_EQ(L->front(), I1); L->pop_front(); } if (I2) { EXPECT_EQ(L->front(), I2); L->pop_front(); } if (I3) { EXPECT_EQ(L->front(), I3); L->pop_front(); } if (I4) { EXPECT_EQ(L->front(), I4); L->pop_front(); } if (I5) { EXPECT_EQ(L->front(), I5); L->pop_front(); } if (I6) { EXPECT_EQ(L->front(), I6); L->pop_front(); } EXPECT_TRUE(L->empty()); } template