Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to reach minimum value of signed types #233

Closed
shaobo-he opened this issue Apr 18, 2019 · 0 comments
Closed

Unable to reach minimum value of signed types #233

shaobo-he opened this issue Apr 18, 2019 · 0 comments

Comments

@shaobo-he
Copy link

Hello,

It appears this test will always pass even setting QUICKCHECK_TESTS and QUICKCHECK_MAX_TESTS to a large value (e.g., 10000000) and QUICKCHECK_GENERATOR_SIZE to 300,

fn prop_gt(x: i8) -> bool {
    x != i8::min_value()
}

fn main() {
    quickcheck(prop_gt as fn(i8) -> bool);
    println!("Hello, world!");
}

It appears these lines of code attribute to this issue,
https://docs.rs/quickcheck/0.8.2/src/quickcheck/arbitrary.rs.html#756-771
If upper = min(g.size(), $ty::max_value() as usize), then if upper > $ty::max_value() always evaluates to the else branch.

BurntSushi pushed a commit that referenced this issue Dec 27, 2020
This commit tweaks the Arbitrary impls of number types (integers,
floats) to use the full range with a small bias toward "problem" values.
This is a change from prior behavior that would use the `size` parameter
to control the range of integers.

In retrospect, using the `size` parameter this way was probably
misguided. Instead, it should only be used to control the sizes of data
structures instead of also constraining numeric ranges. By constraining
numeric ranges, we leave out a huge space of values that are never
tested.

Fixes #27, Fixes #119, Fixes #190, Fixes #233, Closes #240
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant