Test the edges, check against the slot version, then give the cost
The edges.
- Add
(45, 10)to the dump, and the walk reaches it withfree_fromat 50, so it raises. - Two blocks that both start at 0 raise on the second.
(90, 20)runs past 100,(5, 0)holds nothing and(-3, 5)starts before 0, and all three raise.[]gives[(0, 100)], and[(0, 100)]gives[].
The check start < free_from catches a negative start for free, because free_from begins at 0.
Test it against the slot version. On 2,000 random dumps of up to 10 blocks in arenas of up to 60 units, the two agreed every time.
Cost. The sort is O(b log b) for b blocks, and the walk is O(b). The arena's size never enters: 100,000 blocks scattered over an 80 GiB arena took 44.7 ms and gave 100,001 runs.
This is also the test you want for the practice problem. Rebuild the free runs from the allocator's own live blocks after every call, and compare them with its free list. If they ever differ, a merge, a split or a free went wrong on that exact call.
free_runs_from_dump from the worked example is in the editor, finished. Write agrees(size, blocks, free_list), the check to run after every call: rebuild the runs from the allocator's blocks and compare them with its free list.