20namespace sequoia::testing
29 template<test_mode Mode>
32 check(equality,
"Sizes different", logger, nodes.size(), prediction.size());
33 check(with_best_available,
"const_node_iter", logger, nodes.cbegin_node_weights(), nodes.cend_node_weights(), prediction.cbegin_node_weights(), prediction.cend_node_weights());
38 requires std::is_empty_v<typename Nodes::weight_type>
43 template<test_mode Mode>
54 using equivalent_type = std::initializer_list<typename type::weight_type>;
56 template<test_mode Mode>
59 check(equality,
"Sizes different", logger, nodes.size(), prediction.size());
61 check(with_best_available,
"const_node_iter", logger, nodes.cbegin_node_weights(), nodes.cend_node_weights(), prediction.begin(), prediction.end());
62 check(with_best_available,
"const_reverse_node_iter", logger, nodes.crbegin_node_weights(), nodes.crend_node_weights(), std::reverse_iterator(prediction.end()), std::reverse_iterator(prediction.begin()));
63 check(with_best_available,
"implicitly const range", logger, nodes.node_weights().begin(), nodes.node_weights().end(), prediction.begin(), prediction.end());
64 check(with_best_available,
"explicitly const range", logger, nodes.cnode_weights().begin(), nodes.cnode_weights().end(), prediction.begin(), prediction.end());
66 using iterator_type = Nodes::iterator;
67 if constexpr(std::indirectly_writable<iterator_type, std::iter_value_t<iterator_type>>)
69 auto& n{
const_cast<Nodes&
>(nodes)};
70 check(with_best_available,
"range", logger, n.node_weights().begin(), n.node_weights().end(), prediction.begin(), prediction.end());
76 requires std::is_empty_v<typename Nodes::weight_type>
81 using equivalent_type = std::initializer_list<typename type::weight_type>;
83 template<test_mode Mode>
86 testing::check(
"Node storage should have zero size for empty node weights", logger, nodes.empty());
93 template<
class Weight,
class Container>
104 template<
class Weight, std::
size_t N>
115 template<
class... Ts>
119 using equivalent_type = std::tuple<Ts...>;
121 template<test_mode Mode>
124 if(
check(equality,
"Node storaage sizes different", logger, nodes.size(), prediction.size()))
126 check_elements(logger, nodes, prediction);
130 template<test_mode Mode>
133 if (
check(equality,
"Node storage sizes different", logger, nodes.size(),
sizeof...(Ts)))
135 check_elements(logger, nodes, prediction);
140 template<test_mode Mode, std::
size_t I=0>
142 [[maybe_unused]]
const type& nodes,
143 [[maybe_unused]]
const type& prediction)
145 if constexpr(I <
sizeof...(Ts))
147 const std::string message{std::to_string(I) +
"th element incorrect"};
148 check(equality, message, logger, nodes.template node_weight<I>(), prediction.template get_node_weight<I>());
149 check_elements<Mode, I+1>(logger, nodes, prediction);
153 template<test_mode Mode, std::
size_t I = 0>
155 [[maybe_unused]]
const type& nodes,
156 [[maybe_unused]]
const equivalent_type& prediction)
158 if constexpr (I <
sizeof...(Ts))
160 const auto message{ std::to_string(I).append(
"th element incorrect") };
161 check(equality, message, logger, nodes.template get_node_weight<I>(), std::get<I>(prediction));
162 check_elements<Mode, I + 1>(logger, nodes, prediction);
167 template<
class Weight,
bool PropagateCopy=true,
bool PropagateMove=true,
bool PropagateSwap=true>
169 :
public maths::node_storage_base<Weight, std::vector<Weight, shared_counting_allocator<Weight, PropagateCopy, PropagateMove, PropagateSwap>>>
174 using allocator_type =
typename base_t::node_weight_container_type::allocator_type;
175 using size_type =
typename base_t::size_type;
176 using weight_type =
typename base_t::weight_type;
196 node_storage_tester(std::initializer_list<weight_type> weights,
const allocator_type& allocator)
197 :
base_t{weights, allocator}
209 :
base_t{std::move(s), allocator}
223 using base_t::reserve;
224 using base_t::capacity;
225 using base_t::shrink_to_fit;
226 using base_t::add_node;
227 using base_t::insert_node;
228 using base_t::erase_node;
229 using base_t::erase_nodes;
231 using base_t::get_node_allocator;
234 template<
class Weight, std::
size_t N>
242 template<
class Weight,
bool PropagateCopy,
bool PropagateMove,
bool PropagateSwap>
253 template<
class Weight, std::
size_t N>
255 :
public value_tester<maths::static_node_storage<Weight, N>>
Utilities for allocation testing.
bool check(CheckType flavour, std::string description, test_logger< Mode > &logger, Iter first, Sentinel last, PredictionIter predictionFirst, PredictionSentinel predictionLast, tutor< Advisor > advisor={})
The workhorse for comparing the contents of ranges.
Definition: FreeCheckers.hpp:377
Node storage for graphs with heterogeneous node weights.
Classes to allow homogeneous treatment of graphs with empty/non-empty node weights.
Utilities for checking regular semantics.
Classes for node storage that may be used in a constexpr context.
Definition: HeterogeneousNodeStorage.hpp:27
Definition: NodeStorage.hpp:37
Definition: NodeStorage.hpp:272
Definition: StaticNodeStorage.hpp:26
Definition: NodeStorageTestingUtilities.hpp:170
Definition: NodeStorageTestingUtilities.hpp:236
Definition: TestLogger.hpp:183
Definition: FreeCheckers.hpp:82
Definition: FreeCheckers.hpp:87
Definition: NodeStorageTestingUtilities.hpp:51
Definition: NodeStorageTestingUtilities.hpp:26
class template, specializations of which implement various comparisons for the specified type.
Definition: FreeCheckers.hpp:78