Skip to main content

Crate utmt

Crate utmt 

Source
Expand description

This crate offers a list of macros for unittest support. The aim of these macros is to extends existing rust unittest macros by adding some new assertions and facilities.

Macros§

assert_all
Multi-assertion macro. This macro take at least 1 argument as an expression. Several expressions can be added.
assert_all_match_result
Multi-assertion macro for method that return a Result value. Seval expressions of this type must be specified.
assert_match_natural_result
Assert for a Result<T, E> value. If the value is a type of Ok(_) the result is Ok(()). If the value is a type of Err(_) the result is the natural error from the method calling.
assert_match_option
Assert the Option<T> value. If the value is Some(...) return Ok(()), otherwise a Err value.
assert_match_result
Assert for a Result<T, E> value. If the value is a type of Ok(_) the result is Ok(()). If the value is a type of Err(_) the result is a type of Err(&str).
assert_match_values
Assertion for matching specific values.
assert_none
Assertion for a non value. If this option is none, the assertion is valid.
assert_not_match_option
Assert the Option<T> for a result that does not match the given argument. If the value is None return Ok(()) result. If the value is Some(...) return None result.
assert_not_match_result
Assert for a not validResult<T, E> value. If the value is a type of Err(_) the result is Ok(()). If the value is a type of Ok(_) the result is a type of Err(&str).
assert_not_match_values
Assert on invalid values.
assert_not_none
Assertion for an option value. If this option value is not none, the assertion is valid.
assert_not_same_slices
Assertion for not same slices. Not same slices means, is not same content or not same the size.
assert_same_slices
Assertion for same slices. Same slices means, the order is not guaranteed, but the size and the content are equals.
assert_slices_eq
Assertion about slices equality.
assert_slices_ne
Assertion about slices inequality.
facility_match_values
Match the specific values.
fail
Force the test failure.
repeat
Repeat the code block for a number of iterations.
setup
Setup for unit test initialization.
teardown
Teardown for unit tests. The code of the teardown macro will be running automatically while the test will end, with test failure or not.

Functions§

mark_fail
Shows a simple mark for a failed test
mark_ok
Shows a simple mark for a test ok
mark_run
Shows a simple mark for a test running
random_string
Creates a random string for the specified length.