ef_tests/assert.rs
1//! Various assertion helpers.
2
3use crate::Error;
4use std::fmt::Debug;
5
6/// A helper like `assert_eq!` that instead returns `Err(Error::Assertion)` on failure.
7pub fn assert_equal<T>(left: T, right: T, msg: &str) -> Result<(), Error>
8where
9 T: PartialEq + Debug,
10{
11 if left == right {
12 Ok(())
13 } else {
14 Err(Error::Assertion(format!("{msg}\n left `{left:?}`,\n right `{right:?}`")))
15 }
16}