Skip to content
This repository was archived by the owner on Oct 18, 2024. It is now read-only.

Commit 03af1fd

Browse files
authored
Merge pull request #85 from wingyplus/nan-report
gocov: report total coverage as 0.00% if reached and statements are zero
2 parents b6eca66 + 0c17229 commit 03af1fd

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

gocov/report.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"fmt"
2626
"io"
2727
"io/ioutil"
28+
"math"
2829
"os"
2930
"path/filepath"
3031
"sort"
@@ -136,6 +137,9 @@ func (r *report) printTotalCoverage(w io.Writer) {
136137
}
137138

138139
coveragePercentage := float64(totalReached) / float64(totalStatements) * 100
140+
if math.IsNaN(coveragePercentage) {
141+
coveragePercentage = 0
142+
}
139143
fmt.Fprintf(w, "Total Coverage: %.2f%% (%d/%d)", coveragePercentage, totalReached, totalStatements)
140144
fmt.Fprintln(w)
141145
}

0 commit comments

Comments
 (0)