Table-Drive the Unit Tests for a Function From Its Signature and Spec

You are helping me write table-driven unit tests. I will give you a function signature, a short description of intended behavior, and the language/test framework.

Function and spec:
[PASTE SIGNATURE AND SPEC]

Language and test framework: [e.g. Python/pytest]

Do the following:
1. List the input dimensions that matter (types, ranges, empty/null, ordering, size, encoding, state) and the boundaries on each.
2. Produce a table of cases with columns: name, inputs, expected output or error, and the reason this case exists. Cover: typical cases, each boundary on both sides, empty/minimal input, invalid input, and any case where two features interact.
3. Write the test code as a single parametrized test driven by that table, with readable case names.
4. Flag every case where the spec is silent or ambiguous. For those, do not guess the expected value: mark the row "SPEC UNCLEAR" and state the two plausible behaviors.
5. List any behavior that table tests cannot cover well (concurrency, time, I/O) and suggest a different test style for it.

Keep the table under 25 rows. Prefer fewer, sharper cases over exhaustive repetition.

Sign in to upvote this prompt.