diff options
author | Simon Warta <[email protected]> | 2017-01-02 20:54:54 +0100 |
---|---|---|
committer | Simon Warta <[email protected]> | 2017-01-02 20:57:19 +0100 |
commit | cc760f3a67cc136a30f707e19f1e9d2f01297959 (patch) | |
tree | 6da7f75b2695abd1e779ffe99fae4f38282ded81 /src | |
parent | 8387b027dcee25002842f83903b1f5190eaecd58 (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.cpp | 8 |
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)); } } } |