unit-threaded v0.8.0

Atila Neves atila.neves at gmail.com
Thu Jan 31 14:42:43 UTC 2019


On Wednesday, 30 January 2019 at 14:55:37 UTC, jmh530 wrote:
> On Wednesday, 30 January 2019 at 14:27:25 UTC, Atila Neves 
> wrote:
>> [snip]
>>
>> ------------------
>> @Types!(ubyte, byte)
>> @Types!(int, uint, float)
>> @UnitTest
>> void fun(T0, T1)() {
>>     static assert(T0.sizeof == 1);
>>     static assert(T1.sizeof == 4);
>> }
>> ------------------
>>
>> This now generates 6 tests, one for each combination of types, 
>> similarly to what already worked with the @Values UDA.
>
> I'm a little confused on this. What if you have void fun(T0, 
> T1, T2)) {}, but only two @Types listed? Does it just do the 
> first two?

It would fail to compile.

> Also, there is an example in the readme on @Values of
> @Values(1, 2, 3) unittest { assert(getValue!int % 2 == 0); }
> What if it's not so easy to create the values? I suppose you 
> could pass the parameters in @Values to some other function 
> that will then create what you actually need and then test 
> using that.

I've never had a need to use complicated values, so I haven't 
coded that.

If presented with an example, I think there's a high chance I'd 
consider it an anti-pattern.

> Maybe good to provide some more examples of advanced usage?

Documentation is hard. :(

I tried by using examples, but without knowing what's not clear 
it's hard for me to know what to do about it.



More information about the Digitalmars-d-announce mailing list