4 ms·
One answer to that is to apply property based testing. If you're testing an addition algorithm, for example, you might test that A + B == B + A A + 0 ==
by jameshart 10y ago
One answer to that is to apply property based testing. If you're testing an addition algorithm, for example, you might test that
A + B == B + A
A + 0 == A
(A + B) + C == A + (B + C)
A + B != A + C (given B != C)
- slavik81 10y agoIt's a good idea in principle, though your third and fourth properties are not true of floating point addition. When you have one available, testing against the results against a reference implementation is a little more direct. Though, given how easy those property tests are, you might as well do both.