crypto.rand: add a test for rand.read/1

pull/9325/head
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
1 changed files with 15 additions and 0 deletions

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