Write a Boundary Example Before Coding
Scenario
Library checkout allows borrowing only when a reader currently has fewer than 3 books.
Try it yourself
Compare the three neighbors around the 3-book limit.
| Case | Result |
|---|---|
| borrowedCount = 2 (just below limit) | Select a choice above to see what happens. |
| borrowedCount = 3 (exact limit) | Select a choice above to see what happens. |
| borrowedCount = 4 (above limit) | Select a choice above to see what happens. |
Reveal the explanation
- borrowedCount = 2 (just below limit)
Allowed (true). One more book brings the reader to 3.
- borrowedCount = 3 (exact limit)
Declined (false). "Fewer than 3" excludes 3 itself.
- borrowedCount = 4 (above limit)
Declined (false). Already over the limit.
Testing only 0 and 10 would miss a buggy <= 3 check. Writing 2, 3, and 4 by hand first makes off-by-one errors impossible to overlook.
Download shared test cases
Your turn
Write a three-neighbor hand example for a workshop requiring at least 10 minutes of check-in buffer.
Common mistake Testing 0 minutes and 30 minutes while skipping 9, 10, and 11.
Check your work
9 → Declined, 10 → Accepted, 11 → Accepted.
Quick check
This browser could not save your progress. Changes last until you leave the page.