Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

ClockEstimate: DivByZero

The clock estimator has a potential division by zero.
Using `iteration + 1` seems also more logical to me for
an average.

Found with coverity in a downstream project.
Commit
d1e7344f16d5765ec2a675162a88983bd51baa1d
Author
Axel Huebl ·
Committer
Martin Hořeňovský
Parents
3ed544106777

Files · Download .tar.gz

Changes

 include/internal/catch_timer.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/internal/catch_timer.cpp b/include/internal/catch_timer.cpp
index d52c0085..ca383a2d 100644
--- a/include/internal/catch_timer.cpp
+++ b/include/internal/catch_timer.cpp
@@ -40,7 +40,7 @@ namespace Catch {
                 // is terrible and we should move on.
                 // TBD: How to signal that the measured resolution is probably wrong?
                 if (ticks > startTime + 3 * nanosecondsInSecond) {
-                    return sum / i;
+                    return sum / ( i + 1u );
                 }
             }