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