Assert and the optional Message

Jonathan M Davis jmdavisProg at gmx.com
Mon Mar 12 10:25:09 PDT 2012


On Monday, March 12, 2012 09:40:44 Jacob Carlborg wrote:
> On 2012-03-11 22:12, Jonathan M Davis wrote:
> > On Sunday, March 11, 2012 13:13:58 Jacob Carlborg wrote:
> >> Yeah, exactly. And it feels a bit stupid to duplicate the assert
> >> statement just to throw something that isn't an AssertError.
> > 
> > Not to say that it's what you have to do, but I _would_ point out that all
> > of the unit testing frameworks that I've seen in other langages _do_
> > create their own custom assert statements, so that wouldn't be abnormal
> > at all. Now, in C++, assert doesn't throw anything (I don't remember if
> > it does in Java or not), and there's no built-in unit testing framework
> > using assert, so it's not as weird to use your own as it would be in D,
> > but it's still not uncommon in unit testing frameworks to define a set of
> > custom assertion functions specfically for unit testing.
> > 
> > - Jonathan M Davis
> 
> They usually define "assertEqual", "assertNotEqual" and so on. But
> basically all unit testing frameworks also have a basic "assert". I see
> know reason why the basic assert needs to be redefined.

It does if you need it to function differently than it does normally, which is 
more or less what you're looking to do here, but aside from that, no, there's 
probably no reason to.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list