#[derive(Debug)]
pub(crate) struct TestRng(u64);
impl TestRng {
pub(crate) fn new(seed: u64) -> Self {
Self(seed)
}
pub(crate) fn next_u64(&mut self) -> u64 {
self.0 = self.0.wrapping_add(0x9e37_79b9_7f4a_7c15);
let mut z = self.0;
z = (z ^ (z >> 30)).wrapping_mul(0xbf58_476d_1ce4_e5b9);
z = (z ^ (z >> 27)).wrapping_mul(0x94d0_49bb_1331_11eb);
z ^ (z >> 31)
}
pub(crate) fn below(&mut self, bound: u64) -> u64 {
self.next_u64() % bound
}
pub(crate) fn below_usize(&mut self, bound: usize) -> usize {
usize::try_from(self.below(bound as u64)).unwrap()
}
pub(crate) fn bytes(&mut self, len: usize) -> Vec<u8> {
(0..len).map(|_| self.next_u64().to_le_bytes()[0]).collect()
}
}