How do you test pre-/post-conditions and invariants?

Ary Manzana ary at esperanto.org.ar
Fri Feb 25 09:51:29 PST 2011


On 2/25/11 1:48 PM, spir wrote:
> On 02/25/2011 04:30 PM, Magnus Lie Hetland wrote:
>> Or, more generally, how do you test asserts (which is what I'm using
>> in my
>> preconditions etc.)?
>>
>> As far as I can see, collectException() won't collect errors, which is
>> what
>> assert() throws -- so what's the standard way of writing unit tests for
>> preconditions that use assert? (I.e., test that they will, in fact,
>> throw when
>> you break them.)
>
> See the page on DbC: http://www.digitalmars.com/d/2.0/dbc.html.
>
> Denis

By the way, the link to "Adding Contracts to Java" at the bottom of the 
page is broken.


More information about the Digitalmars-d-learn mailing list