use super::{AssertInfo, Assertion, Debug, Display};
#[must_use = "assertions do not fire unless returned from a test"]
pub struct Succeed {
info: AssertInfo,
}
impl Display for Succeed {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let AssertInfo { file, line, column } = self.info;
write!(
f,
"assertion starting at {file}:{line}:{column} was forced success"
)
}
}
impl Debug for Succeed {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
Display::fmt(self, f)
}
}
impl Succeed {
#[doc(hidden)]
pub const fn manual_constructor(file: &'static str, line: u32, column: u32) -> Self {
Self {
info: AssertInfo { file, line, column },
}
}
}
#[cfg(feature = "std")]
impl std::process::Termination for Succeed {
fn report(self) -> std::process::ExitCode {
std::process::ExitCode::SUCCESS
}
}
impl Assertion for Succeed {
fn test(&self) -> bool {
true
}
}
#[macro_export]
macro_rules! succeed {
() => {
$crate::assertion::Succeed::manual_constructor(
::core::file!(),
::core::line!(),
::core::column!(),
)
};
}