You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ntool/nrandom/int_test.go

25 lines
484 B
Go

package nrandom_test
import (
"fmt"
"git.noahlan.cn/noahlan/ntool/nrandom"
"git.noahlan.cn/noahlan/ntool/ntest/assert"
"testing"
"time"
)
func TestRandInt(t *testing.T) {
min, max := 1000, 9999
for i := 0; i < 5; i++ {
val := nrandom.RandInt(min, max)
fmt.Println(val)
assert.True(t, val >= min)
assert.True(t, val <= max)
seed := time.Now().UnixNano()
val = nrandom.RandIntWithSeed(min, max, seed)
assert.True(t, val >= min)
assert.True(t, val <= max)
}
}