add comment explaining arbitrary gen for uint

This commit is contained in:
Maximilian Krüger 2018-02-16 09:59:00 +01:00
parent c3624193af
commit 37aabc3b6b
1 changed files with 5 additions and 0 deletions

View File

@ -1372,11 +1372,16 @@ macro_rules! impl_quickcheck_arbitrary_for_uint {
let mut res = [0u8; $n_bytes];
let p = g.next_f64();
// make it more likely to generate smaller numbers that
// don't use up the full $n_bytes
let range =
// 10% chance to generate number that uses up to $n_bytes
if p < 0.1 {
$n_bytes
// 20% chance to generate number that uses up to $n_bytes / 2
} else if p < 0.2 {
$n_bytes / 2
// 70% chance to generate number that uses up to $n_bytes / 5
} else {
$n_bytes / 5
};