4 ms·
You tested a postcondition. What about preconditions and invariants, do you have separate tests for those assertions too, or just not bother?
by krona 4y ago
You tested a postcondition. What about preconditions and invariants, do you have separate tests for those assertions too, or just not bother?
- mollerhoj 4y agoPlease correct me if I'm wrong, but would a precondtion not just be the postcondition of the setup? Invariants would either have to be publically available and thus easily testable with similar methods, or, one would have to use assertions in the implemention. I try to avoid the latter, as it mixes implemations and 'test/invariants'. Granted, there are situations (usually in code that implements something very 'algorithm'-ish) where inline assertions are so useful that it would be silly to avoid them. (But implementing algos from scratch is rare in commercial code)
- int_19h 4y agoassertions are basically comments with teeth; why would you avoid them in any code, algorithmic or no?