diff options
author | peterbell10 <peterbell10@live.co.uk> | 2017-06-13 21:35:30 +0200 |
---|---|---|
committer | Lukas Pioch <lukas@zgow.de> | 2017-06-13 21:35:30 +0200 |
commit | 360d8eade0332f2c1aa5c205ca772cd506c35b26 (patch) | |
tree | 066fde557310742a39020bad9bc4aa2a5ef8d51a /tests/FastRandom/FastRandomTest.cpp | |
parent | Corrected check for level of subcommand and fixed multiple levels not working (#3758) (diff) | |
download | cuberite-360d8eade0332f2c1aa5c205ca772cd506c35b26.tar cuberite-360d8eade0332f2c1aa5c205ca772cd506c35b26.tar.gz cuberite-360d8eade0332f2c1aa5c205ca772cd506c35b26.tar.bz2 cuberite-360d8eade0332f2c1aa5c205ca772cd506c35b26.tar.lz cuberite-360d8eade0332f2c1aa5c205ca772cd506c35b26.tar.xz cuberite-360d8eade0332f2c1aa5c205ca772cd506c35b26.tar.zst cuberite-360d8eade0332f2c1aa5c205ca772cd506c35b26.zip |
Diffstat (limited to '')
-rw-r--r-- | tests/FastRandom/FastRandomTest.cpp | 14 |
1 files changed, 6 insertions, 8 deletions
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<int>(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; |