macro_rules! assert_read_to_string_eq_other_as_result {
    ($a_reader:expr, $b_reader:expr $(,)?) => { ... };
}
Expand description

Assert a std::io::Read read_to_string() is equal to another.

  • If true, return Result Ok(()).

  • Otherwise, return Result Err with a diagnostic message.

Examples

use std::io::Read;
let mut a = "alpha".as_bytes();
let mut b = "alpha".as_bytes();
let x = assert_read_to_string_eq_other_as_result!(a, b);
//-> Ok(())
let actual = x.unwrap();
let expect = ();
assert_eq!(actual, expect);

let mut a = "alpha".as_bytes();
let mut b = "bravo".as_bytes();
let x = assert_read_to_string_eq_other_as_result!(a, b);
//-> Err(…)
let actual = x.unwrap_err();
let expect = concat!(
    "assertion failed: `assert_read_to_string_eq_other!(left_reader, right_reader)`\n",
    "  left_reader label: `a`,\n",
    "  left_reader debug: `[]`,\n",
    " right_reader label: `b`,\n",
    " right_reader debug: `[]`,\n",
    "               left: `\"alpha\"`,\n",
    "              right: `\"bravo\"`",
);
assert_eq!(actual, expect);