macro_rules! assert_pos_relative_eq {
($left:expr, $right:expr, $epsilon:expr) => { ... };
}Expand description
Asserts that two Positive values are relatively equal within a given epsilon.
This macro compares two Positive values and checks if their relative difference
is within the specified epsilon. It handles cases where one or both values
are zero, ensuring that the non-zero value is less than or equal to epsilon.
§Examples
use positive::Positive;
use positive::{assert_pos_relative_eq, pos_or_panic};
let a = pos_or_panic!(1.0);
let b = pos_or_panic!(1.0001);
let epsilon = pos_or_panic!(0.001);
assert_pos_relative_eq!(a, b, epsilon); // Passesⓘ
use positive::{assert_pos_relative_eq, pos_or_panic};
let c = pos_or_panic!(1.0);
let d = pos_or_panic!(2.0);
let epsilon = pos_or_panic!(0.001);
assert_pos_relative_eq!(c, d, epsilon); // Panics§Panics
This macro panics if the relative difference between the two values is greater than
the specified epsilon, or if one value is zero and the other is greater than epsilon.
The panic message includes the values being compared, the expected relative difference,
and the actual relative difference.