mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
crypto.rand: add a test for rand.read/1
This commit is contained in:
parent
0363206bac
commit
c09e85fa90
15
vlib/crypto/rand/crypto_rand_read_test.v
Normal file
15
vlib/crypto/rand/crypto_rand_read_test.v
Normal file
@ -0,0 +1,15 @@
|
||||
import crypto.rand
|
||||
|
||||
fn test_reading() ? {
|
||||
a := rand.read(32) ?
|
||||
dump(a.hex())
|
||||
assert a.len == 32
|
||||
mut histogram := [256]int{}
|
||||
for b in a {
|
||||
histogram[b]++
|
||||
}
|
||||
dump(histogram)
|
||||
for h in histogram {
|
||||
assert h < 10
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user