unit-threaded v0.6.5 - Type-parametrized tests

Jacob Carlborg via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Thu Mar 10 00:09:40 PST 2016


On 2016-03-09 19:01, Atila Neves wrote:
> The forum must be sick of hearing from me... :P For those not in the
> know, unit-threaded is an advanced unit testing library for D:
>
> http://code.dlang.org/packages/unit-threaded
>
> The v0.6.3 release had tests parametrized by value; this v0.6.5 release
> brings with it the possibility of parametrizing tests by type, like so:
>
> @Types!(int, byte)
> void testInit(T)() {
>      assert(T.init == 0);
> }
>
> This will run the testInit code twice, once for each type, and report
> them as separate tests:
>
> tests.pass.attributes.testInit.int:
> tests.pass.attributes.testInit.byte:
>
>
> I've literally only written that silly testInit example yet. But imagine
> how easy it'd be to test, say, different input ranges.
>
> I'm thinking of ways of getting the parametrized tests to work with the
> built-in unittest blocks. I assume it'll be hacky. Right now it's the
> only thing that requires non-standard test functions and I'm trying to
> augment the existing unit testing features of D instead of replacing them.

Do you have a slightly more extended example that shows how this is used?

-- 
/Jacob Carlborg


More information about the Digitalmars-d-announce mailing list