public class BetweenKt
| Modifier and Type | Method and Description |
|---|---|
static Matcher<java.lang.Double> |
between(double a,
double b,
double tolerance)
Matcher that matches doubles and intervals
|
static void |
shouldBeBetween(double $receiver,
double a,
double b,
double tolerance)
Asserts that this Double is in the interval [a-tolerance , b+tolerance]
|
static void |
shouldNotBeBetween(double $receiver,
double a,
double b,
double tolerance)
Asserts that this Double is NOT in the interval [a-tolerance , b+tolerance]
|
public static void shouldBeBetween(double $receiver,
double a,
double b,
double tolerance)
Asserts that this Double is in the interval [a-tolerance , b+tolerance]
Verifies that this Double is greater than or equal to (a - tolerance) and less than or equal to (b + tolerance)
Opposite of BetweenKt.shouldNotBeBetween
0.5.shouldBeBetween(0.2, 0.7, 0.0) // Assertion passes
0.5.shouldBeBetween(0.2, 0.3, 0.0) // Assertion fails
0.5.shouldBeBetween(0.2, 0.3, 0.2) // Assertion passes
0.5.shouldBeBetween(0.2, 0.3, 0.1) // Assertion fails
BetweenKt.shouldNotBeBetweenpublic static void shouldNotBeBetween(double $receiver,
double a,
double b,
double tolerance)
Asserts that this Double is NOT in the interval [a-tolerance , b+tolerance]
Verifies that this Double is not:
Greater than or equal to (a - tolerance)
Less than or equal to (b + tolerance)
If and only if both the assertions are true, which means that this Double is in the interval, this assertion fails.
Opposite of BetweenKt.shouldBeBetween
0.5.shouldNotBeBetween(0.2, 0.7, 0.0) // Assertion fails
0.5.shouldNotBeBetween(0.2, 0.3, 0.0) // Assertion passes
0.5.shouldNotBeBetween(0.2, 0.3, 0.2) // Assertion fails
0.5.shouldNotBeBetween(0.2, 0.3, 0.1) // Assertion passes
BetweenKt.shouldBeBetweenpublic static Matcher<java.lang.Double> between(double a, double b, double tolerance)
Matcher that matches doubles and intervals
Verifies that a specific Double is in the interval [a - tolerance , b + tolerance].
For example:
0.5 is in the interval 0.4,0.6, because 0.4 <= 0.5 <= 0.6.
This matcher also includes the bonds of the interval, so:
0.5 is in the interval 0.5,0.6 because 0.5 <= 0.5 <= 0.6.
The parameter tolerance is used to allow a slightly wider range, to include possible imprecision, and can be 0.0.
0.5 is in the interval 0.6,0.7 when there's a tolerance of 0.1, because (0.6 - 0.1) <= 0.5 <= (0.7 + 0.1)
0.5 shouldBe between(0.1, 1.0, 0.0) // Assertion passes
0.5 shouldNotBe between(1.0, 2.0, 0.1) // Assertion passes
BetweenKt.shouldBeBetween,
BetweenKt.shouldNotBeBetween