-
Notifications
You must be signed in to change notification settings - Fork 867
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
Update rand requirement from 0.8 to 0.9 #7045
Changes from 1 commit
44173b8
01f041f
53c1f5f
a292c78
442558d
c5e271f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -371,7 +371,10 @@ impl ExactSizeIterator for BitChunkIterator<'_> { | |
|
||
#[cfg(test)] | ||
mod tests { | ||
use rand::distr::uniform::UniformSampler; | ||
use rand::distr::uniform::UniformUsize; | ||
use rand::prelude::*; | ||
use rand::rng; | ||
|
||
use crate::buffer::Buffer; | ||
use crate::util::bit_chunk_iterator::UnalignedBitChunk; | ||
|
@@ -624,21 +627,25 @@ mod tests { | |
#[test] | ||
#[cfg_attr(miri, ignore)] | ||
fn fuzz_unaligned_bit_chunk_iterator() { | ||
let mut rng = thread_rng(); | ||
let mut rng = rng(); | ||
|
||
let usize = UniformUsize::new(usize::MIN, usize::MAX).unwrap(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I found this name confusing -- using There are a few other similar refactors below There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
for _ in 0..100 { | ||
let mask_len = rng.gen_range(0..1024); | ||
let bools: Vec<_> = std::iter::from_fn(|| Some(rng.gen())) | ||
let mask_len = rng.random_range(0..1024); | ||
let bools: Vec<_> = std::iter::from_fn(|| Some(rng.random())) | ||
.take(mask_len) | ||
.collect(); | ||
|
||
let buffer = Buffer::from_iter(bools.iter().cloned()); | ||
|
||
let max_offset = 64.min(mask_len); | ||
let offset = rng.gen::<usize>().checked_rem(max_offset).unwrap_or(0); | ||
let offset = usize.sample(&mut rng).checked_rem(max_offset).unwrap_or(0); | ||
|
||
let max_truncate = 128.min(mask_len - offset); | ||
let truncate = rng.gen::<usize>().checked_rem(max_truncate).unwrap_or(0); | ||
let truncate = usize | ||
.sample(&mut rng) | ||
.checked_rem(max_truncate) | ||
.unwrap_or(0); | ||
|
||
let unaligned = | ||
UnalignedBitChunk::new(buffer.as_slice(), offset, mask_len - offset - truncate); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this rename from
gen
torandom
-- I think it is much clearer now