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§

source

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();
source

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();
source

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();
source

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();
source

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();
source

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.

Implementors§