use crate::backend::Assertion;
pub trait NotModifier<T> {
fn not(self) -> Self;
}
impl<T: Clone> NotModifier<T> for Assertion<T> {
fn not(self) -> Self {
return Self {
value: self.value.clone(),
expr_str: self.expr_str,
negated: !self.negated,
steps: self.steps.clone(),
in_chain: self.in_chain, is_final: self.is_final, };
}
}
#[cfg(test)]
mod tests {
use crate::prelude::*;
#[test]
fn test_not_modifier() {
crate::Reporter::disable_deduplication();
let value = 42;
expect!(value).not().to_equal(100);
expect!(value).not().to_be_less_than(10);
let chain = expect!(value)
.not()
.to_be_less_than(30) .and()
.not()
.to_be_greater_than(50);
let result = chain.evaluate();
assert!(result, "NOT chain with AND should evaluate to true when both conditions are true");
}
}