Expand description
§Standard Rust test suite
While not always explicitly documented, it is generally expected that the implementation of
traits from Rust’s std
has certain properties that cannot be expressed in the type system
alone. For instance, most people assume that if a type T
implements both Clone
and Eq
then x == x.clone()
holds for all values x
of T
. Thus it’s often desirable for the impls
to have such properties. In some cases (such as Eq
) the properties are explicitly documented
as required.
In any case, the only way to enforce correctness is to test the impls but that can be tedious and repetitive. This crate aims to help with that. It provides a set of standard tests that can be invoked easily.
The recommended way is to implement Arbitrary
from crate arbitrary
for your types and then invoke standard_checks!(YourTypeHere)
macro to magically implement a
test for your type. You can then use the one_iteration
method within your fuzz loop.
The macro uses hacky “specialization” to run appropriate tests for your type based on which traits it implements.
Alternatively, if you for some reason cannot implement Arbitrary
but can generate values
differently, you can simply manually call approriate functions in the crate that provide the
checks. For instance you could use kani
to model-check that your implementation is correct.
Re-exports§
pub extern crate arbitrary;
Modules§
- clone_
eq - Checks combination of
Clone + Eq
. - clone_
iterator_ of_ eq - Checks that cloned iterator yields the same values.
- eq
- Checks reflexivity.
- eq_hash
- Checks that for equal values equal bytes are given to a hasher.
- exact_
size_ iterator - Checks that the length of
ExactSizeIterator
matchessize_hint
- fused_
iterator - Checks that the iterator continues returning
None
once it reached the end. - iterator
- Checks that
size_hint
behaves correctly. - partial_
eq - Checks commutativity and transitivity.
- partial_
eq_ into_ iterator_ partial_ eq - Checks combination of
IntoIterator + PartialEq
where the items implementPartialEq
.
Macros§
- standard_
checks - Automagically implements
StandardChecks
for your type given as paramter.
Traits§
- Standard
Checks - A trait implemented by types that have their traits auto-checked.