Skip to main content

arbitrary

Function arbitrary 

Source
pub fn arbitrary<T>() -> ArbitraryStrategy<T>
where T: Arbitrary,
Expand description

Bridges a quickcheck::Arbitrary type into the seam as a Strategy<T>.

Use it anywhere a strategy is expected:

use test_better_core::TestResult;
use test_better_matchers::{check, lt};
use test_better_property::{arbitrary, for_all};

// A `u8` is `quickcheck::Arbitrary`; doubling one in `u16` never overflows.
for_all(arbitrary::<u8>(), |n: u8| {
    check!(u16::from(n) * 2).satisfies(lt(512u16))
})
.map_err(|f| f.failure)?;