mirror of
https://github.com/number571/go-peer.git
synced 2026-09-14 11:05:42 +05:00
40 lines
552 B
Go
40 lines
552 B
Go
package random
|
|
|
|
import (
|
|
"bytes"
|
|
"testing"
|
|
)
|
|
|
|
func TestCSPRNG(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
r := NewRandom()
|
|
|
|
if bytes.Equal(r.GetBytes(8), r.GetBytes(8)) {
|
|
t.Fatal("bytes in random equals")
|
|
}
|
|
|
|
x := r.GetString(8)
|
|
if x == r.GetString(8) {
|
|
t.Fatal("strings in random equals")
|
|
}
|
|
|
|
y := r.GetUint64()
|
|
if y == r.GetUint64() {
|
|
t.Fatal("numbers in random equals")
|
|
}
|
|
}
|
|
|
|
func TestCSPRNGBool(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
r := NewRandom()
|
|
for i := 0; i < 1000; i++ {
|
|
t1 := r.GetBool()
|
|
t2 := r.GetBool()
|
|
if t1 != t2 {
|
|
break
|
|
}
|
|
}
|
|
}
|