Skip to content

Commit

Permalink
Merge pull request #195 from artichoke/lopopolo/default-is-new-unseeded
Browse files Browse the repository at this point in the history
Add tests for Default impl on RNGs
  • Loading branch information
lopopolo authored May 31, 2023
2 parents 1cbad11 + fa9fcb6 commit 8e695f7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ target/
!*.yaml
!*.yml

mutants.out*/
**/vendor/*
!**/vendor/*.md
11 changes: 11 additions & 0 deletions src/mt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -683,4 +683,15 @@ mod tests {
assert!(!buf.contains("123456"));
assert_eq!(buf, "Mt19937GenRand32 {}");
}

#[test]
fn default_is_new_unseeded() {
let mut default = Mt19937GenRand32::default();
let mut unseeded = Mt19937GenRand32::new_unseeded();

assert_eq!(default, unseeded);
for _ in 0..1024 {
assert_eq!(default.next_u32(), unseeded.next_u32());
}
}
}
11 changes: 11 additions & 0 deletions src/mt64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -664,4 +664,15 @@ mod tests {
assert!(!buf.contains("123456"));
assert_eq!(buf, "Mt19937GenRand64 {}");
}

#[test]
fn default_is_new_unseeded() {
let mut default = Mt19937GenRand64::default();
let mut unseeded = Mt19937GenRand64::new_unseeded();

assert_eq!(default, unseeded);
for _ in 0..1024 {
assert_eq!(default.next_u64(), unseeded.next_u64());
}
}
}

0 comments on commit 8e695f7

Please sign in to comment.