Macro assertables::assert_lt
source · [−]macro_rules! assert_lt {
($a:expr, $b:expr $(,)?) => { ... };
($a:expr, $b:expr, $($arg:tt)+) => { ... };
}Expand description
Assert a value is less than another.
-
If true, return
(). -
Otherwise, call
panic!with a message and the values of the expressions with their debug representations.
Examples
let a = 1;
let b = 2;
assert_lt!(a, b);
//-> ()
let result = panic::catch_unwind(|| {
let a = 2;
let b = 1;
assert_lt!(a, b);
//-> panic!
});
let actual = result.unwrap_err().downcast::<String>().unwrap().to_string();
let expect = concat!(
"assertion failed: `assert_lt!(left, right)`\n",
" left label: `a`,\n",
" left debug: `2`,\n",
" right label: `b`,\n",
" right debug: `1`,\n",
" left: `2`,\n",
" right: `1`"
);
assert_eq!(actual, expect);