unit-threaded v0.6.5 - Type-parametrized tests
Jacob Carlborg via Digitalmars-d-announce
digitalmars-d-announce at puremagic.com
Fri Mar 11 00:06:19 PST 2016
On 2016-03-10 12:05, Atila Neves wrote:
> No, sorry. I haven't needed it yet. Something like this?
Yes.
> @Types!(int, string)
> void testArray(T)() {
> import std.container;
>
> auto arr = Array!T();
> arr.empty.shouldBeTrue;
>
> arr.insertBack(T.init);
> arr.empty.shouldBeFalse;
> auto l = arr.length;
> l.shouldEqual(1);
> }
I'm trying to think how this would be useful. Would you want to test
with different values than T.init? Or is there some library that can
generate random values based on a type?
What about user defined types? T.init my not be useful at all.
I don't want to sound negative but I'm trying to see the use cases.
--
/Jacob Carlborg
More information about the Digitalmars-d-announce
mailing list