Macro assert_io_read_to_string_eq_x

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

Assert a ::std::io::Read read_to_string() value is equal to an expression.

Pseudocode:
(reader.read_to_string(a_string) ⇒ a_string) = expr

  • If true, return a_string.

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

§Examples

use assertables::*;
use std::io::Read;

let mut reader = "alfa".as_bytes();
let value = String::from("alfa");
assert_io_read_to_string_eq_x!(reader, &value);

// This will panic
let mut reader = "alfa".as_bytes();
let value = String::from("bravo");
assert_io_read_to_string_eq_x!(reader, &value);
// assertion failed: `assert_io_read_to_string_eq_x!(a_reader, b_expr)`
// https://docs.rs/assertables/9.5.4/assertables/macro.assert_io_read_to_string_eq_x.html
//  a_reader label: `reader`,
//  a_reader debug: `[]`,
//    b_expr label: `&value`,
//    b_expr debug: `\"bravo\"`,
//               a: `\"alfa\"`,
//               b: `\"bravo\"`

§Module macros