Struct fuzzcheck::builder::FuzzerBuilder1
source · [−]pub struct FuzzerBuilder1<T, F> where
T: ?Sized,
F: Fn(&T) -> bool + 'static, { /* private fields */ }
Expand description
A fuzz-test builder that knows the function to fuzz-test. It is created by calling fuzz_test(..)
.
Use self.mutator(..)
to specify the mutator
and obtain a FuzzerBuilder2
. If the function argument’s type implements DefaultMutator
,
you can also use self.default_mutator()
.
Alternatively, use self.default_options()
to use the default mutator, serializer, sensor, pool, and arguments, and obtain a FuzzerBuilder5
.
This method is only available if the argument of the test function implements DefaultMutator
and is serializable with serde.
Implementations
sourceimpl<T, F> FuzzerBuilder1<T, F> where
T: ?Sized + ToOwned + 'static,
T::Owned: Clone + Serialize + for<'e> Deserialize<'e> + DefaultMutator,
<T::Owned as DefaultMutator>::Mutator: 'static,
F: Fn(&T) -> bool,
F: FuzzTestFunction<T::Owned, T, ReturnBool>,
impl<T, F> FuzzerBuilder1<T, F> where
T: ?Sized + ToOwned + 'static,
T::Owned: Clone + Serialize + for<'e> Deserialize<'e> + DefaultMutator,
<T::Owned as DefaultMutator>::Mutator: 'static,
F: Fn(&T) -> bool,
F: FuzzTestFunction<T::Owned, T, ReturnBool>,
sourcepub fn default_options(
self
) -> FuzzerBuilder5<F::NormalizedFunction, <T::Owned as DefaultMutator>::Mutator, T::Owned, DiverseAndMaxHitsSensor, BasicAndDiverseAndMaxHitsPool>
Available on crate feature serde_json_serializer
only.
pub fn default_options(
self
) -> FuzzerBuilder5<F::NormalizedFunction, <T::Owned as DefaultMutator>::Mutator, T::Owned, DiverseAndMaxHitsSensor, BasicAndDiverseAndMaxHitsPool>
serde_json_serializer
only.Use the default mutator, serializer, sensor, pool, and arguments.
sourceimpl<T, F> FuzzerBuilder1<T, F> where
T: ?Sized + ToOwned + 'static,
T::Owned: Clone + DefaultMutator,
<T::Owned as DefaultMutator>::Mutator: 'static,
F: Fn(&T) -> bool,
F: FuzzTestFunction<T::Owned, T, ReturnBool>,
impl<T, F> FuzzerBuilder1<T, F> where
T: ?Sized + ToOwned + 'static,
T::Owned: Clone + DefaultMutator,
<T::Owned as DefaultMutator>::Mutator: 'static,
F: Fn(&T) -> bool,
F: FuzzTestFunction<T::Owned, T, ReturnBool>,
sourcepub fn default_mutator(
self
) -> FuzzerBuilder2<F::NormalizedFunction, <T::Owned as DefaultMutator>::Mutator, T::Owned>
pub fn default_mutator(
self
) -> FuzzerBuilder2<F::NormalizedFunction, <T::Owned as DefaultMutator>::Mutator, T::Owned>
Use the DefaultMutator
trait to specify the mutator that produces input values for the tested function.
sourceimpl<T, F> FuzzerBuilder1<T, F> where
T: ?Sized,
F: Fn(&T) -> bool,
impl<T, F> FuzzerBuilder1<T, F> where
T: ?Sized,
F: Fn(&T) -> bool,
sourcepub fn mutator<M, V>(
self,
mutator: M
) -> FuzzerBuilder2<F::NormalizedFunction, M, V> where
V: Clone + Borrow<T>,
F: FuzzTestFunction<V, T, ReturnBool>,
M: Mutator<V>,
pub fn mutator<M, V>(
self,
mutator: M
) -> FuzzerBuilder2<F::NormalizedFunction, M, V> where
V: Clone + Borrow<T>,
F: FuzzTestFunction<V, T, ReturnBool>,
M: Mutator<V>,
Specify the mutator that produces input values for the tested function.
For example, if the test function is:
fn foo(xs: &[u8]) {
// ..
}
Then the given mutator should produces values that can be borrowed as [u8]
.
We can write:
use fuzzcheck::DefaultMutator;
use fuzzcheck::mutators::vector::VecMutator;
fn foo(xs: &[u8]) {
// ..
}
fn fuzz_test() {
fuzzcheck::fuzz_test(foo)
.mutator(VecMutator::new(u8::default_mutator(), 2 ..= 10, true))
// ..
}
Alternatively, if you would like to use the argument type’s default mutator, you can use
.default_mutator()
, as follows:
use fuzzcheck::DefaultMutator;
fn foo(xs: &[u8]) {
// ..
}
fn fuzz_test() {
fuzzcheck::fuzz_test(foo)
.default_mutator()
// ..
}
Auto Trait Implementations
impl<T: ?Sized, F> RefUnwindSafe for FuzzerBuilder1<T, F> where
F: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, F> !Send for FuzzerBuilder1<T, F>
impl<T, F> !Sync for FuzzerBuilder1<T, F>
impl<T: ?Sized, F> Unpin for FuzzerBuilder1<T, F> where
F: Unpin,
impl<T: ?Sized, F> UnwindSafe for FuzzerBuilder1<T, F> where
F: UnwindSafe,
T: RefUnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more