unittest blocks not being run inside of class and struct templates

NoBigDeal256 via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jul 24 19:48:57 PDT 2017


On Tuesday, 25 July 2017 at 02:18:41 UTC, Adam D. Ruppe wrote:
> On Tuesday, 25 July 2017 at 02:11:20 UTC, NoBigDeal256 wrote:
>> it passes when it should fail because the unittest block is 
>> never executed. Why is this?
>
> Did you actually instantiate the class somewhere? A template 
> has no concrete code unless created with an argument 
> somewhere...

Well shit that was the issue. My mistake, I should have thought 
of that, but it makes total sense now.

What is the standard way of testing class templates in the 
context of a library where some of the classes may never actually 
be used by the library itself? I know I could just make a private 
module-level field declaration that just instantiates a template 
but that seems like an ugly way of handling it. Any suggestions 
on how you would handle this?


More information about the Digitalmars-d-learn mailing list