1
0
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:
Delyan Angelov 2021-03-16 11:37:05 +02:00
parent 0363206bac
commit c09e85fa90
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED

View 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
}
}