assertables

Macro assert_io_read_to_string_contains

source
macro_rules! assert_io_read_to_string_contains {
    ($reader:expr, $containee:expr $(,)?) => { ... };
    ($a:expr, $b:expr, $($message:tt)+) => { ... };
}
Expand description

Assert a std::io::Read read_to_string() contains a pattern.

Pseudocode:
(reader.read_to_string(a) ⇒ a) contains (expr into string)

  • If true, return ().

  • 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 = "hello".as_bytes();
let containee = "ell";
assert_io_read_to_string_contains!(reader, &containee);

// This will panic
let mut reader = "hello".as_bytes();
let containee = "zz";
assert_io_read_to_string_contains!(reader, &containee);
// assertion failed: `assert_io_read_to_string_contains!(reader, &containee)`
// https://docs.rs/assertables/8.18.0/assertables/macro.assert_io_read_to_string_contains.html
//     reader label: `&reader`,
//     reader debug: `[]`,
//  containee label: `&containee`,
//  containee debug: `\"zz\"`,
//      read string: `\"hello\"`

§Module macros