mirror of
https://github.com/AdrianKuta/Tree-Data-Structure.git
synced 2026-06-19 19:00:14 +02:00
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).