From 360d8eade0332f2c1aa5c205ca772cd506c35b26 Mon Sep 17 00:00:00 2001 From: peterbell10 Date: Tue, 13 Jun 2017 20:35:30 +0100 Subject: FastRandom rewrite (#3754) --- tests/FastRandom/FastRandomTest.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/FastRandom/FastRandomTest.cpp b/tests/FastRandom/FastRandomTest.cpp index 9ab775936..2bfa7ced6 100644 --- a/tests/FastRandom/FastRandomTest.cpp +++ b/tests/FastRandom/FastRandomTest.cpp @@ -15,14 +15,13 @@ static void TestInts(void) cFastRandom rnd; int sum = 0; const int BUCKETS = 8; - int Counts[BUCKETS]; - memset(Counts, 0, sizeof(Counts)); + int Counts[BUCKETS] = {0}; const int ITER = 10000; for (int i = 0; i < ITER; i++) { - int v = rnd.NextInt(1000); + int v = rnd.RandInt(1000); assert_test(v >= 0); - assert_test(v < 1000); + assert_test(v <= 1000); Counts[v % BUCKETS]++; sum += v; } @@ -43,12 +42,11 @@ static void TestFloats(void) cFastRandom rnd; float sum = 0; const int BUCKETS = 8; - int Counts[BUCKETS]; - memset(Counts, 0, sizeof(Counts)); + int Counts[BUCKETS] = {0}; const int ITER = 10000; for (int i = 0; i < ITER; i++) { - float v = rnd.NextFloat(1000); + float v = rnd.RandReal(1000.0f); assert_test(v >= 0); assert_test(v <= 1000); Counts[static_cast(v) % BUCKETS]++; @@ -76,7 +74,7 @@ static void TestReCreation(void) for (int i = 0; i < ITER; ++i) { cFastRandom rnd; - int val = rnd.NextInt(10); + int val = rnd.RandInt(9); if (val == lastVal) { numSame += 1; -- cgit v1.2.3