1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

crypto.rand: add PRNG function read_u64

This commit is contained in:
joe-conigliaro
2019-09-18 05:03:54 +10:00
committed by Alexander Medvednikov
parent 1796869da7
commit 32ad33558d
2 changed files with 77 additions and 1 deletions

View File

@ -4,7 +4,7 @@
import crypto.rand
fn test_crypto_rand() {
fn test_crypto_rand_read() {
no_bytes := 100
max_percentage_diff := 20
@ -28,3 +28,16 @@ fn test_crypto_rand() {
assert diff_percentage <= max_percentage_diff
}
fn test_crypto_rand_read_u64() {
max := u64(200)
r1 := rand.read_u64(max) or {
assert false
return
}
r2 := rand.read_u64(max) or {
assert false
return
}
assert r1 > u64(0) && r2 > u64(0) && r1 < max && r2 < max
}