macro_rules! assert_next_eq_with_timeout {
($stream:expr, $expected:expr) => { ... };
($stream:expr, $expected:expr, $timeout:literal ms) => { ... };
($stream:expr, $expected:expr, $timeout:literal ms, $($msg:tt)*) => { ... };
($stream:expr, $expected:expr, $($msg:tt)*) => { ... };
}
Available on crate feature
testing
only.Expand description
Asserts that the next item from an asynchronous stream is equal to the expected value, with an optional timeout and custom error message.
§Arguments
$stream
- The asynchronous stream to retrieve the next item from.$expected
- The expected value to assert against.$timeout ms
(optional) - A timeout in milliseconds (e.g.,200ms
). Defaults to100ms
.$msg
(optional) - A formatted message string for assertion failure.
§Examples
let mut stream = tokio_stream::iter(vec![42]);
assert_next_eq_with_timeout!(stream, 42);
let mut stream = tokio_stream::iter(vec![42]);
assert_next_eq_with_timeout!(stream, 42, 200 ms);
let mut stream = tokio_stream::iter(vec![42]);
assert_next_eq_with_timeout!(
stream,
42,
"Expected 42 but got something else"
);
let mut stream = tokio_stream::iter(vec![42]);
assert_next_eq_with_timeout!(stream, 42, 200 ms, "Expected 42 within 200ms");