Commit 3b17196f authored by Roman Proskuryakov's avatar Roman Proskuryakov

Add a test for Meter::Reset

parent a0a12174
......@@ -3,6 +3,7 @@ package flow
import (
"fmt"
"math"
"testing"
"time"
)
......@@ -29,6 +30,24 @@ func ExampleMeter() {
// Output: 3000 (300/s)
}
func TestResetMeter(t *testing.T) {
meter := new(Meter)
meter.Mark(30)
time.Sleep(2 * time.Second)
if total := meter.Snapshot().Total; total != 30 {
t.Errorf("total = %d; want 30", total)
}
meter.Reset()
if total := meter.Snapshot().Total; total != 0 {
t.Errorf("total = %d; want 0", total)
}
}
func roundTens(x float64) int64 {
return int64(math.Floor(x/10+0.5)) * 10
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment