38#include <gtest/gtest.h>
66 for (
auto it =
g.
get_node_it(); it.has_curr(); it.next_ne())
74 for (
auto it =
g.
get_arc_it(); it.has_curr(); it.next_ne())
109 ARC_COOKIE(a1) =
reinterpret_cast<void*
>(0x2);
178 throw std::runtime_error(
"test exception");
209 ARC_COOKIE(a1) =
reinterpret_cast<void*
>(0x3);
217 ARC_COOKIE(a1) =
reinterpret_cast<void*
>(0xC);
289 if (cookie !=
nullptr && cookie !=
reinterpret_cast<void*
>(0x1))
290 delete static_cast<int*
>(cookie);
313 throw std::runtime_error(
"test exception");
331 auto &
saved =
saver.get_saved_node_cookies();
336 [
this](
const auto & p) { return p.first == n1; });
338 EXPECT_EQ(it->second,
reinterpret_cast<void*
>(0x1));
477 throw std::runtime_error(
"test");
WeightedDigraph::Node Node
RAII guard that clears graph cookies on destruction.
RAII guard that saves and restores graph cookies.
void next_ne() noexcept
Advances the iterator to the next filtered element (noexcept version).
size_t size() const noexcept
Count the number of elements of the list.
virtual Node * insert_node(Node *node) noexcept
Insertion of a node already allocated.
Graph_Node< int > Node
The graph type.
Graph_Arc< int > Arc
The node class type.
Arc * insert_arc(Node *src_node, Node *tgt_node, void *a)
Filtered iterator on the nodes of a graph.
Generic RAII scope guard for cleanup operations on graphs.
bool all_arc_cookies_null()
bool all_node_cookies_null()
auto get_arc_it() const noexcept
Obtains an iterator to the arc of graph.
auto get_node_it() const noexcept
Obtains an iterator to the nodes of graph.
iterator end() noexcept
Return an STL-compatible end iterator.
iterator begin() noexcept
Return an STL-compatible iterator to the first element.
RAII guards for graph node/arc cookies.
TEST_F(CookieGuardTest, BasicCleanup)
#define ARC_COOKIE(p)
Return the arc cookie
auto with_clean_cookies(GT &g, Func &&func) -> decltype(func())
Convenience function to run an algorithm with automatic cookie cleanup.
auto with_saved_cookies(GT &g, Func &&func) -> decltype(func())
Convenience function to run an algorithm preserving existing cookies.
#define NODE_COOKIE(p)
Return the node cookie
Main namespace for Aleph-w library functions.
DynList< T > maps(const C &c, Op op)
Classic map operation.
Arc of graph implemented with double-linked adjacency lists.
Generic graph and digraph implementations.