aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSimon Warta <[email protected]>2017-01-02 20:54:54 +0100
committerSimon Warta <[email protected]>2017-01-02 20:57:19 +0100
commitcc760f3a67cc136a30f707e19f1e9d2f01297959 (patch)
tree6da7f75b2695abd1e779ffe99fae4f38282ded81 /src
parent8387b027dcee25002842f83903b1f5190eaecd58 (diff)
Fix math in test_random_integer()
Removes complicated extra variable "dev", which was calculated incorrectly: if ratio = 0.0 then dev = 0.0, resulting in a test success.
Diffstat (limited to 'src')
-rw-r--r--src/tests/test_bigint.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/tests/test_bigint.cpp b/src/tests/test_bigint.cpp
index 802e22ff8..f07c82330 100644
--- a/src/tests/test_bigint.cpp
+++ b/src/tests/test_bigint.cpp
@@ -165,17 +165,15 @@ class BigInt_Unit_Tests : public Test
for(size_t i = 0; i != counts.size(); ++i)
{
double ratio = static_cast<double>(counts[i]) / ITERATIONS_PER_POSSIBLE_VALUE;
- double dev = std::min(ratio, std::fabs(1.0 - ratio));
- if(dev < .15)
+ if(ratio >= 0.85 && ratio <= 1.15) // +/-15 %
{
result.test_success("distribution within expected range");
}
else
{
- result.test_failure("distribution " + std::to_string(dev) +
- " outside expected range with count" +
- std::to_string(counts[i]));
+ result.test_failure("distribution ratio outside expected range (+/-15 %): " +
+ std::to_string(ratio));
}
}
}