[][src]Struct proptest::test_runner::TestRng

pub struct TestRng { /* fields omitted */ }

Proptest's random number generator.

Methods

impl TestRng
[src]

Create a new RNG with the given algorithm and seed.

Any RNG created with the same algorithm-seed pair will produce the same sequence of values on all systems and all supporting versions of proptest.

Panics

Panics if seed is not an appropriate length for algorithm.

Returns a TestRng with a particular hard-coded seed.

The seed value will always be the same for a particular version of Proptest and algorithm, but may change across releases.

This is useful for testing things like strategy implementations without risking getting "unlucky" RNGs which deviate from average behaviour enough to cause spurious failures. For example, a strategy for bool which is supposed to produce true 50% of the time might have a test which checks that the distribution is "close enough" to 50%. If every test run starts with a different RNG, occasionally there will be spurious test failures when the RNG happens to produce a very skewed distribution. Using this or TestRunner::deterministic() avoids such issues.

Trait Implementations

impl Debug for TestRng
[src]

impl Clone for TestRng
[src]

Performs copy-assignment from source. Read more

impl RngCore for TestRng
[src]

Auto Trait Implementations

impl Send for TestRng

impl Sync for TestRng

Blanket Implementations

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> From for T
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

impl<R> Rng for R where
    R: RngCore + ?Sized
[src]

Return a random value supporting the [Standard] distribution. Read more

Generate a random value in the range [low, high), i.e. inclusive of low and exclusive of high. Read more

Sample a new value, using the given distribution. Read more

Create an iterator that generates values using the given distribution. Read more

Fill dest entirely with random bytes (uniform value distribution), where dest is any type supporting [AsByteSliceMut], namely slices and arrays over primitive integer types (i8, i16, u32, etc.). Read more

Fill dest entirely with random bytes (uniform value distribution), where dest is any type supporting [AsByteSliceMut], namely slices and arrays over primitive integer types (i8, i16, u32, etc.). Read more

Return a bool with a probability p of being true. Read more

Return a random element from values. Read more

Return a mutable pointer to a random element from values. Read more

Shuffle a mutable slice in place. Read more

Deprecated since 0.5.0

: use Rng::sample_iter(&Standard) instead

Return an iterator that will yield an infinite number of randomly generated items. Read more

Deprecated since 0.5.0

: use gen_bool instead

Return a bool with a 1 in n chance of true Read more

Deprecated since 0.5.0

: use sample_iter(&Alphanumeric) instead

Return an iterator of random characters from the set A-Z,a-z,0-9. Read more

impl<R> Rng for R where
    R: RngCore + ?Sized
[src]

Return a random value supporting the [Standard] distribution. Read more

Generate a random value in the range [low, high), i.e. inclusive of low and exclusive of high. Read more

Sample a new value, using the given distribution. Read more

Create an iterator that generates values using the given distribution. Read more

Fill dest entirely with random bytes (uniform value distribution), where dest is any type supporting [AsByteSliceMut], namely slices and arrays over primitive integer types (i8, i16, u32, etc.). Read more

Fill dest entirely with random bytes (uniform value distribution), where dest is any type supporting [AsByteSliceMut], namely slices and arrays over primitive integer types (i8, i16, u32, etc.). Read more

Return a bool with a probability p of being true. Read more

Return a bool with a probability of numerator/denominator of being true. I.e. gen_ratio(2, 3) has chance of 2 in 3, or about 67%, of returning true. If numerator == denominator, then the returned value is guaranteed to be true. If numerator == 0, then the returned value is guaranteed to be false. Read more

Deprecated since 0.6.0

: use SliceRandom::choose instead

Return a random element from values. Read more

Deprecated since 0.6.0

: use SliceRandom::choose_mut instead

Return a mutable pointer to a random element from values. Read more

Deprecated since 0.6.0

: use SliceRandom::shuffle instead

Shuffle a mutable slice in place. Read more