macro_rules! assert_fn {
($function:ident($left:expr, $right:expr)) => { ... };
(not $function:ident($left:expr, $right:expr)) => { ... };
}Expand description
Assert that a binary function call of 2 expressions returns true.
Syntax:
ⓘ
assert_fn!($function($left, $right))ⓘ
assert_fn!(not $function($left, $right))$functionis an identifier of a binary function.$leftand$rightare expressions.not’s appearance means expecting the function call to returnsfalseinstead oftrue.
Example: An assertion that passes
fn func<A, B>(_: A, _: B) -> bool {
true
}
assert_fn!(func(123, 456));Example: An assertion that fails
ⓘ
fn func<A, B>(_: A, _: B) -> bool {
false
}
assert_fn!(func(123, 456)); // panic: func(123, 456) ⇒ func(123, 456) ⇒ falseExample: A negative assertion that passes
fn func<A, B>(_: A, _: B) -> bool {
false
}
assert_fn!(not func(123, 456));Example: A negative assertion that fails
ⓘ
fn func<A, B>(_: A, _: B) -> bool {
true
}
assert_fn!(not func(123, 456)); // panic: func(123, 456) ⇒ func(123, 456) ⇒ true