QUnit Close assertion plugin
This plugin for QUnit adds close
, notClose
, close.percent
, and notClose.percent
assertion methods to test that a number is approximately equal (or not) to an expected number, within a given tolerance.
Usage
assert; assert; assertclose;// Alternatively:assert; assertnotClose;// Alternatively:assert;
Where:
maxDifference
: the maximum inclusive difference allowed (tolerance) between theactual
andexpected
numbersminDifference
: the minimum exclusive difference allowed (tolerance) between theactual
andexpected
numbersactual
,expected
,message
: The usual
Examples
Example 1: Number differences
QUnit;
Example 2: Percentage differences
QUnit;
For more examples, refer to the unit tests.