1
Fork 0
galene/estimator/estimator_test.go

22 lines
352 B
Go
Raw Normal View History

2020-04-30 20:15:52 +02:00
package estimator
import (
"testing"
"time"
)
func TestEstimator(t *testing.T) {
now := time.Now()
e := New(time.Second)
e.estimate(now)
2020-05-31 23:47:12 +02:00
e.Accumulate(42)
e.Accumulate(128)
2020-04-30 20:15:52 +02:00
e.estimate(now.Add(time.Second))
rate := e.estimate(now.Add(time.Second + time.Millisecond))
if rate != 42+128 {
t.Errorf("Expected %v, got %v", 42+128, rate)
}
}