Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::test_helpers Namespace Reference

Namespaces

namespace  detail
 

Functions

Rectangle union_of (const Rectangle &a, const Rectangle &b)
 Computes the tight axis-aligned union of two rectangles.
 
template<typename Snapshot >
size_t check_snapshot_node (const Snapshot &snap, const size_t idx, const size_t expected_depth)
 Recursively validates the structural invariants of a DebugSnapshot produced by RTree::debug_snapshot() or RStarTree::debug_snapshot(), reporting GTest failures on mismatch.
 
void expect_array_eq (const Array< size_t > &a, std::initializer_list< size_t > expected)
 Assert that an Aleph::Array contains exactly the elements in an initializer_list.
 

Function Documentation

◆ check_snapshot_node()

template<typename Snapshot >
size_t Aleph::test_helpers::check_snapshot_node ( const Snapshot &  snap,
const size_t  idx,
const size_t  expected_depth 
)

Recursively validates the structural invariants of a DebugSnapshot produced by RTree::debug_snapshot() or RStarTree::debug_snapshot(), reporting GTest failures on mismatch.

Checks, for the subtree rooted at idx: every node's recorded depth matches expected_depth (increasing by one per level), every leaf's stored bbox is the tight union of its entry_boxes, every internal node's bbox is the tight union of its children's bboxes, and every child index is in range. An out-of-range idx (including an empty snapshot) or a repeated node index (cycle) is reported as a test failure via GTest's non-fatal ADD_FAILURE/EXPECT_* macros instead of causing out-of-bounds access or unbounded recursion.

Parameters
snapSnapshot to validate.
idxIndex into snap.nodes of the subtree root to check.
expected_depthDepth expected for the node at idx.
Returns
Total number of leaf entries found in the subtree, or a partial count (possibly 0) if an invariant violation was detected.
Precondition
None; idx and the reachability of nodes are validated internally.
Exceptions
Neverthrows (violations are reported via GTest assertions, not exceptions).
Note
O(n) time and O(n) auxiliary space, where n = snap.nodes.size() (each node is visited at most once thanks to the cycle guard). Not thread-safe: relies on GTest's current-test-scoped assertion state and must not be called concurrently on the same test.

Definition at line 143 of file r_tree_debug_snapshot_test_helpers.H.

References Aleph::blossom_maximum_cardinality_matching(), and Aleph::test_helpers::detail::check_snapshot_node_impl().

Referenced by TEST(), and TEST().

◆ expect_array_eq()

void Aleph::test_helpers::expect_array_eq ( const Array< size_t > &  a,
std::initializer_list< size_t >  expected 
)
inline

Assert that an Aleph::Array contains exactly the elements in an initializer_list.

Performs equality checks between each element of the array and the corresponding element in the expected list.

Parameters
[in]aThe Aleph::Array to check.
[in]expectedInitializer list of expected values.

Definition at line 52 of file test_helpers.H.

References Aleph::blossom_maximum_cardinality_matching(), Aleph::Array< T >::size(), and value.

Referenced by TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().

◆ union_of()

Rectangle Aleph::test_helpers::union_of ( const Rectangle &  a,
const Rectangle &  b 
)
inline

Computes the tight axis-aligned union of two rectangles.

Parameters
aFirst rectangle.
bSecond rectangle.
Returns
The smallest axis-aligned rectangle enclosing both a and b.
Exceptions
Neverthrows.
Note
O(1) time and space. Pure function, hence thread-safe (no shared state, no side effects).

Definition at line 52 of file r_tree_debug_snapshot_test_helpers.H.

References Aleph::Rectangle::get_xmax(), Aleph::Rectangle::get_xmin(), Aleph::Rectangle::get_ymax(), and Aleph::Rectangle::get_ymin().

Referenced by Aleph::test_helpers::detail::check_snapshot_node_impl().