macro_rules! assert_diff_lt_x {
($a:expr, $b:expr, $x:expr $(,)?) => { ... };
($a:expr, $b:expr, $x:expr, $($message:tt)+) => { ... };
}
Expand description
Assert a difference is less than an expression.
Pseudocode:
Δ < x
-
If true, return
(lhs, rhs)
. -
Otherwise, call
panic!
with a message and the values of the expressions with their debug representations.
§Examples
use assertables::*;
let a: i8 = 10;
let b: i8 = 13;
let x: i8 = 4;
assert_diff_lt_x!(a, b, x);
// This will panic
let a: i8 = 10;
let b: i8 = 13;
let x: i8 = 2;
assert_diff_lt_x!(a, b, x);
// assertion failed: `assert_diff_lt_x!(a, b, x)`
// https://docs.rs/assertables/…/assertables/macro.assert_diff_lt_x.html
// a label: `a`,
// a debug: `10`,
// b label: `b`,
// b debug: `13`,
// x label: `x`,
// x debug: `2`,
// Δ: `3`,
// Δ < x: false