How do you test pre-/post-conditions and invariants?
Magnus Lie Hetland
magnus at hetland.org
Fri Feb 25 14:16:51 PST 2011
On 2011-02-25 19:18:40 +0100, Jesse Phillips said:
> There has been talk of a std.unittest that would help with this, but for now:
> unittest {
> try {
> callMeWrong(wrong);
> assert(0);
> catch(AssertError e) {
> }
> }
>
> }
Ah. I used something like...
auto thrown = 0;
try foo() catch (AssertError) thrown++;
...
assert(thrown == k);
I guess I could wrap it up a bit, or something.
--
Magnus Lie Hetland
http://hetland.org
More information about the Digitalmars-d-learn
mailing list