Trait sample_test::tester::Testable
source · pub trait Testable<S>: 'staticwhere
S: Sample,{
// Required method
fn result(&self, v: S::Output) -> TestResult;
// Provided methods
fn test_once(&self, s: &S, rng: &mut Random) -> TestResult
where S::Output: Clone + Debug { ... }
fn shrink(&self, s: &S, r: TestResult, v: S::Output) -> TestResult
where S::Output: Clone + Debug { ... }
}
Expand description
Testable
describes types (e.g., a function) whose values can be
tested.
Anything that can be tested must be capable of producing a TestResult from the output of an instance of Sample.
It’s unlikely that you’ll have to implement this trait yourself.
Required Methods§
sourcefn result(&self, v: S::Output) -> TestResult
fn result(&self, v: S::Output) -> TestResult
Report a TestResult
from a given value.
Provided Methods§
sourcefn test_once(&self, s: &S, rng: &mut Random) -> TestResultwhere
S::Output: Clone + Debug,
fn test_once(&self, s: &S, rng: &mut Random) -> TestResultwhere S::Output: Clone + Debug,
Convenience function for running this Testable
once on a random
value, and shrinking any failures.
sourcefn shrink(&self, s: &S, r: TestResult, v: S::Output) -> TestResultwhere
S::Output: Clone + Debug,
fn shrink(&self, s: &S, r: TestResult, v: S::Output) -> TestResultwhere S::Output: Clone + Debug,
Iteratively shrink the given test result until the iteration limit is reached or no further shrinkage is possible.