38# include <gtest/gtest.h>
44using namespace testing;
47constexpr size_t N = 17;
55 for (
size_t i = 0; i <
N; ++i, ++
n)
66 for (
size_t i = 0; i <
N; ++i, ++
n)
67 s.push({ int(i), 0, 1, 2, int(i) });
83 for (
size_t i = 0; i < n; ++i)
86 for (
size_t i = 0; i < n; ++i)
93 for (
size_t i = 0; i < n; ++i)
96 for (
size_t i = 0; i < n; ++i)
113 for (
size_t i = 0; i < n; ++i)
115 EXPECT_EQ(s.top(i).get_first(), n - i - 1);
116 EXPECT_EQ(s.top(i).get_last(), n - i - 1);
120 for (
size_t i = 0; i < n; ++i)
132 auto &
ll = s.pushn(n);
136 for (
size_t i = 0; i < n; ++i)
137 s.top(i) = {
int(i), 0, 1,
int(i) };
139 for (
size_t i = 0; i < n; ++i)
170 auto it = s.get_it();
171 for (
size_t i = 0; it.has_curr(); it.next(), ++i)
175 for (
size_t i = 0; it.has_curr(); it.prev(), ++i)
181 auto it = s.get_it();
182 for (
size_t i = 0; it.has_curr(); it.next(), ++i)
191 for (
size_t i = 0; it.has_curr(); it.prev(), ++i)
193 ASSERT_EQ(it.get_curr().get_first(), n - i -1);
194 ASSERT_EQ(it.get_curr().get_last(), n - i -1);
207 for (; i <
sc.
size(); ++i)
218 for (; i <
sc.
size(); ++i)
230 for (; i <
sc.
size(); ++i)
239 for (; i < s.size(); ++i)
251 for (; i <
sc.
size(); ++i)
262 for (; i <
sc.
size(); ++i)
274 for (; i <
sc.
size(); ++i)
288 for (; i < s.size(); ++i)
290 ASSERT_EQ(s.top(i).get_first(), n - i - 1);
291 ASSERT_EQ(s.top(i).get_last(), n - i - 1);
301 s.traverse([&i] (
auto k) {
EXPECT_EQ(
k, i);
return k == i++; });
Functional programming utilities for Aleph-w containers.
T & push(const T &data)
Push into stack a copy of data
Dynamic singly linked list with functional programming support.
T & get_last() const
Return the last item of the list.
T & get_first() const
Return the first item of the list.
size_t size() const noexcept
Return the number of elements stored in the stack.
bool is_empty() const noexcept
Return true if stack is empty.
constexpr bool is_empty() const noexcept
Return true if list is empty.
size_t size() const noexcept
Count the number of elements of the list.
Type & nth(const size_t n)
Return the n-th item of container.
auto get_it() const
Return a properly initialized iterator positioned at the first item on the container.
TEST_F(SimpleStack, push_pop)
Main namespace for Aleph-w library functions.
bool eq(const C1 &c1, const C2 &c2, Eq e=Eq())
Check equality of two containers using a predicate.
bool traverse(Node *root, Op op)
DynList< T > maps(const C &c, Op op)
Classic map operation.
Fixture with a stack of complex objects (DynList<int>)
ArrayStack< DynList< int > > s
FixedStack< DynList< int > > s
Fixture with a stack of integers.
Stack implementations backed by dynamic or fixed arrays.