expectations_matcher/
lib.rs1fn expected_single_outcome(
10 name: &str,
11 expectation: &ser::Expectation,
12 cases_to_run: &ser::CasesToRun,
13) -> Option<Outcome> {
14 let (ser::Matchers { matchers }, outcome) = match expectation {
15 ser::Expectation::Skip(a) => (a, Outcome::Skip),
16 ser::Expectation::ExpectFailure(a) => match cases_to_run {
17 ser::CasesToRun::WithErrLogs => (a, Outcome::Skip),
18 _ => (a, Outcome::Fail),
19 },
20 ser::Expectation::ExpectPass(a) => match cases_to_run {
21 ser::CasesToRun::WithErrLogs => (a, Outcome::Skip),
22 _ => (a, Outcome::Pass),
23 },
24 ser::Expectation::ExpectFailureWithErrLogs(a) => match cases_to_run {
25 ser::CasesToRun::NoErrLogs => (a, Outcome::Skip),
26 _ => (a, Outcome::Fail),
27 },
28 ser::Expectation::ExpectPassWithErrLogs(a) => match cases_to_run {
29 ser::CasesToRun::NoErrLogs => (a, Outcome::Skip),
30 _ => (a, Outcome::Pass),
31 },
32 };
33 matchers.iter().any(|matcher| matcher.matches(name)).then_some(outcome)
34}
35
36pub fn expected_outcome(name: &str, expectations: &ser::Expectations) -> Option<Outcome> {
39 let ser::Expectations { expectations, cases_to_run } = expectations;
40 expectations
41 .iter()
42 .rev()
43 .find_map(|expectation| expected_single_outcome(name, expectation, cases_to_run))
44}
45
46#[derive(Debug, Clone, Copy, PartialEq, Eq)]
48pub enum Outcome {
49 Pass,
50 Fail,
51 Skip,
52}