Skip to main content

Crate assert4rs

Crate assert4rs 

Source
Expand description

Fluent assertions for Rust.

This crate provides a fluent API for writing assertions in tests. All assertions start with Assert::that and can be chained:

use assert4rs::Assert;

Assert::that("foo")
    .is("foo")
    .is_not("bar");

Type-specific assertions are available for Option, Result, and Vec:

use assert4rs::Assert;

Assert::that(Some(42)).unwrap().is_gt(0);
Assert::that(vec![1, 2, 3]).contains(&2);

Values can be transformed with Assert::map to apply further assertions:

use assert4rs::Assert;

Assert::that("3")
    .map(|v| v.parse::<i32>().unwrap())
    .is(3);

Modules§

equals
option
result
string
vec

Structs§

Assert
Entry point for the Assert DSL.