[tor-commits] [tor/master] Add test for crypto_fast_rng_get_double().

dgoulet at torproject.org dgoulet at torproject.org
Thu Feb 14 16:48:45 UTC 2019


commit 3f28b98220a49730b8c58c45e42598ad2bada47b
Author: Nick Mathewson <nickm at torproject.org>
Date:   Thu Feb 7 08:18:08 2019 -0500

    Add test for crypto_fast_rng_get_double().
---
 src/test/test_crypto_rng.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/test/test_crypto_rng.c b/src/test/test_crypto_rng.c
index 0513d2a80..075c876b8 100644
--- a/src/test/test_crypto_rng.c
+++ b/src/test/test_crypto_rng.c
@@ -207,6 +207,10 @@ test_crypto_rng_fast(void *arg)
     uint64_t u64 = crypto_fast_rng_get_uint64(rng, UINT64_C(1)<<40);
     tt_u64_op(u64, OP_GE, 0);
     tt_u64_op(u64, OP_LT, UINT64_C(1)<<40);
+
+    double d = crypto_fast_rng_get_double(rng);
+    tt_assert(d >= 0.0);
+    tt_assert(d < 1.0);
   }
 
   /* All values should have come up once. */





More information about the tor-commits mailing list