Module common_testing::assert

source ·

Traits

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

Functions

  • Asserts that the value implements Cow and is borrowed. This is useful for testing that a Cow is not cloned.
  • Asserts cursor position has reached the end. This is useful for testing that a cursor has been completely consumed.
  • Asserts that the value is default.
  • 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.
  • 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.
  • 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.
  • More specific than assert::equal, must be for AsRef<u8>.
  • Assert that the value is err.
  • Asserts that the value is err and returns the value.
  • Assert that the value is none.
  • 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.
  • Assert that the value is ok.
  • Asserts that the value is ok and returns the value.
  • Asserts that the value implements Cow and is owned. This is useful for testing that a Cow is cloned.
  • Assert that they share the same AsRef somewhere.
  • Assert that the value is some.
  • Asserts that the value is some and returns the value.