...
1
2
3
4
5 package rand
6
7 import (
8 "sync"
9 "testing"
10 )
11
12
13
14 func TestConcurrent(t *testing.T) {
15 const (
16 numRoutines = 10
17 numCycles = 10
18 )
19 var wg sync.WaitGroup
20 defer wg.Wait()
21 wg.Add(numRoutines)
22 for i := 0; i < numRoutines; i++ {
23 go func(i int) {
24 defer wg.Done()
25 buf := make([]byte, 997)
26 for j := 0; j < numCycles; j++ {
27 var seed uint64
28 seed += uint64(ExpFloat64())
29 seed += uint64(Float32())
30 seed += uint64(Float64())
31 seed += uint64(Intn(Int()))
32 seed += uint64(Int31n(Int31()))
33 seed += uint64(Int63n(Int63()))
34 seed += uint64(NormFloat64())
35 seed += uint64(Uint32())
36 seed += uint64(Uint64())
37 for _, p := range Perm(10) {
38 seed += uint64(p)
39 }
40 Read(buf)
41 for _, b := range buf {
42 seed += uint64(b)
43 }
44 Seed(uint64(i*j) * seed)
45 }
46 }(i)
47 }
48 }
49
View as plain text