Trait quickcheck::Testable
[−]
[src]
pub trait Testable: Send + 'static { fn result<G: Gen>(&self, &mut G) -> TestResult; }
Testable
describes types (e.g., a function) whose values can be
tested.
Anything that can be tested must be capable of producing a TestResult
given a random number generator. This is trivial for types like bool
,
which are just converted to either a passing or failing test result.
For functions, an implementation must generate random arguments and potentially shrink those arguments if they produce a failure.
It's unlikely that you'll have to implement this trait yourself.
This comes with a caveat: currently, only functions with 4 parameters
or fewer (both fn
and ||
types) satisfy Testable
. If you have
functions to test with more than 4 parameters, please
file a bug and
I'll hopefully add it. (As of now, it would be very difficult to
add your own implementation outside of quickcheck
, since the
functions that do shrinking are not public.)
Required Methods
fn result<G: Gen>(&self, &mut G) -> TestResult
Implementors
impl Testable for bool
impl Testable for ()
impl Testable for TestResult
impl<A, E> Testable for Result<A, E> where A: Testable, E: Debug + Send + 'static
impl<T> Testable for fn() -> T where T: Testable
impl<A, T> Testable for fn(A) -> T where A: AShow, T: Testable
impl<A, B, T> Testable for fn(A, B) -> T where A: AShow, B: AShow, T: Testable
impl<A, B, C, T> Testable for fn(A, B, C) -> T where A: AShow, B: AShow, C: AShow, T: Testable
impl<A, B, C, D, T> Testable for fn(A, B, C, D) -> T where A: AShow, B: AShow, C: AShow, D: AShow, T: Testable