A library for automatic random testing, inspired by Haskell's excellent QuickCheck.
int[] mysort(int[] arr)
{
// ...
return arr;
}
unittest
{
import qcheck;
import std.algorithm;
quickCheck!((int[] a) => mysort(a.dup).equal(a.sort()));
}
The library can also just be used to generate random data, see getArbitrary
.
unittest
{
import qcheck.arbitrary;
auto sarray = getArbitrary!(int[4])();
auto array = getArbitrary!(float[])();
auto aarray = getArbitrary!(int[string])();
}