17namespace sequoia::testing
19 namespace undirected_graph{
22 enum meta_data_graph_description : std::size_t {
51 class EdgeStorageConfig,
52 class NodeWeightStorage
58 using edge_t =
typename graph_t::edge_init_type;
59 using node_weight_type =
typename graph_t::node_weight_type;
60 using edges_equivalent_t = std::initializer_list<std::initializer_list<edge_t>>;
65 auto trg{make_meta_data_transition_graph(t)};
68 [&t](std::string_view description,
const graph_t& obtained,
const graph_t& prediction,
const graph_t& parent, std::size_t host, std::size_t target) {
69 t.check(equality, {description, no_source_location}, obtained, prediction);
70 if(host != target) t.check_semantics({description, no_source_location}, prediction, parent);
78 static graph_t make_and_check(
regular_test& t, std::string_view description, edges_equivalent_t init)
83 static void check_initialization_exceptions(
regular_test& t)
85 using namespace maths;
88 t.check_exception_thrown<std::out_of_range>(
"Target index of edge out of range", [](){
return graph_t{{edge_t{1, 0.5f}}}; });
89 t.check_exception_thrown<std::logic_error>(
"Mismatched loop", [](){
return graph_t{{edge_t{0, 0.5f}}}; });
92 t.check_exception_thrown<std::logic_error>(
"Mismatched partial edges", [](){
return graph_t{{edge_t{1, 0.5f}}, {edge_t{1, -0.5f}}}; });
93 t.check_exception_thrown<std::logic_error>(
"Mismatched loop", [](){
return graph_t{{edge_t{1, 0.5f}}, {edge_t{0, 0.6f}, edge_t{1, -0.5f}}}; });
97 static transition_graph make_meta_data_transition_graph(
regular_test& t)
99 using meta_data_t = EdgeMetaData;
102 check_initialization_exceptions(t);
104 return transition_graph{
110 meta_data_graph_description::node_0a_0b,
111 t.report(
"Add loop"),
113 g.join(0, 0, 0.0f, 0.5f);
118 meta_data_graph_description::node_0b_0a,
119 t.report(
"Add loop"),
121 g.join(0, 0, 0.5f, 0.0f);
128 meta_data_graph_description::node_0b_0a,
129 t.report(
"Set edge meta data"),
131 g.set_edge_meta_data(g.cbegin_edges(0), 0.5f);
136 meta_data_graph_description::node_0b_0a,
137 t.report(
"Set edge meta data"),
139 g.set_edge_meta_data(g.cbegin_edges(0), meta_data_t{0.5f});
144 meta_data_graph_description::node_0b_0a,
145 t.report(
"Mutate edge meta data"),
147 t.check(equality,
"Mutate return value", g.mutate_edge_meta_data(g.cbegin_edges(0), [](meta_data_t& m) { m += 0.5f;
return 42; }), 42);
152 meta_data_graph_description::node_0a_0b,
153 t.report(
"Set meta data via reverse iterator"),
155 g.set_edge_meta_data(g.crbegin_edges(0), 0.5f);
160 meta_data_graph_description::node_0a_0b,
161 t.report(
"Mutate edge meta data via reverse iterator"),
163 t.check(equality,
"Mutate return value", g.mutate_edge_meta_data(g.crbegin_edges(0), [](meta_data_t& m) { m += 0.5f;
return 42; }), 42);
175 make_and_check(t, t.report(
""), {}),
178 make_and_check(t, t.report(
""), {{}}),
181 make_and_check(t, t.report(
""), {{{0, 0.0f}, {0, 0.0f}}}),
184 make_and_check(t, t.report(
""), {{{0, 0.0f}, {0, 0.5f}}}),
187 make_and_check(t, t.report(
""), {{{0, 0.5f}, {0, 0.0f}}}),
Utilities for checking regular semantics.
Facility to define tests via a graph comprising states of an object and transitions between them.
Definition: DynamicGraph.hpp:303
Definition: DynamicGraph.hpp:360
class template from which all concrete tests should derive.
Definition: FreeTestCore.hpp:144
Exposes elementary check methods, with the option to plug in arbitrary Extenders to compose functiona...
Definition: FreeCheckers.hpp:708
Definition: DynamicGraphTestingUtilities.hpp:173
Definition: StateTransitionUtilities.hpp:77