mirror of https://github.com/v2ray/v2ray-core
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
528 B
25 lines
528 B
9 years ago
|
package protocol_test
|
||
9 years ago
|
|
||
|
import (
|
||
|
"testing"
|
||
|
"time"
|
||
|
|
||
9 years ago
|
. "github.com/v2ray/v2ray-core/common/protocol"
|
||
9 years ago
|
v2testing "github.com/v2ray/v2ray-core/testing"
|
||
9 years ago
|
"github.com/v2ray/v2ray-core/testing/assert"
|
||
9 years ago
|
)
|
||
|
|
||
|
func TestGenerateRandomInt64InRange(t *testing.T) {
|
||
9 years ago
|
v2testing.Current(t)
|
||
9 years ago
|
|
||
9 years ago
|
base := time.Now().Unix()
|
||
|
delta := 100
|
||
9 years ago
|
generator := NewTimestampGenerator(Timestamp(base), delta)
|
||
9 years ago
|
|
||
|
for i := 0; i < 100; i++ {
|
||
9 years ago
|
v := int64(generator())
|
||
9 years ago
|
assert.Int64(v).AtMost(base + int64(delta))
|
||
|
assert.Int64(v).AtLeast(base - int64(delta))
|
||
|
}
|
||
|
}
|