diff options
Diffstat (limited to 'libmisc')
-rw-r--r-- | libmisc/tests/test_rand.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/libmisc/tests/test_rand.c b/libmisc/tests/test_rand.c index 295ea61..282c6a4 100644 --- a/libmisc/tests/test_rand.c +++ b/libmisc/tests/test_rand.c @@ -48,14 +48,14 @@ static void test_n(uint64_t cnt) { bool seen[MAX_SEE_ALL] = {0}; for (int i = 0; i < ROUNDS; i++) { uint64_t val = rand_uint63n(cnt); - sum += ((double)val)/(cnt-1); + sum += val; test_assert(val < cnt); if (cnt < MAX_SEE_ALL) seen[val] = true; } if (cnt > 1) { - test_assert(sum/ROUNDS > 0.45); - test_assert(sum/ROUNDS < 0.55); + test_assert(sum/ROUNDS > 0.45*(cnt-1)); + test_assert(sum/ROUNDS < 0.55*(cnt-1)); } if (cnt < MAX_SEE_ALL) { for (uint64_t i = 0; i < cnt; i++) |