Assert and the optional Message

Jacob Carlborg doob at me.com
Mon Mar 12 01:40:44 PDT 2012


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.

-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list