Module assert

Source

Traits§

Unwrappable
A trait that can be R, Result<R>, Option<R>, Result<Option<R>>, or Option<Result<R>> and can unwrap to return R.

Functions§

borrowed
Asserts that the value implements Cow and is borrowed. This is useful for testing that a Cow is not cloned.
cursor_completely_consumed
Asserts cursor position has reached the end. This is useful for testing that a cursor has been completely consumed.
default
Asserts that the value is default.
equal
Asserts two values are equal using PartialEq, allowing for different types to be compared. Automatically unwraps Result and Option, failing the test if the value is Err or None. This is useful for removing boilerplate .unwrap().unwrap() calls in tests.
equal_bytes
More specific than assert::equal, must be for AsRef<u8>. On failure, the output message will show the hex values of the bytes for easier debugging of longer byte arrays.
equal_file_contents
Asserts that the value is equal to the contents of the file. Works for anything that implements AsRef<u8>. This is useful for testing against large fixtures. The file is read into memory and compared against the value.
equal_hex_bytes
More specific than assert::equal, must be for AsRef<u8>.
err
Assert that the value is err.
err_into
Asserts that the value is err and returns the value.
none
Assert that the value is none.
not_equal
Asserts two values are not equal using PartialEq, allowing for different types to be compared. Automatically unwraps Result and Option, failing the test if the value is Err or None. This is useful for removing boilerplate .unwrap().unwrap() calls in tests.
ok
Assert that the value is ok.
ok_into
Asserts that the value is ok and returns the value.
owned
Asserts that the value implements Cow and is owned. This is useful for testing that a Cow is cloned.
ref_equal
Assert that they share the same AsRef somewhere.
some
Assert that the value is some.
some_into
Asserts that the value is some and returns the value.