pub trait Testable<S>: 'staticwhere
S: Sample,{
// Required method
fn result(&self, v: S::Output) -> TestResult;
// Provided methods
fn test_once(&self, s: &mut 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: &mut S, rng: &mut Random) -> TestResult
fn test_once(&self, s: &mut S, rng: &mut Random) -> TestResult
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) -> TestResult
fn shrink(&self, s: &S, r: TestResult, v: S::Output) -> TestResult
Iteratively shrink the given test result until the iteration limit is reached or no further shrinkage is possible.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".