diff options
author | Jack Lloyd <[email protected]> | 2015-11-11 08:36:09 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2015-11-11 08:36:09 -0500 |
commit | 75dbef27700d22478a5845476bd7b120f72cfe2c (patch) | |
tree | 493ff5ef9135477b394c24f1bdaac675e82bf4da /src/tests/test_bigint.cpp | |
parent | f266e5e24b61ace20e79d7e27f178068fed86d64 (diff) |
Fix occasional test fails
Increase the iterations of the BigInt::random_integer test. Since things
get slow quickly, leave the larger range tests to higher soak levels.
In TLS, if the corrupted data causes an exception immediately that's ok
because it's corrupted data.
Diffstat (limited to 'src/tests/test_bigint.cpp')
-rw-r--r-- | src/tests/test_bigint.cpp | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/src/tests/test_bigint.cpp b/src/tests/test_bigint.cpp index 07158fee1..96ec035fe 100644 --- a/src/tests/test_bigint.cpp +++ b/src/tests/test_bigint.cpp @@ -80,11 +80,29 @@ class BigInt_Unit_Tests : public Test { Test::Result result("BigInt::random_integer"); - const size_t ITERATIONS = 1000; + result.start_timer(); - for(size_t range_min : { 0, 10, 100 }) + const size_t ITERATIONS = 5000; + + std::vector<size_t> min_ranges{ 0 }; + std::vector<size_t> max_ranges{ 10 }; + + // This gets slow quickly: + if(Test::soak_level() > 10) { - for(size_t range_max : { 0, 10, 100 }) + min_ranges.push_back(10); + max_ranges.push_back(100); + + if(Test::soak_level() > 50) + { + min_ranges.push_back(79); + max_ranges.push_back(293); + } + } + + for(size_t range_min : min_ranges) + { + for(size_t range_max : max_ranges) { if(range_min >= range_max) continue; @@ -104,14 +122,22 @@ class BigInt_Unit_Tests : public Test double ratio = static_cast<double>(counts[i]) / ITERATIONS; double dev = std::min(ratio, std::fabs(1.0 - ratio)); - if(dev > .15) + if(dev < .15) { - result.test_failure("random_integer distribution" + std::to_string(dev)); + 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.end_timer(); + return result; } }; |