...
1
16
17 package calculation
18
19 import (
20 "testing"
21 )
22
23 func TestRatio(t *testing.T) {
24 t.Run("regular", func(t *testing.T) {
25 c := &Coverage{Name: "fake-coverage", NumCoveredStmts: 105, NumAllStmts: 210}
26 actualRatio := c.Ratio()
27 if actualRatio != float32(.5) {
28 t.Fatalf("incorrect coverage ratio: expected 0.5, got %f", actualRatio)
29 }
30 })
31
32 t.Run("no actual statements", func(t *testing.T) {
33 c := &Coverage{Name: "fake-coverage", NumCoveredStmts: 0, NumAllStmts: 0}
34 if c.Ratio() != float32(1) {
35 t.Fatalf("incorrect coverage ratio: expected 1, got %f", c.Ratio())
36 }
37 })
38 }
39
View as plain text