expectations_matcher/
lib.rsfn expected_single_outcome(
name: &str,
expectation: &ser::Expectation,
cases_to_run: &ser::CasesToRun,
) -> Option<Outcome> {
let (ser::Matchers { matchers }, outcome) = match expectation {
ser::Expectation::Skip(a) => (a, Outcome::Skip),
ser::Expectation::ExpectFailure(a) => match cases_to_run {
ser::CasesToRun::WithErrLogs => (a, Outcome::Skip),
_ => (a, Outcome::Fail),
},
ser::Expectation::ExpectPass(a) => match cases_to_run {
ser::CasesToRun::WithErrLogs => (a, Outcome::Skip),
_ => (a, Outcome::Pass),
},
ser::Expectation::ExpectFailureWithErrLogs(a) => match cases_to_run {
ser::CasesToRun::NoErrLogs => (a, Outcome::Skip),
_ => (a, Outcome::Fail),
},
ser::Expectation::ExpectPassWithErrLogs(a) => match cases_to_run {
ser::CasesToRun::NoErrLogs => (a, Outcome::Skip),
_ => (a, Outcome::Pass),
},
};
matchers.iter().any(|matcher| matcher.matches(name)).then_some(outcome)
}
pub fn expected_outcome(name: &str, expectations: &ser::Expectations) -> Option<Outcome> {
let ser::Expectations { expectations, cases_to_run } = expectations;
expectations
.iter()
.rev()
.find_map(|expectation| expected_single_outcome(name, expectation, cases_to_run))
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Outcome {
Pass,
Fail,
Skip,
}