38# include <gtest/gtest.h>
43using namespace testing;
50 EXPECT_EQ(
l.get_next(), &
l);
51 EXPECT_EQ(
l.get_prev(), &
l);
59 EXPECT_EQ(
l.get_next(), &
l);
60 EXPECT_EQ(
l.get_prev(), &
l);
67 EXPECT_EQ(
l.get_next(), &
l);
68 EXPECT_EQ(
l.get_prev(), &
l);
75 EXPECT_EQ(
l.get_next(), &
l);
76 EXPECT_EQ(
l.get_prev(), &
l);
83 EXPECT_EQ(
l.get_next(), &
l);
84 EXPECT_EQ(
l.get_prev(), &
l);
90 Dlink llaux(move(laux));
105 EXPECT_EQ(llaux.
get_next(), &llaux);
106 EXPECT_EQ(llaux.
get_prev(), &llaux);
109 l.append_list(&laux);
113 l.insert_list(&laux);
168 EXPECT_EQ(
l.remove_last(), &
l2);
214 EXPECT_THROW(it.
get_curr(), overflow_error);
220 EXPECT_THROW(it.
get_curr(), overflow_error);
226 EXPECT_THROW(it.
get_curr(), overflow_error);
248 for (
size_t i = 0; i < 2; ++i)
275 EXPECT_THROW(it.
get_curr(), overflow_error);
281 for (
size_t i = 0; i < 2; ++i)
307 EXPECT_THROW(it.
get_curr(), overflow_error);
313 EXPECT_EQ(it.
del(), &
l1);
316 EXPECT_EQ(it.
del(), &
l2);
319 EXPECT_EQ(it.
del(), &
l3);
322 EXPECT_EQ(it.
del(), &l4);
325 EXPECT_EQ(it.
del(), &
l5);
327 EXPECT_TRUE(list.is_empty());
335 EXPECT_TRUE(list.is_empty());
343 EXPECT_FALSE(list.is_empty());
344 EXPECT_EQ(list.get_first(), &
l1);
345 EXPECT_EQ(list.get_last(), &
l5);
350 Dlink laux, n1, n2, n3;
355 list.append_list(&laux);
357 EXPECT_EQ(list.get_first(), &
l1);
358 EXPECT_EQ(list.get_last(), &n3);
363 EXPECT_EQ(list.get_first(), &
l1);
364 EXPECT_EQ(list.get_last(), &
l5);
367 EXPECT_TRUE(list.is_empty());
371 list.insert_list(&lr);
373 EXPECT_EQ(list.get_first(), &
l1);
374 EXPECT_EQ(list.get_last(), &
l5);
375 EXPECT_FALSE(list.is_empty());
377 list.insert_list(&laux);
379 EXPECT_EQ(list.get_first(), &n1);
380 EXPECT_EQ(list.get_last(), &
l5);
384 EXPECT_EQ(list.get_first(), &n0);
385 EXPECT_EQ(list.get_last(), &
l5);
411 EXPECT_EQ(list.get_first(), &n0);
412 EXPECT_EQ(list.get_first()->get_next()->get_next()->get_next(), &m1);
413 EXPECT_EQ(list.get_last(), &
l5);
426 list.split_list(
l,
r);
427 EXPECT_TRUE(list.is_empty());
430 EXPECT_EQ(
r.get_first(), &
l2);
431 EXPECT_EQ(
r.get_last(), &
l5);
438 EXPECT_THROW(stack.
top(), underflow_error);
439 EXPECT_THROW(stack.
pop(), underflow_error);
449 EXPECT_EQ(stack.
top(), &n1);
450 EXPECT_EQ(stack.
pop(), &n1);
451 EXPECT_EQ(stack.
top(), &n2);
452 EXPECT_EQ(stack.
pop(), &n2);
456 EXPECT_EQ(stack.
top(), &n3);
457 EXPECT_EQ(stack.
pop(), &n3);
465 EXPECT_EQ(list.get_first(), &
l5);
466 EXPECT_EQ(list.get_last(), &
l1);
bool is_in_last() const noexcept
Return true if the iterator is positiones on the last item.
constexpr bool is_in_first() const noexcept
Return true if the iterator is positiones on the first item.
bool has_curr() const noexcept
Return true if the iterator has current item.
Dlink * get_curr() const
Return the current node of iterator.
void next()
Move the iterator one position forward.
Dlink * del()
Remove from the list the current node and move the iterator one position forward.
void prev()
Move the iterator one position backward.
void reset_last() noexcept
Reset the iterator to the last item of list.
void reset_first() noexcept
Reset the iterator to the first item of list.
bool is_last() const noexcept
Doubly linked circular list node.
Dlink * top() const
See get_next().
constexpr bool is_unitarian_or_empty() const noexcept
Return true if this (as header node) has zero or one element.
constexpr Dlink *& get_last() const noexcept
If this is a header node, it return the last node of this
Dlink * remove_first() noexcept
See remove_next().
constexpr Dlink *& get_first() const noexcept
If this is a header node, it return the first node of this
constexpr bool is_empty() const noexcept
Return true if this (as header node) is empty.
void append(Dlink *node) noexcept
Insert node before this.
void swap(Dlink *link) noexcept
Swap this with list whose header is link.
constexpr bool is_unitarian() const noexcept
Return true if this (as header node) has exactly one element.
Dlink * remove_last() noexcept
See remove_prev().
Dlink * pop()
See remove_next().
Dlink * del() noexcept
Remove this from the list. this must not be a header node.
void insert(Dlink *node) noexcept
Insert node after this.
Dlink *& get_prev() const noexcept
Return the link that is before this
void push(Dlink *node) noexcept
See insert(Dlink * node).
void append_list(Dlink *head) noexcept
Insert the list head before this
Dlink cut_list(Dlink *link) noexcept
Cut this from link.
Dlink *& get_next() const noexcept
Return the link that is after this
T & get_first()
Return the first item of the list.
T & append(const T &item)
T & insert(const T &item)
T & get_last()
Return the last item of the list.
T remove_first()
See remove().
DynList & swap(DynList &l) noexcept
size_t reverse_list() noexcept
See reverse().
constexpr bool is_empty() const noexcept
bool is_unitarian() const noexcept
Return true if the list contains exactly just one.
bool is_unitarian_or_empty() const noexcept
Return true if list contains one element or is empty.
Doubly linked circular list implementation.
TEST_F(List_of_5_nodes, Iterator)
Main namespace for Aleph-w library functions.
void reverse(Itor beg, Itor end)
Reverse elements in a range.
T & swap(T &t1, T &t2)
Generic swap using object's swap method.