mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-11-17 09:56:18 -05:00
21 lines
383 B
Go
21 lines
383 B
Go
|
package math
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
"time"
|
||
|
|
||
|
"github.com/v2ray/v2ray-core/testing/unit"
|
||
|
)
|
||
|
|
||
|
func TestGenerateRandomInt64InRange(t *testing.T) {
|
||
|
assert := unit.Assert(t)
|
||
|
base := time.Now().Unix()
|
||
|
delta := 100
|
||
|
|
||
|
for i := 0; i < 100; i++ {
|
||
|
v := GenerateRandomInt64InRange(base, delta)
|
||
|
assert.Int64(v).AtMost(base + int64(delta))
|
||
|
assert.Int64(v).AtLeast(base - int64(delta))
|
||
|
}
|
||
|
}
|