Macro tokio_test::assert_ok
source · macro_rules! assert_ok { ($e:expr) => { ... }; ($e:expr,) => { ... }; ($e:expr, $($arg:tt)+) => { ... }; }
Expand description
Asserts that the expression evaluates to Ok
and returns the value.
This will invoke the panic!
macro if the provided expression does not evaluate to Ok
at
runtime.
§Custom Messages
This macro has a second form, where a custom panic message can be provided with or without arguments for formatting.
§Examples
use tokio_test::assert_ok;
let n: u32 = assert_ok!("123".parse());
let s = "123";
let n: u32 = assert_ok!(s.parse(), "testing parsing {:?} as a u32", s);