macro_rules! read_assert {
($resource:expr, $n:expr, $expected:expr) => { ... };
}
Expand description
Convenience macro for reading and comparing a specific amount of bytes.
Reads a $n
number of bytes from $resource
and then compares that buffer with $expected
.
Panics if the buffers are not equal.
ยงExample
use tcp_test::read_assert;
use std::io::{self, Read};
struct Placeholder;
impl Read for Placeholder {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
buf[0] = 1;
buf[1] = 2;
buf[2] = 3;
Ok(3)
}
}
read_assert!(Placeholder {}, 3, [1, 2, 3]);