NumericAssertions extension
Extension providing assertion methods for numeric values.
This extension adds various assertion methods to num types to help with testing numeric conditions. Each method performs a specific validation and throws a test failure if the condition is not met.
Example usage:
void main() {
test('numeric assertions', () {
5.assertGreaterThan(3);
10.assertDivisibleBy(2);
7.assertPrime();
});
}
- on
Methods
-
assertBetween(
num min, num max, {String? message}) → void -
Available on num, provided by the NumericAssertions extension
Asserts that this number is betweenmin
andmax
(inclusive). -
assertDivisibleBy(
num divisor, {String? message}) → void -
Available on num, provided by the NumericAssertions extension
Asserts that this number is evenly divisible bydivisor
. -
assertEven(
{String? message}) → void -
Available on num, provided by the NumericAssertions extension
Asserts that this number is even. -
assertGreaterOrEqual(
num value, {String? message}) → void -
Available on num, provided by the NumericAssertions extension
Asserts that this number is greater than or equal tovalue
. -
assertGreaterThan(
num value, {String? message}) → void -
Available on num, provided by the NumericAssertions extension
Asserts that this number is greater thanvalue
. -
assertLessOrEqual(
num value, {String? message}) → void -
Available on num, provided by the NumericAssertions extension
Asserts that this number is less than or equal tovalue
. -
assertLessThan(
num value, {String? message}) → void -
Available on num, provided by the NumericAssertions extension
Asserts that this number is less thanvalue
. -
assertMultipleOf(
num factor, {String? message}) → void -
Available on num, provided by the NumericAssertions extension
Asserts that this number is a multiple offactor
. -
assertNegative(
{String? message}) → void -
Available on num, provided by the NumericAssertions extension
Asserts that this number is negative (less than zero). -
assertOdd(
{String? message}) → void -
Available on num, provided by the NumericAssertions extension
Asserts that this number is odd. -
assertPerfectSquare(
{String? message}) → void -
Available on num, provided by the NumericAssertions extension
Asserts that this number is a perfect square. -
assertPositive(
{String? message}) → void -
Available on num, provided by the NumericAssertions extension
Asserts that this number is positive (greater than zero). -
assertPrime(
{String? message}) → void -
Available on num, provided by the NumericAssertions extension
Asserts that this number is prime. -
assertZero(
{String? message}) → void -
Available on num, provided by the NumericAssertions extension
Asserts that this number is exactly zero.