Ah, simple solution to unittests inside templates

Nick Treleaven via Digitalmars-d digitalmars-d at puremagic.com
Sun Sep 18 03:23:07 PDT 2016


On Saturday, 17 September 2016 at 17:22:52 UTC, Andrei 
Alexandrescu wrote:
>     ///
>     static if (is(T == int)) unittest
>     {
>         Awesome awesome;
>         awesome.awesome;
>     }
> }
>
> The unittest documentation is nicely generated. The unittest 
> code itself is only generated for one instantiation.

Besides the other comments, we still have to instantiate 
Awesome!int somewhere for the tests to run, which could be 
forgotten or improperly done, failing silently. (Also int is 
arbitrary, unhelpful for the uninitiated).


More information about the Digitalmars-d mailing list