Skip to content

Commit

Permalink
Add tests for f32 random number generator used in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
robertknight committed Sep 15, 2024
1 parent 9d5ed57 commit ca6b364
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions rten-tensor/src/rng.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,27 @@ impl_random_source!(u32);
mod tests {
use super::XorShiftRng;

#[test]
fn test_f32() {
let mut rng = XorShiftRng::new(1234);
let x: Vec<f32> = rng.iter().take(10).collect();
assert_eq!(
x,
&[
7.2381226e-8,
0.12971127,
0.44675463,
6.69676e-5,
0.44387037,
0.24518594,
0.84056354,
0.9960614,
0.32433507,
0.9239961
]
);
}

#[test]
fn test_i8() {
let mut rng = XorShiftRng::new(1234);
Expand Down

0 comments on commit ca6b364

Please sign in to comment.