1 /// Assertion check for X is is within Y of Z
2 #[macro_export]
3 macro_rules! assert_near {
4     ($thing:expr, $expected:expr, $error:expr) => {
5         match (&$thing, &$expected, &$error) {
6             (thing_val, expected_val, error_val) => {
7                 if thing_val < &(expected_val - error_val) || thing_val > &(expected_val + error_val) {
8                     panic!(
9                         "assertion failed: {:?} is not within {:?} of {:?}",
10                         &*thing_val, &*error_val, &*expected_val
11                     )
12                 }
13             }
14         }
15     };
16 }
17