https://github.com/mif-0/easy-assert
https://github.com/mif-0/easy-assert
assertions rust-crate rust-lang rust-library rustlang testing
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/mif-0/easy-assert
- Owner: MIF-0
- License: mit
- Created: 2022-02-22T17:29:35.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-09-18T18:13:03.000Z (almost 3 years ago)
- Last Synced: 2025-10-24T23:44:04.673Z (8 months ago)
- Topics: assertions, rust-crate, rust-lang, rust-library, rustlang, testing
- Language: Rust
- Homepage:
- Size: 61.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
easy-assert crate, which will help you to create better tests
Add dependency to your `Cargo.toml`
```
[dev-dependencies]
assert-that = "0.2.1"
```
Example:
`NumericAssert::assert_that(actual(-1)).is_equal().to(expected(-1));`
If you need custom description, or you can't implement Display trait)
`StringAssert::assert_that(actual_with(value, description_fucntion))
.length()
.is(expected_with(5, description_fucntion));`
If you need custom match:
` CustomAssert::assert_that(actual(val1))
.matches_by(|a, b| a.eq(b))
.to(expected(val2));`
Available assertions:
`NumericAssert -> is_equal, is_not_equal, is_less, is_less_or_equal, is_greater, is_greater_or_equal`
`StringAssert -> is_equal, is_not_equal, length, contains`
`BooleanAssert -> is_true, is_false`
`OptionAssert -> is_none, is_some, contains` for now only with custom assertion or with list assertion
```
ListAssert ->
length;
with_element_matcher ->
is_equal_to ->
in_any_order;
in_order;
contains ->
in_any_order;
in_exact_order; - [A,B,C,A,D].contains([B,C]).in_exact_order() = true/[A,B,C,A,D].contains([B,D]).in_exact_order() = false
just_in_order; - [A,B,C,A,D].contains([B,C]).in_exact_order() = true/[A,B,C,A,D].contains([B,D]).in_exact_order() = true
is_not_equal_to ->
in_any_order; - At least one element should be different
in_order; - All elements can be same, but order different
does_not_contain ->
all(); - All elements from expected should be missed in actual
at_least_one(); - At least one element from expected should be missed in actual
```
`CustomAssert -> matches_by`
It is open source, feel free to submit merge requests or propose improvements.