dcheck 0.1.0
Library for generating random data sets and automated checking of test constraints
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
DCheck
Library for generating random data sets and automated checking of test constraints. The library design is inspired by Haskell one - QuickCheck. User define Arbitrary
template (behaves like typeclass in haskell) for a type to add random generating feature and result shrinking. Then the library can pass random sets of data into special functions called constraints and provide you fancy formatted minimal fail case.
Usage
First, consider simple example:
unittest
{
checkConstraint!((int a, int b) => a + b == b + a);
}
As the provided delegate is always true unittest passes clearly.
Negative result example:
unittest
{
import std.math;
checkConstraint!((int a, int b) => abs(a) < 100 && abs(b) < 100)
}
DCheck will find the fail case:
==============================
Constraint __lambda2 is failed!
Calls count: 1. Shrinks count: 24
Parameters:
0: int "" = -61
1: int "" = -30
Result shrinking is performed to provide you concise fail case.
DCheck can detect parameter names for regular functions:
bool foo(bool a, bool b)
{
return a && !b;
}
unittest
{
checkConstraint!foo;
}
Output:
core.exception.AssertError:
==============================
Constraint foo is failed!
Calls count: 1. Shrinks count: 0
Parameters:
0: bool "a" = true
1: bool "b" = true
Building
To use DCheck as dependency in your project add the following in your dub.json
file:
"dependencies": {
"dcheck": ">=0.1.0"
}
To run unittests, clone the repo and run:
dub test
- 0.1.0 released 10 years ago
- NCrashed/DCheck
- MIT
- Copyright © 2014, ncrashed
- Authors:
- Dependencies:
- none
- Versions:
-
0.1.0 2014-Mar-27 ~master 2014-Nov-04 - Download Stats:
-
-
0 downloads today
-
0 downloads this week
-
0 downloads this month
-
210 downloads total
-
- Score:
- 0.8
- Short URL:
- dcheck.dub.pm