diff --git a/tokio-bin-process/src/event_matcher.rs b/tokio-bin-process/src/event_matcher.rs index 49ad20c..9c73fef 100644 --- a/tokio-bin-process/src/event_matcher.rs +++ b/tokio-bin-process/src/event_matcher.rs @@ -110,12 +110,17 @@ impl EventMatcher { /// Defines how many times the [`EventMatcher`] must match to pass an assertion. #[derive(Debug)] +#[non_exhaustive] pub enum Count { /// This matcher must match this many times to pass an assertion. Times(usize), /// This matcher may match 0 or more times and will still pass an assertion. /// Use sparingly but useful for ignoring a warning or error that is not appearing deterministically. Any, + /// This matcher must match this many times or more to pass an asssertion + GreaterThanOrEqual(usize), + /// This matcher must match this many times or fewer to pass an asssertion + LessThanOrEqual(usize), } impl From for Count { diff --git a/tokio-bin-process/src/process.rs b/tokio-bin-process/src/process.rs index ca0f163..eb3d181 100644 --- a/tokio-bin-process/src/process.rs +++ b/tokio-bin-process/src/process.rs @@ -432,6 +432,16 @@ impl BinProcess { panic!("Expected to find matches for {matcher:?}, {matcher_count} times but actually matched {count} times") } } + Count::GreaterThanOrEqual(x) => { + if *count < x { + panic!("Expected to find matches for {matcher:?}, greater than or equal to {x} times but actually matched {count} times") + } + } + Count::LessThanOrEqual(x) => { + if *count > x { + panic!("Expected to find matches for {matcher:?}, less than or equal to {x} times but actually matched {count} times") + } + } } } }