-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxoshiro256_test.go
41 lines (36 loc) · 1001 Bytes
/
xoshiro256_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package fastrand
import "testing"
var expXoroshiro = []uint64{0x0, 0x1680, 0x1680, 0x2d001680, 0x2d000002d000000, 0x5a5a2d001680, 0x2d05a002d0b4000, 0x1c005a002d000000}
func TestXoshiro256StarStar(t *testing.T) {
var r Xoshiro256StarStar
r.Seed(1, 0, 0, 0)
for i, e := range expXoroshiro {
if g := r.Uint64(); g != e {
t.Errorf("i=%d, expected=%x, got=%x", i, e, g)
}
}
}
func TestShardedXoshiro256StarStarFallback(t *testing.T) {
var r ShardedXoshiro256StarStar // no shards created
r.fallback.Seed(1, 0, 0, 0)
for i, e := range expXoroshiro {
if g := r.Uint64(); g != e {
t.Errorf("i=%d, expected=%x, got=%x", i, e, g)
}
}
}
func TestShardedXoshiro256StarStar(t *testing.T) {
r := NewShardedXoshiro256StarStar()
id := procPin()
defer procUnpin()
if fastrand_nounsafe {
r.fallback.Seed(1, 0, 0, 0)
} else {
r.states[id].Seed(1, 0, 0, 0)
}
for i, e := range expXoroshiro {
if g := r.Uint64(); g != e {
t.Errorf("i=%d, expected=%x, got=%x", i, e, g)
}
}
}