24 lines
555 B
Go
24 lines
555 B
Go
|
|
package utilities
|
||
|
|
|
||
|
|
import (
|
||
|
|
"testing"
|
||
|
|
"time"
|
||
|
|
)
|
||
|
|
|
||
|
|
func TestDefaultApplyJitterIsAlwaysGEZero(t *testing.T) {
|
||
|
|
if got := DefaultApplyJitter(maxInt64, time.Nanosecond); got < 0 {
|
||
|
|
t.Fatalf("error: wanted >= 0; got %s\n", got)
|
||
|
|
}
|
||
|
|
if got := DefaultApplyJitter(maxInt64, maxInt64); got < 0 {
|
||
|
|
t.Fatalf("error: wanted >= 0; got %s\n", got)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func TestDefaultApplyJitterWithZeroPauseAlwaysZero(t *testing.T) {
|
||
|
|
for i := 0; i < 10; i++ {
|
||
|
|
if got := DefaultApplyJitter(0, time.Duration(i)); got != 0 {
|
||
|
|
t.Fatalf("error: wanted 0; got %s\n", got)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|