Macro expecting::expect_some_eq

source ·
macro_rules! expect_some_eq {
    ( $some_a:expr, $b:expr ) => { ... };
}
Expand description

Expects that a is Some and its contents are equal to b.

§Examples


fn passing_test() -> Result<()> {
    expect_some_eq!(Some(1), 1);
    Ok(())
}

fn failing_test1() -> Result<()> {
    // wrong contents, 1 != 2
    expect_some_eq!(Some(1), 2);  // returns early
    Ok(())  // won't be reached
}

fn failing_test2() -> Result<()> {
    // first arg is None
    expect_some_eq!(None::<i32>, 2);  // returns early
    Ok(())  // won't be reached
}