MCPcopy
hub / github.com/tinygo-org/tinygo / main

Function main

testdata/rand.go:7–24  ·  view source on GitHub ↗

TODO: make this a test in the crypto/rand package.

()

Source from the content-addressed store, hash-verified

5// TODO: make this a test in the crypto/rand package.
6
7func main() {
8 buf := make([]byte, 500)
9 n, err := rand.Read(buf)
10 if n != len(buf) || err != nil {
11 println("could not read random numbers:", err)
12 }
13
14 // Very simple test that random numbers are at least somewhat random.
15 sum := 0
16 for _, b := range buf {
17 sum += int(b)
18 }
19 if sum < 95*len(buf) || sum > 159*len(buf) {
20 println("random numbers don't seem that random, the average byte is", sum/len(buf))
21 } else {
22 println("random number check was successful")
23 }
24}

Callers

nothing calls this directly

Calls 1

ReadMethod · 0.65

Tested by

no test coverage detected