fail fast when rolling window size is zero

This commit is contained in:
kevin
2020-10-15 11:40:31 +08:00
parent 6f49639f80
commit c824e9e118
3 changed files with 11 additions and 21 deletions

View File

@@ -11,6 +11,13 @@ import (
const duration = time.Millisecond * 50
func TestNewRollingWindow(t *testing.T) {
assert.NotNil(t, NewRollingWindow(10, time.Second))
assert.Panics(t, func() {
NewRollingWindow(0, time.Second)
})
}
func TestRollingWindowAdd(t *testing.T) {
const size = 3
r := NewRollingWindow(size, duration)