Skip to main content

Testable

Trait Testable 

Source
pub trait Testable<S>: 'static
where 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§

Source

fn result(&self, v: S::Output) -> TestResult

Report a TestResult from a given value.

Provided Methods§

Source

fn test_once(&self, s: &mut S, rng: &mut Random) -> TestResult
where S::Output: Clone + Debug,

Convenience function for running this Testable once on a random value, and shrinking any failures.

Source

fn shrink(&self, s: &S, r: TestResult, v: S::Output) -> TestResult
where S::Output: Clone + Debug,

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".

Implementations on Foreign Types§

Source§

impl<T: 'static, S, A, B, C, D, E, F, G, H> Testable<S> for fn(A, B, C, D, E, F, G, H) -> T
where TestResult: From<T>, S: Sample<Output = (A, B, C, D, E, F, G, H)>, (A, B, C, D, E, F, G, H): Clone, A: Debug + 'static, B: Debug + 'static, C: Debug + 'static, D: Debug + 'static, E: Debug + 'static, F: Debug + 'static, G: Debug + 'static, H: Debug + 'static,

Source§

fn result(&self, v: S::Output) -> TestResult

Source§

impl<T: 'static, S, A, B, C, D, E, F, G> Testable<S> for fn(A, B, C, D, E, F, G) -> T
where TestResult: From<T>, S: Sample<Output = (A, B, C, D, E, F, G)>, (A, B, C, D, E, F, G): Clone, A: Debug + 'static, B: Debug + 'static, C: Debug + 'static, D: Debug + 'static, E: Debug + 'static, F: Debug + 'static, G: Debug + 'static,

Source§

fn result(&self, v: S::Output) -> TestResult

Source§

impl<T: 'static, S, A, B, C, D, E, F> Testable<S> for fn(A, B, C, D, E, F) -> T
where TestResult: From<T>, S: Sample<Output = (A, B, C, D, E, F)>, (A, B, C, D, E, F): Clone, A: Debug + 'static, B: Debug + 'static, C: Debug + 'static, D: Debug + 'static, E: Debug + 'static, F: Debug + 'static,

Source§

fn result(&self, v: S::Output) -> TestResult

Source§

impl<T: 'static, S, A, B, C, D, E> Testable<S> for fn(A, B, C, D, E) -> T
where TestResult: From<T>, S: Sample<Output = (A, B, C, D, E)>, (A, B, C, D, E): Clone, A: Debug + 'static, B: Debug + 'static, C: Debug + 'static, D: Debug + 'static, E: Debug + 'static,

Source§

fn result(&self, v: S::Output) -> TestResult

Source§

impl<T: 'static, S, A, B, C, D> Testable<S> for fn(A, B, C, D) -> T
where TestResult: From<T>, S: Sample<Output = (A, B, C, D)>, (A, B, C, D): Clone, A: Debug + 'static, B: Debug + 'static, C: Debug + 'static, D: Debug + 'static,

Source§

fn result(&self, v: S::Output) -> TestResult

Source§

impl<T: 'static, S, A, B, C> Testable<S> for fn(A, B, C) -> T
where TestResult: From<T>, S: Sample<Output = (A, B, C)>, (A, B, C): Clone, A: Debug + 'static, B: Debug + 'static, C: Debug + 'static,

Source§

fn result(&self, v: S::Output) -> TestResult

Source§

impl<T: 'static, S, A, B> Testable<S> for fn(A, B) -> T
where TestResult: From<T>, S: Sample<Output = (A, B)>, (A, B): Clone, A: Debug + 'static, B: Debug + 'static,

Source§

fn result(&self, v: S::Output) -> TestResult

Source§

impl<T: 'static, S, A> Testable<S> for fn(A) -> T
where TestResult: From<T>, S: Sample<Output = (A,)>, (A,): Clone, A: Debug + 'static,

Source§

fn result(&self, v: S::Output) -> TestResult

Implementors§