pub struct TestTarget<Generator, Engine, InputOwnership> { /* private fields */ }Expand description
Configuration for a test target
Implementations§
Source§impl<Engine> TestTarget<ByteSliceGenerator, Engine, BorrowedInput>
impl<Engine> TestTarget<ByteSliceGenerator, Engine, BorrowedInput>
Sourcepub fn new(
engine: Engine,
) -> TestTarget<ByteSliceGenerator, Engine, BorrowedInput>
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>
impl<G, Engine, InputOwnership> TestTarget<G, Engine, InputOwnership>
Sourcepub fn with_generator<Generator: ValueGenerator>(
self,
generator: Generator,
) -> TestTarget<Generator, Engine, InputOwnership>
pub fn with_generator<Generator: ValueGenerator>( self, generator: Generator, ) -> TestTarget<Generator, Engine, InputOwnership>
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.
Sourcepub fn with_type<T: Debug + TypeGenerator>(
self,
) -> TestTarget<TypeValueGenerator<T>, Engine, InputOwnership>
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.
Sourcepub fn with_shrink_time(self, shrink_time: Duration) -> Self
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.
Sourcepub fn exhaustive(self) -> Self
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>
impl<G: ValueGenerator, Engine, InputOwnership> TestTarget<G, Engine, InputOwnership>
Sourcepub fn map<F: Fn(G::Output) -> T, T: Debug>(
self,
map: F,
) -> TestTarget<MapGenerator<G, F>, Engine, InputOwnership>
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
Sourcepub fn and_then<F: Fn(G::Output) -> T, T: ValueGenerator>(
self,
map: F,
) -> TestTarget<AndThenGenerator<G, F>, Engine, InputOwnership>
pub fn and_then<F: Fn(G::Output) -> T, T: ValueGenerator>( self, map: F, ) -> TestTarget<AndThenGenerator<G, F>, Engine, InputOwnership>
Map the value of the generator with a new generator
Sourcepub fn filter<F: Fn(&G::Output) -> bool>(
self,
filter: F,
) -> TestTarget<FilterGenerator<G, F>, Engine, InputOwnership>
pub fn filter<F: Fn(&G::Output) -> bool>( self, filter: F, ) -> TestTarget<FilterGenerator<G, F>, Engine, InputOwnership>
Filter the value of the generator
Sourcepub fn filter_map<F: Fn(G::Output) -> Option<T>, T>(
self,
filter_map: F,
) -> TestTarget<FilterMapGenerator<G, F>, Engine, InputOwnership>
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
Sourcepub fn with_driver_mode(self, mode: DriverMode) -> Self
👎Deprecated: Driver mode is no longer being used by generator implementations
pub fn with_driver_mode(self, mode: DriverMode) -> Self
Set the driver mode for the test target
Sourcepub fn with_max_depth(self, max_depth: usize) -> Self
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>
impl<G, InputOwnership> TestTarget<G, TestEngine, InputOwnership>
Sourcepub fn with_test_time(self, test_time: Duration) -> Self
pub fn with_test_time(self, test_time: Duration) -> Self
Set the maximum runtime of the tests
Sourcepub fn with_iterations(self, iterations: usize) -> Self
pub fn with_iterations(self, iterations: usize) -> Self
Set the number of iterations executed
Sourcepub fn with_max_len(self, max_len: usize) -> Self
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>
impl<G, Engine> TestTarget<G, Engine, BorrowedInput>
Sourcepub fn cloned(self) -> TestTarget<G, Engine, ClonedInput>
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,
impl<G, E> TestTarget<G, E, BorrowedInput>where
G: ValueGenerator,
Sourcepub fn for_each<F>(self, test: F) -> E::Outputwhere
E: Engine<BorrowedGeneratorTest<F, G, G::Output>>,
BorrowedGeneratorTest<F, G, G::Output>: Test,
pub fn for_each<F>(self, test: F) -> E::Outputwhere
E: Engine<BorrowedGeneratorTest<F, G, G::Output>>,
BorrowedGeneratorTest<F, G, G::Output>: Test,
Iterate over all of the inputs and check the TestTarget
Source§impl<G, E> TestTarget<G, E, ClonedInput>where
G: ValueGenerator,
impl<G, E> TestTarget<G, E, ClonedInput>where
G: ValueGenerator,
Source§impl<E> TestTarget<ByteSliceGenerator, E, BorrowedInput>
impl<E> TestTarget<ByteSliceGenerator, E, BorrowedInput>
Source§impl<E> TestTarget<ByteSliceGenerator, E, ClonedInput>
impl<E> TestTarget<ByteSliceGenerator, E, ClonedInput>
Auto Trait Implementations§
impl<Generator, Engine, InputOwnership> Freeze for TestTarget<Generator, Engine, InputOwnership>
impl<Generator, Engine, InputOwnership> RefUnwindSafe for TestTarget<Generator, Engine, InputOwnership>
impl<Generator, Engine, InputOwnership> Send for TestTarget<Generator, Engine, InputOwnership>
impl<Generator, Engine, InputOwnership> Sync for TestTarget<Generator, Engine, InputOwnership>
impl<Generator, Engine, InputOwnership> Unpin for TestTarget<Generator, Engine, InputOwnership>
impl<Generator, Engine, InputOwnership> UnwindSafe for TestTarget<Generator, Engine, InputOwnership>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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