proptest-rs / proptest

Hypothesis-like property testing for Rust
Apache License 2.0
1.63k stars 152 forks source link

Detect empty ranges during tree creation #462

Closed mirandaconrado closed 2 weeks ago

mirandaconrado commented 2 weeks ago

Currently, if an empty range is used as base for a strategy, the generation will fail during the call to the rand crate as it cannot sample from an empty range. This PR creates a panic during the tree construction (the soonest we can) with a descriptive message, facilitating tracking the source of the issue.

Solves https://github.com/proptest-rs/proptest/issues/449

The panic message test pattern follows Rust's core library https://github.com/rust-lang/rust/blob/a1bad57fa59a8069a6ebb05cd6a2ae73c88b2e98/src/test/run-pass/panic-uninitialized-zeroed.rs