dcheck.constraint

Module defines routines for checking constraints in automated mode.

To perform automated check user should define a delegate, that takes some arguments and by design should return always true. The checkConstraint function generates arguments via Arbitrary!T template and checks the delegate to be true.

If constrained returned false, checkConstraint function tries to shrink input parameters to find minimum fail case (of course, it shrink function of corresponding Arbitrary template is properly defined).

Public Imports

dcheck.arbitrary
public import dcheck.arbitrary;

Members

Functions

checkConstraint
void checkConstraint(size_t testsCount, size_t shrinkCount)

Checks constraint to return true value for random generated input parameters with Arbitrary template.

Examples

checkConstraint!((int a, int b) => a + b == b + a);
assertThrown!Error(checkConstraint!((int a, int b) => abs(a) < 100 && abs(b) < 100));
assertThrown!Error(checkConstraint!((bool a, bool b) => a && !b));

Meta

License

Subject to the terms of the MIT license, as written in the included LICENSE file.

Authors

NCrashed <ncrashed@gmail.com>