1extern crate num_traits;
2#[macro_export]
5macro_rules! assert_delta {
6 ($x:expr, $y:expr, $delta:expr) => {
7 assert!(
8 ($x - $y).abs() <= num_traits::NumCast::from($delta).unwrap(),
9 "{} is not within {} of {}",
10 stringify!($x),
11 $delta,
12 stringify!($y)
13 );
14 };
15}
16
17#[macro_export]
18macro_rules! assert_eq_len {
19 ($a:expr, $b:expr) => {
20 if $a.len() != $b.len() {
21 return Err(Error::DiffLen);
22 }
23 };
24}
25
26#[macro_export]
27macro_rules! assert_empty {
28 ($a:expr) => {
29 if $a.is_empty() {
30 return Err(Error::EmptyVal);
31 }
32 };
33}