Skip to content

Commit

Permalink
Seed from u64
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdplm committed Dec 30, 2020
1 parent 53cf7e9 commit a29d15c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
1 change: 1 addition & 0 deletions fixed-hash/Cargo.toml
Expand Up @@ -24,6 +24,7 @@ arbitrary = { version = "0.4", optional = true }
[dev-dependencies]
rand_xorshift = "0.2.0"
criterion = "0.3.0"
rand = { version = "0.8.0", default-features = false, features = ["std_rng"] }

[features]
default = ["std", "rand", "rustc-hex", "byteorder"]
Expand Down
19 changes: 2 additions & 17 deletions fixed-hash/src/tests.rs
Expand Up @@ -244,23 +244,8 @@ mod rand {

#[test]
fn random() {
let default_seed = <StdRng as SeedableRng>::Seed::default();
let mut rng = StdRng::from_seed(default_seed);
assert_eq!(H32::random_using(&mut rng), H32::from([0x76, 0xa0, 0x40, 0x53]));
}

#[test]
fn randomize() {
let default_seed = <StdRng as SeedableRng>::Seed::default();
let mut rng = StdRng::from_seed(default_seed);
assert_eq!(
{
let mut ret = H32::zero();
ret.randomize_using(&mut rng);
ret
},
H32::from([0x76, 0xa0, 0x40, 0x53])
)
let mut rng = StdRng::seed_from_u64(123);
assert_eq!(H32::random_using(&mut rng), H32::from([0xeb, 0x96, 0xaf, 0x1c]));
}
}

Expand Down

0 comments on commit a29d15c

Please sign in to comment.