Skip to content

Commit 0c5a5f9

Browse files
committed
Simplify dummy RNG for BlockRng test
We no longer implement the non-block step RNG.
1 parent 0f0d66f commit 0c5a5f9

File tree

3 files changed

+9
-70
lines changed

3 files changed

+9
-70
lines changed

rand_core/src/block.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -439,11 +439,10 @@ impl<R: BlockRngCore + CryptoRng> CryptoRng for BlockRng<R> {}
439439
mod test {
440440
use crate::{SeedableRng, RngCore};
441441
use crate::block::{BlockRng, BlockRng64, BlockRngCore};
442-
use crate::mock::StepRng;
443442

444443
#[derive(Debug, Clone)]
445444
struct DummyRng {
446-
rng: StepRng,
445+
counter: u32,
447446
}
448447

449448
impl BlockRngCore for DummyRng {
@@ -453,16 +452,17 @@ mod test {
453452

454453
fn generate(&mut self, results: &mut Self::Results) {
455454
for r in results {
456-
*r = self.rng.next_u32();
455+
*r = self.counter;
456+
self.counter += 1;
457457
}
458458
}
459459
}
460460

461461
impl SeedableRng for DummyRng {
462-
type Seed = [u8; 8];
462+
type Seed = [u8; 4];
463463

464464
fn from_seed(seed: Self::Seed) -> Self {
465-
DummyRng { rng: StepRng::new(u64::from_le_bytes(seed), 1) }
465+
DummyRng { counter: u32::from_le_bytes(seed) }
466466
}
467467
}
468468

@@ -492,7 +492,7 @@ mod test {
492492

493493
#[derive(Debug, Clone)]
494494
struct DummyRng64 {
495-
rng: StepRng,
495+
counter: u64,
496496
}
497497

498498
impl BlockRngCore for DummyRng64 {
@@ -502,7 +502,8 @@ mod test {
502502

503503
fn generate(&mut self, results: &mut Self::Results) {
504504
for r in results {
505-
*r = self.rng.next_u64();
505+
*r = self.counter;
506+
self.counter += 1;
506507
}
507508
}
508509
}
@@ -511,7 +512,7 @@ mod test {
511512
type Seed = [u8; 8];
512513

513514
fn from_seed(seed: Self::Seed) -> Self {
514-
DummyRng64 { rng: StepRng::new(u64::from_le_bytes(seed), 1) }
515+
DummyRng64 { counter: u64::from_le_bytes(seed) }
515516
}
516517
}
517518

rand_core/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ mod error;
5454
pub mod impls;
5555
pub mod le;
5656
#[cfg(feature = "getrandom")] mod os;
57-
#[cfg(test)] mod mock;
5857

5958

6059
/// The core of a random number generator.

rand_core/src/mock.rs

Lines changed: 0 additions & 61 deletions
This file was deleted.

0 commit comments

Comments
 (0)