26/27
Part 7 of 7 · Follow-upsLearn and do
What tests would you write?
When asked, name each test by the bug it catches. One tree per bug, small enough to check by hand:
- One machine. Catches a
startthat never checks whether it's already done. - A root whose id isn't 0. Catches code that assumes the root.
- Children listed out of sorted order, like
7: [9, 3]. Catches a shape that sorts. - Uneven branches, a leaf next to a deep branch. Catches finishing on the last child's answer, because the leaf answers long before its sibling.
Then the general checks from earlier: random trees in every order against the oracle, every message delivered twice, a lost message on each kind of link, and two counts at once.
The editor holds edge_trees(), to write, which returns a list of (tree, root) pairs. The tests run four broken machines on your trees in fifo and lifo order, and pass when each one fails on at least one tree.