use core::fmt::{Debug, Display};
use crate::AssertInfo;
mod binary;
mod collected;
mod fail;
mod multi;
mod should_fail;
mod succeed;
mod unary;
#[cfg(feature = "alloc")]
mod multi_dyn;
pub use binary::BinaryAssertion;
pub use collected::{AssertAll, CollectedAssertion};
pub use fail::Fail;
pub use multi::MultiAssertion;
pub use should_fail::ShouldFail;
pub use succeed::Succeed;
pub use unary::UnaryAssertion;
#[cfg(feature = "alloc")]
pub use multi_dyn::MultiDynAssertion;
#[cfg(feature = "std")]
#[must_use = "assertions do not fire unless returned from a test"]
pub trait Assertion: Debug + Display + std::process::Termination {
fn test(&self) -> bool;
fn should_fail(self) -> ShouldFail<Self>
where
Self: Sized,
{
ShouldFail(self)
}
#[allow(
clippy::panic,
reason = "I agree with you clippy, but some people don't care about panics."
)]
fn unwrap(&self) {
assert!(self.test(), "failed assertion was unwrapped:\n{self}");
}
}
#[cfg(not(feature = "std"))]
#[must_use = "assertions do not fire unless returned from a test"]
pub trait Assertion: Debug + Display {
fn test(&self) -> bool;
fn should_fail(self) -> ShouldFail<Self>
where
Self: Sized,
{
ShouldFail(self)
}
#[allow(
clippy::panic,
reason = "I agree with you clippy, but some people don't care about panics."
)]
fn unwrap(&self) {
assert!(self.test(), "failed assertion was unwrapped:\n{self}");
}
}