macro_rules! assert_read_to_string_eq {
    ($a_reader:expr, $b_expr:expr $(,)?) => { ... };
    ($a_reader:expr, $b_expr:expr, $($arg:tt)+) => { ... };
}
Expand description

Assert a read_to_string() value is 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;

let mut reader = "alpha".as_bytes();
let value = String::from("alpha");
assert_read_to_string_eq!(reader, &value);
//-> ()

let result = panic::catch_unwind(|| {
let mut reader = "alpha".as_bytes();
let value = String::from("bravo");
assert_read_to_string_eq!(reader, &value);
//-> panic!
});
let actual = result.unwrap_err().downcast::<String>().unwrap().to_string();
let expect = concat!(
    "assertion failed: `assert_read_to_string_eq!(left_reader, right_expr)`\n",
    " left_reader label: `reader`,\n",
    " left_reader debug: `[]`,\n",
    "  right_expr label: `&value`,\n",
    "  right_expr debug: `\"bravo\"`,\n",
    "              left: `\"alpha\"`,\n",
    "             right: `\"bravo\"`"
);
assert_eq!(actual, expect);