Atlas › Test
TestBasicRandomness
Exact test identity: go.temporal.io/server/common/fastrand/TestBasicRandomness
- Package
go.temporal.io/server/common/fastrand
- Suite / test hierarchy
TestBasicRandomness
- Test
TestBasicRandomness
- Introduced at
- fastrand.go ×4 Frontier kind: Joint frontier
- Covered ranges
- 4
- Covered lines
- 13
- Covered files
- 1
Covered source
Expand a file to inspect source; the > gutter marks covered lines.
go.temporal.io/server/common/fastrand/fastrand.go 13 covered LOC · 4 ranges
Open complete file
16
// the code.
17
var globalRngPool = sync.Pool{
19
>
return rand.New(rand.NewSource(rand.Int63()))
20
>
},
21
}
22
24
// for globalRngPool.Get(), with a typecast and assertion that everything is
25
// as expected.
27
>
rng, ok := globalRngPool.Get().(*rand.Rand)
28
>
if !ok {
29
// nolint:forbidigo
30
panic("Failed to access valid object from globalRngPool") // This should never happen, since it would mean someone put an invalid object into the pool.
31
}
32
34
}
35
108
109
// Intn implements [math/rand.Rand.Intn].
111
>
rng := getRng()
112
>
res := rng.Intn(n)
113
>
globalRngPool.Put(rng)
114
>
return res
115
>
}
116
117
// NormFloat64 implements [math/rand.Rand.NormFloat64].