Hacker News new | ask | show | jobs
by bluGill 179 days ago
The original claim for TDD is your write tests for all your edge cases. It doesn't matter about inputs you didn't consider because they are covered in the edge. If you can only accept inputs from 2-7 (inclusive) you check 1,2,7,8 - if those pass you assume the rest work.
1 comments

You forgot 0, -1, null, "1".
Since I work in a strongly typed languages the last two will fail to compile and are thus not worth the bother - those who don't have that luxury of course need to test the edge cases that apply to them. The first are maybe, in my experience they are rarely a problem, but we need to go from the abstract to the particular algorithm before we can have a discussion on if they are potentially a problem or not.
If you're using Rust you can push it one level further: use a NonZeroU*.

More than that and you'll need nightly for now: https://docs.rs/ranged_integers/latest/ranged_integers/