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§

source

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

Report a TestResult from a given value.

Provided Methods§

source

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.

source

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.

Implementations on Foreign Types§

source§

impl<T: 'static, S, A, B, C, D, E> Testable<S> for fn(_: A, _: B, _: C, _: D, _: E) -> Twhere 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, E, F, G, H> Testable<S> for fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H) -> Twhere 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> Testable<S> for fn(_: A, _: B) -> Twhere 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, B, C> Testable<S> for fn(_: A, _: B, _: C) -> Twhere 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, C, D> Testable<S> for fn(_: A, _: B, _: C, _: D) -> Twhere 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> Testable<S> for fn(_: A) -> Twhere TestResult: From<T>, S: Sample<Output = (A,)>, (A,): Clone, A: 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) -> Twhere 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) -> Twhere 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

Implementors§