38#include <gtest/gtest.h>
53void push_front(
Slink & head, TestNode & node)
68 ASSERT_TRUE(n1.link.is_empty());
72 EXPECT_EQ(head.
get_next(), &n1.link);
75 EXPECT_EQ(head.
get_next(), &n2.link);
76 EXPECT_EQ(n2.link.get_next(), &n1.link);
79 EXPECT_EQ(removed, &n2.link);
80 EXPECT_TRUE(n2.link.is_empty());
81 EXPECT_EQ(head.
get_next(), &n1.link);
84 EXPECT_EQ(removed, &n1.link);
93 for (
auto & node :
nodes)
94 push_front(head, node);
100 auto * owner = TestNode::slink_to_type(it);
101 ASSERT_NE(owner,
nullptr);
102 EXPECT_EQ(owner->value,
expected[idx++]);
104 EXPECT_EQ(idx, std::size(
expected));
109 auto * owner = TestNode::slink_to_type(removed);
111 EXPECT_TRUE(owner->link.is_empty());
120 push_front(head, node);
122 const Slink & cref = head;
size_t size_t int32_t value
Singly linked handle to list nodes.
void insert_next(Slink *p)
Insert link p right after this.
Slink * remove_next()
Remove the link right after this.
constexpr bool is_empty() const noexcept
Return true if this link is empty (points to itself).
constexpr Slink *& get_next() noexcept
Return the next link.
Minimal std::expected-style result type for C++20.
DynArray< Graph::Node * > nodes
Main namespace for Aleph-w library functions.
Singly linked list base class.
#define SLINK_TO_TYPE(type_name, link_name)
Generate a conversion function from the link name to the enclosing structure.
Graph_Anode< Empty_Class > TestNode