TestTarget

Struct TestTarget 

Source
pub struct TestTarget<Generator, Engine, InputOwnership> { /* private fields */ }
Expand description

Configuration for a test target

Implementations§

Source§

impl<Engine> TestTarget<ByteSliceGenerator, Engine, BorrowedInput>

Source

pub fn new( engine: Engine, ) -> TestTarget<ByteSliceGenerator, Engine, BorrowedInput>

Create a TestTarget with the given Engine

Source§

impl<G, Engine, InputOwnership> TestTarget<G, Engine, InputOwnership>

Source

pub fn with_generator<Generator: ValueGenerator>( self, generator: Generator, ) -> TestTarget<Generator, Engine, InputOwnership>
where Generator::Output: Debug,

Set the value generator for the TestTarget

The function with_generator::<Generator>(generator) will use the provided Generator, which implements generator::ValueGenerator, to generate input values of type Generator::Output.

This mode is used for testing an implementation that requires structured input with specific constraints applied to the type.

Source

pub fn with_type<T: Debug + TypeGenerator>( self, ) -> TestTarget<TypeValueGenerator<T>, Engine, InputOwnership>

Set the type generator for the TestTarget

Calling with_type::<Type>() will generate random values of Type to be tested. Type is required to implement generator::TypeGenerator in order to use this method.

This mode is used for testing an implementation that requires structured input.

Source

pub fn with_shrink_time(self, shrink_time: Duration) -> Self

Set the amount of time that will be spent shrinking an input on failure

Engines can optionally shrink inputs on failures to make it easier to debug and identify the failure. Increasing this time can potentially lead to smaller values.

Source

pub fn exhaustive(self) -> Self

Exhaustively iterates over all of the possible inputs

Note that if the search space is large this can take a long time.

Source§

impl<G: ValueGenerator, Engine, InputOwnership> TestTarget<G, Engine, InputOwnership>

Source

pub fn map<F: Fn(G::Output) -> T, T: Debug>( self, map: F, ) -> TestTarget<MapGenerator<G, F>, Engine, InputOwnership>

Map the value of the generator

Source

pub fn and_then<F: Fn(G::Output) -> T, T: ValueGenerator>( self, map: F, ) -> TestTarget<AndThenGenerator<G, F>, Engine, InputOwnership>
where T::Output: Debug,

Map the value of the generator with a new generator

Source

pub fn filter<F: Fn(&G::Output) -> bool>( self, filter: F, ) -> TestTarget<FilterGenerator<G, F>, Engine, InputOwnership>

Filter the value of the generator

Source

pub fn filter_map<F: Fn(G::Output) -> Option<T>, T>( self, filter_map: F, ) -> TestTarget<FilterMapGenerator<G, F>, Engine, InputOwnership>

Filter the value of the generator and map it to something else

Source

pub fn with_driver_mode(self, mode: DriverMode) -> Self

👎Deprecated: Driver mode is no longer being used by generator implementations

Set the driver mode for the test target

Source

pub fn with_max_depth(self, max_depth: usize) -> Self

Set the maximum number of recursive types that can be generated.

The default value is 5.

Source§

impl<G, InputOwnership> TestTarget<G, TestEngine, InputOwnership>

Source

pub fn with_test_time(self, test_time: Duration) -> Self

Set the maximum runtime of the tests

Source

pub fn with_iterations(self, iterations: usize) -> Self

Set the number of iterations executed

Source

pub fn with_max_len(self, max_len: usize) -> Self

Set the maximum length of the generated bytes

Source§

impl<G, Engine> TestTarget<G, Engine, BorrowedInput>

Source

pub fn cloned(self) -> TestTarget<G, Engine, ClonedInput>

Use a cloned value for the test input

Cloning the test inputs will force a call to Clone::clone on each input value, and therefore, will be less efficient than using a reference.

Source§

impl<G, E> TestTarget<G, E, BorrowedInput>
where G: ValueGenerator,

Source

pub fn for_each<F>(self, test: F) -> E::Output

Iterate over all of the inputs and check the TestTarget

Source§

impl<G, E> TestTarget<G, E, ClonedInput>
where G: ValueGenerator,

Source

pub fn for_each<F>(self, test: F) -> E::Output

Iterate over all of the inputs and check the TestTarget

Source§

impl<E> TestTarget<ByteSliceGenerator, E, BorrowedInput>

Source

pub fn for_each<T>(self, test: T) -> E::Output

Iterate over all of the inputs and check the TestTarget

Source

pub fn run<T, R>(self, test: T) -> E::Output
where T: FnMut() -> R + RefUnwindSafe, R: IntoResult, E: ScopedEngine,

Iterate over all of the inputs and check the TestTarget

Source

pub fn run_with_replay<T, R>(self, test: T) -> E::Output
where T: FnMut(bool) -> R + RefUnwindSafe, R: IntoResult, E: ScopedEngine,

Source§

impl<E> TestTarget<ByteSliceGenerator, E, ClonedInput>

Source

pub fn for_each<T>(self, test: T) -> E::Output

Iterate over all of the inputs and check the TestTarget

Auto Trait Implementations§

§

impl<Generator, Engine, InputOwnership> Freeze for TestTarget<Generator, Engine, InputOwnership>
where Generator: Freeze, Engine: Freeze,

§

impl<Generator, Engine, InputOwnership> RefUnwindSafe for TestTarget<Generator, Engine, InputOwnership>
where Generator: RefUnwindSafe, Engine: RefUnwindSafe, InputOwnership: RefUnwindSafe,

§

impl<Generator, Engine, InputOwnership> Send for TestTarget<Generator, Engine, InputOwnership>
where Generator: Send, Engine: Send, InputOwnership: Send,

§

impl<Generator, Engine, InputOwnership> Sync for TestTarget<Generator, Engine, InputOwnership>
where Generator: Sync, Engine: Sync, InputOwnership: Sync,

§

impl<Generator, Engine, InputOwnership> Unpin for TestTarget<Generator, Engine, InputOwnership>
where Generator: Unpin, Engine: Unpin, InputOwnership: Unpin,

§

impl<Generator, Engine, InputOwnership> UnwindSafe for TestTarget<Generator, Engine, InputOwnership>
where Generator: UnwindSafe, Engine: UnwindSafe, InputOwnership: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V