2015-09-19 18:11:14 -04:00
|
|
|
package user
|
2015-09-16 18:15:06 -04:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
2015-12-02 10:26:11 -05:00
|
|
|
v2testing "github.com/v2ray/v2ray-core/testing"
|
2015-12-02 09:27:18 -05:00
|
|
|
"github.com/v2ray/v2ray-core/testing/assert"
|
2015-09-16 18:15:06 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestGenerateRandomInt64InRange(t *testing.T) {
|
2015-12-02 09:27:18 -05:00
|
|
|
v2testing.Current(t)
|
2015-09-16 18:15:06 -04:00
|
|
|
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))
|
|
|
|
}
|
|
|
|
}
|