From e0f3972dd6e965a9ef28c2a80838d5030ef48539 Mon Sep 17 00:00:00 2001 From: Diggory Hardy Date: Fri, 10 Nov 2017 17:34:55 +0000 Subject: [PATCH] Isaac64: add test for true 32-bit values Includes both the values output now and the values which should be output by #36. [Cherry-picked from fd2660b54272653] --- src/prng/isaac64.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/prng/isaac64.rs b/src/prng/isaac64.rs index 7df5882897a..7afffbae76f 100644 --- a/src/prng/isaac64.rs +++ b/src/prng/isaac64.rs @@ -374,6 +374,28 @@ mod test { 10391409374914919106)); } + #[test] + fn test_isaac64_true_values_32() { + let seed: &[_] = &[1, 23, 456, 7890, 12345]; + let mut rng1 = Isaac64Rng::from_seed(seed); + let v = (0..10).map(|_| rng1.next_u32()).collect::>(); + // Subset of above values, as an LE u32 sequence + // TODO: switch to this sequence? +// assert_eq!(v, +// [141028748, 127386717, +// 1058730652, 3347555894, +// 851491469, 4039984500, +// 2692730210, 288449107, +// 646103879, 2782923823]); + // Subset of above values, using only low-half of each u64 + assert_eq!(v, + [141028748, 1058730652, + 851491469, 2692730210, + 646103879, 4195642895, + 2836348583, 1312677241, + 999139615, 253604626]); + } + #[test] fn test_isaac64_true_bytes() { let seed: &[_] = &[1, 23, 456, 7890, 12345];