osom_lib_test_macros/
assert_eq_hex.rs

1/// Compares two operands by equality. If operands are not equal panics
2/// and prints both operands as hex arrays.
3///
4/// # Arguments
5///
6/// Both arguments have to be arrays, slices or vectors.
7#[macro_export]
8macro_rules! assert_eq_hex {
9    ($left:expr, $right:expr) => {{
10        let left_expr = $crate::traits::AsDisplayAsHex::as_display_as_hex(&($left));
11        let right_expr = $crate::traits::AsDisplayAsHex::as_display_as_hex(&($right));
12        if left_expr.as_slice() != right_expr.as_slice() {
13            panic!(
14                r#"assertion `left == right` failed
15  left: {left_expr}
16 right: {right_expr}"#
17            )
18        }
19    }};
20}
21
22/// Compares two operands by equality. If operands are equal panics
23/// and prints a single operand as hex array.
24///
25/// # Arguments
26///
27/// Both arguments have to be arrays, slices or vectors.
28#[macro_export]
29macro_rules! assert_neq_hex {
30    ($left:expr, $right:expr) => {{
31        let left_expr = $crate::traits::AsDisplayAsHex::as_display_as_hex(&($left));
32        let right_expr = $crate::traits::AsDisplayAsHex::as_display_as_hex(&($right));
33        if left_expr.as_slice() == right_expr.as_slice() {
34            panic!(
35                r#"assertion `left != right` failed
36  value: {left_expr}"#
37            )
38        }
39    }};
40}