Files
Adrian Kuta 2671c46f96 test: property-based tests for traversal & structural invariants (#38) (#46)
Add TreeNodePropertyTest: 23 properties checked over many seeded, randomly
generated trees instead of fixed examples. Covers the invariants from #38 —
all three orders visit the same node set with matching cardinality; pre/post
emit each subtree as a contiguous block; level-order is depth-monotonic;
child.depth == parent.depth + 1 (cross-checked against an independent BFS
level walk); nodeCount stays consistent across attach/detach, remove/insert
and clear; and every traversal terminates and is correctly ordered on deep
(5k-node chain) and wide (5k-child) trees. Also pins parent/child pointer
consistency, ancestor/leaf/sibling correctness, deepCopy/mapValues shape
preservation, and lca/distance/pathBetween.

The generator builds trees by uniform random attachment (iterative, so it is
stack-safe and free of left-heavy skew). Failures print the seed, so any case
reproduces. No new dependency — the suite is pure commonTest and runs on every
target (JVM/JS/Wasm/Native).
2026-06-08 13:29:30 +02:00
..