From cc760f3a67cc136a30f707e19f1e9d2f01297959 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Mon, 2 Jan 2017 20:54:54 +0100 Subject: 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. --- src/tests/test_bigint.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src') 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(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)); } } } -- cgit v1.2.3