Function zebra_test::prelude::prop::arbitrary::any_with
pub fn any_with<A>(
args: <A as Arbitrary>::Parameters,
) -> <A as Arbitrary>::Strategywhere
A: Arbitrary,
Expand description
Generates a Strategy
producing Arbitrary
values of A
with the
given configuration arguments passed in args
. Unlike arbitrary_with
,
it should be used for being explicit on what A
is.
For clarity, this may be a good idea.
Use this version instead of arbitrary_with
if you want to be clear which
type you want to generate a Strategy
for, or if you don’t have an anchoring
type for type inference to work with.
If you don’t want to specify any arguments and instead use the default
behavior, you should use any::<A>()
.
§Example
The function can be used as:
use proptest::prelude::*;
use proptest::collection::size_range;
proptest! {
fn reverse_reverse_is_identity
(ref vec in any_with::<Vec<u32>>(size_range(1000).lift()))
{
let vec2 = vec.iter().cloned().rev().rev().collect::<Vec<u32>>();
prop_assert_eq!(vec, &vec2);
}
}
fn main() {
reverse_reverse_is_identity();
}