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