pub enum Expect {
AtLeast(u64),
Eq(u64),
Gt(u64),
Lt(u64),
}Expand description
An expectation over a match count, classifying it into a Verdict.
The numeric forms reuse the suite’s [+|-]N threshold grammar (the same
+ larger-than / - smaller-than / bare at-least convention as
ct-search --size), extended with an exact form and two keywords so the
common search-as-test assertions read plainly:
| Spec | Passes when the count is | Meaning |
|---|---|---|
any | >= 1 | found something (the default) |
none | == 0 | a negative assertion |
N | >= N | at least N |
=N | == N | exactly N |
+N | > N | more than N |
-N | < N | fewer than N |
any is the default so a plain search gains framing without changing its
pass condition: Expect::default().eval(count) is Success exactly when the
search matched, reproducing ct-search’s historic 0/1 exit semantics.
§Examples
use coding_tools::verdict::{Expect, Verdict};
// `none` is a negative assertion: passes only when nothing matched.
assert_eq!(Expect::parse("none").unwrap().eval(0), Verdict::Success);
assert_eq!(Expect::parse("none").unwrap().eval(2), Verdict::Error);
// The default `any` passes on one or more.
assert_eq!(Expect::default().eval(0), Verdict::Error);
assert_eq!(Expect::default().eval(3), Verdict::Success);
// Thresholds: bare N is ">= N", =N exact, +N more-than, -N fewer-than.
assert_eq!(Expect::parse("3").unwrap().eval(3), Verdict::Success);
assert_eq!(Expect::parse("=2").unwrap().eval(3), Verdict::Error);
assert_eq!(Expect::parse("+0").unwrap().eval(1), Verdict::Success);
assert_eq!(Expect::parse("-10").unwrap().eval(9), Verdict::Success);Variants§
AtLeast(u64)
>= N — the bare-N and any (>= 1) forms.
Eq(u64)
== N — the =N and none (== 0) forms.
Gt(u64)
> N — the +N form.
Lt(u64)
< N — the -N form.
Implementations§
Trait Implementations§
impl Copy for Expect
impl Eq for Expect
impl StructuralPartialEq for Expect
Auto Trait Implementations§
impl Freeze for Expect
impl RefUnwindSafe for Expect
impl Send for Expect
impl Sync for Expect
impl Unpin for Expect
impl UnsafeUnpin for Expect
impl UnwindSafe for Expect
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more