macro_rules! assert_read_to_string_le {
    ($a_reader:expr, $b_reader:expr $(,)?) => { ... };
    ($a_reader:expr, $b_reader:expr, $($message:tt)+) => { ... };
}
Expand description

Assert a std::io::Read read_to_string() value is less than or equal to another.

  • If true, return ().

  • Otherwise, call panic! with a message and the values of the expressions with their debug representations.

Examples

use std::io::Read;

// Return Ok
let mut a = "alpha".as_bytes();
let mut b = "bravo".as_bytes();
assert_read_to_string_le!(a, b);
//-> ()

// Panic with error message
let result = panic::catch_unwind(|| {
let mut a = "bravo".as_bytes();
let mut b = "alpha".as_bytes();
assert_read_to_string_le!(a, b);
//-> panic!
});
assert!(result.is_err());
let actual = result.unwrap_err().downcast::<String>().unwrap().to_string();
let expect = concat!(
    "assertion failed: `assert_read_to_string_le!(left_reader, right_reader)`\n",
    "  left_reader label: `a`,\n",
    "  left_reader debug: `[]`,\n",
    " right_reader label: `b`,\n",
    " right_reader debug: `[]`,\n",
    "               left: `\"bravo\"`,\n",
    "              right: `\"alpha\"`"
);
assert_eq!(actual, expect);