(t *testing.T)
| 15 | } |
| 16 | |
| 17 | func TestRound(t *testing.T) { |
| 18 | for _, c := range []struct { |
| 19 | number float64 |
| 20 | decimals int |
| 21 | result float64 |
| 22 | }{ |
| 23 | {0.1111, 1, 0.1}, |
| 24 | {-0.1111, 2, -0.11}, |
| 25 | {5.3253, 3, 5.325}, |
| 26 | {5.3258, 3, 5.326}, |
| 27 | {5.3253, 0, 5.0}, |
| 28 | {5.55, 1, 5.6}, |
| 29 | } { |
| 30 | m, err := stats.Round(c.number, c.decimals) |
| 31 | if err != nil { |
| 32 | t.Errorf("Returned an error") |
| 33 | } |
| 34 | if m != c.result { |
| 35 | t.Errorf("%.1f != %.1f", m, c.result) |
| 36 | } |
| 37 | |
| 38 | } |
| 39 | _, err := stats.Round(math.NaN(), 2) |
| 40 | if err == nil { |
| 41 | t.Errorf("Round should error on NaN") |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | func BenchmarkRound(b *testing.B) { |
| 46 | for i := 0; i < b.N; i++ { |
nothing calls this directly
no test coverage detected
searching dependent graphs…