Expand description
Assertor makes test assertions and failure messages more human-readable.
Assertor is heavy affected by Java Truth in terms of API design and error messages.
§Example
use assertor::*;
assert_that!("foobarbaz").contains("bar");
assert_that!("foobarbaz").ends_with("baz");
assert_that!(0.5).with_abs_tol(0.2).is_approx_equal_to(0.6);
assert_that!(vec!["a", "b"]).contains("a");
assert_that!(vec!["a", "b"]).has_length(2);
assert_that!(vec!["a", "b"]).contains_exactly(vec!["a", "b"]);
assert_that!(Option::Some("Foo")).has_value("Foo");
§Failure cases
ⓘ
use assertor::*;
assert_that!(vec!["a", "b", "c"]).contains_exactly(vec!["b", "c", "d"]);
// missing (1) : ["d"]
// unexpected (1): ["a"]
// ---
// expected : ["b", "c", "d"]
// actual : ["a", "b", "c"]
Modules§
- testing
- Module for testing the assertor library itself. Expected to be used by library developers.
Macros§
- assert_
that - An assertion macro that panics when the assertion fails.
- check_
that - Only for library developers. An assertion macro to get the result of assertion without throwing panic. Expected to be used for testing assertion library.
Structs§
- Assertion
Result - Contains assertion results which will be shown in the assertion messages.
- Location
- Code location.
- Subject
- Data structure that contains a value to be tested (actual value) with auxiliary data (ex. line pos, description).
Enums§
- Fact
- A piece of assertion message.
Traits§
- Assertion
Strategy - A behavior for assertion pass and failure.
AssertionResult
implements this traits. - Boolean
Assertion - Trait for boolean assertion.
- Comparable
Assertion - Trait for comparison assertions.
- CowAssertion
- Trait for Cow assertion.
- Equality
Assertion - Trait for equality assertion.
- Float
Assertion - Trait for float assertion.
- Iterator
Assertion - Trait for iterator assertion.
- MapAssertion
- Trait for map assertion.
- Option
Assertion - Trait for option assertion.
- Ordered
MapAssertion - Trait for ordered map assertion.
- Ordered
SetAssertion - Trait for sorted set assertions.
- Result
Assertion - Trait for result assertion.
- SetAssertion
- Trait for set assertion.
- String
Assertion - Trait for string assertion.
- VecAssertion
- Trait for vector assertion.