macro_rules! assertable_read_to_string_eq {
($left:expr, $right:expr $(,)?) => { ... };
($left:expr, $right:expr, $($arg:tt)+) => { ... };
}
Expand description
Assert a std::io::Read read_to_string() is equal to another.
-
When true, return
Ok(())
. -
Otherwise, return
Err
with a message and the values of the expressions with their debug representations.
Examples
use std::io::Read;
let mut a = "a".as_bytes();
let mut b = "a".as_bytes();
let x = assertable_read_to_string_eq!(a, b);
//-> Ok(())
assert_eq!(x.unwrap(), ());
let mut a = "a".as_bytes();
let mut b = "b".as_bytes();
let x = assertable_read_to_string_eq!(a, b);
//-> Err("…")
// assertable failed: `assertable_read_to_string_eq!(left, right)`
// left: `\"a\"`,
// right: `\"b\"`
assert_eq!(x.unwrap_err(), "assertable failed: `assertable_read_to_string_eq!(left, right)`\n left: `\"a\"`,\n right: `\"b\"`".to_string());
This macro has a second form where a custom message can be provided.