Trait clearcheck::assertions::int::IntAssertion
source · pub trait IntAssertion<T: Integer + PartialEq + Default> {
// Required methods
fn should_be_positive(&self) -> &Self;
fn should_be_negative(&self) -> &Self;
fn should_be_even(&self) -> &Self;
fn should_be_odd(&self) -> &Self;
fn should_be_zero(&self) -> &Self;
fn should_not_be_zero(&self) -> &Self;
}
Expand description
IntAssertion enables assertions about various properties of integers.
It offers a fluent interface for chaining multiple assertions.
Example
use clearcheck::assertions::int::IntAssertion;
use clearcheck::assertions::ordered::OrderedAssertion;
let value = 24;
value
.should_be_positive()
.should_be_even()
.should_be_in_inclusive_range(10..=40);
Required Methods§
sourcefn should_be_positive(&self) -> &Self
fn should_be_positive(&self) -> &Self
- Asserts that the integer value is positive.
- Returns a reference to self for fluent chaining.
- Panics if the assertion fails.
Example
use clearcheck::assertions::int::IntAssertion;
let value = 10;
value.should_be_positive();
sourcefn should_be_negative(&self) -> &Self
fn should_be_negative(&self) -> &Self
- Asserts that the integer value is negative.
- Returns a reference to self for fluent chaining.
- Panics if the assertion fails.
Example
use clearcheck::assertions::int::IntAssertion;
let value = -10;
value.should_be_negative();
sourcefn should_be_even(&self) -> &Self
fn should_be_even(&self) -> &Self
- Asserts that the integer value is even.
- Returns a reference to self for fluent chaining.
- Panics if the assertion fails.
Example
use clearcheck::assertions::int::IntAssertion;
let value = 14;
value.should_be_even();
sourcefn should_be_odd(&self) -> &Self
fn should_be_odd(&self) -> &Self
- Asserts that the integer value is odd.
- Returns a reference to self for fluent chaining.
- Panics if the assertion fails.
Example
use clearcheck::assertions::int::IntAssertion;
let value = 5;
value.should_be_odd();
sourcefn should_be_zero(&self) -> &Self
fn should_be_zero(&self) -> &Self
- Asserts that the integer value is zero.
- Returns a reference to self for fluent chaining.
- Panics if the assertion fails.
Example
use clearcheck::assertions::int::IntAssertion;
let value = 0;
value.should_be_zero();
sourcefn should_not_be_zero(&self) -> &Self
fn should_not_be_zero(&self) -> &Self
- Asserts that the integer value is not zero.
- Returns a reference to self for fluent chaining.
- Panics if the assertion fails.
Example
use clearcheck::assertions::int::IntAssertion;
let value = 5;
value.should_not_be_zero();
Object Safety§
This trait is not object safe.