26/28
Part 6 of 6 · Follow-upsLearn and do
What tests would you write?
One candidate had to write their own test cases after the code (1 report). Don't list examples. List the rules a right output keeps, then the edges.
Rules any output must keep, checked by code against any input:
- No title twice on the screen (or in a row or column, under the grid rule).
- No title twice in one row.
- No title that wasn't in its input row.
- The input rows are unchanged.
Edges, one test each:
- A title in one row's tail and another row's head. It catches tail titles going into
shown. - A row that runs out, and a row shorter than the screen.
- A width of 0, and an exempt row with a repeat inside it.
- Rows two apart that share a title. It catches a set that remembers only the row above.
- Under the grid rule, a title blocked in column 0 that fits column 1.
The rule checks also run on random pages, as in the worked example.
In the editor, write problems(rows, width, out): the sorted names of the rules out breaks, screen, row or unknown.