rand_test.go 387 B

1234567891011121314151617181920
  1. package protocol
  2. import (
  3. "testing"
  4. "time"
  5. "github.com/v2ray/v2ray-core/testing/unit"
  6. )
  7. func TestGenerateRandomInt64InRange(t *testing.T) {
  8. assert := unit.Assert(t)
  9. base := time.Now().Unix()
  10. delta := 100
  11. for i := 0; i < 100; i++ {
  12. v := GenerateRandomInt64InRange(base, delta)
  13. assert.Int64(v).AtMost(base + int64(delta))
  14. assert.Int64(v).AtLeast(base - int64(delta))
  15. }
  16. }