3 ms·
I only have one piece of code for which I can say true 100% coverage exists: a library that works with HTML/CSS color values, and which ships a test that genera
by ubernostrum 10y ago
I only have one piece of code for which I can say true 100% coverage exists: a library that works with HTML/CSS color values, and which ships a test that generates all 16,777,216 hexadecimal and integer rgb() color values, and runs some functions with each value.
However, I don't run that as part of the normal test suite. It only gets run when I'm prepping a new release, as a final verification step; the normal runs-every-commit test suite just exercises with a selection of values likely to expose obvious problems.
- test1235 9y agoHow long does that take?
- ubernostrum 9y agoDepends on the machine. See the comments in the file: https://github.com/ubernostrum/webcolors/blob/master/tests/full_colors.py https://github.com/ubernostrum/webcolors/blob/master/tests/f... The fun part is people who criticize the generation of the integer triplets; yes, it's three nested loops and that's bad, but the total number of iterations will always be 16,777,216 no matter what algorithm you decide to use to generate them. So it uses nested loops since that's the most readable way to do it.
- dahauns 9y agoHmm...true 100% input coverage? Including the time domain? (Order dependency, Idempotence, etc...) :)
- voidpointer 9y agoJust out of curiosity... What is the point in testing all 2^24 possible color values?
- ubernostrum 9y agoThe point is being certain I haven't missed an edge case somewhere. The hard part is the percentage rgb() values, of which there are technically an uncountably infinite number (since any real number in the range 0-100 is a legal percentage value). For those I generate all 16,777,216 integer values, and verify that converting to percentage and back yields the original value.
- LgWoodenBadger 9y agohow do you know the test that generates those values is correct?
- ubernostrum 9y agoPython's test suite.