I am trying to figure out how to properly write unit tests for number conversion to have 100% test coverage and to cover all possibilities.
Let’s say, I have a function which converts integer to roman numeral. It works from 1 to 3999:
function integerToRoman(integer) { ... }
How can I make sure it actually works? Writing 4000 unit tests for every number between 1 and 3999 doesn’t seem like a good option. On the other hand, if I just pick some random numbers and write tests for them, then I cannot be 100% sure the function is working.
100% coverage doesn’t mean testing every single possible input value. But it means that you:
That’s it.