mirror of
https://github.com/pion/webrtc.git
synced 2025-11-03 09:40:59 +08:00
Fix randoms
Use seeded mathematical random where uniqueness is needed but not required to be cryptographic.
This commit is contained in:
@@ -6,14 +6,14 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestRandSeq(t *testing.T) {
|
||||
if len(RandSeq(10)) != 10 {
|
||||
t.Errorf("RandSeq return invalid length")
|
||||
func TestMathRandAlpha(t *testing.T) {
|
||||
if len(MathRandAlpha(10)) != 10 {
|
||||
t.Errorf("MathRandAlpha return invalid length")
|
||||
}
|
||||
|
||||
var isLetter = regexp.MustCompile(`^[a-zA-Z]+$`).MatchString
|
||||
if !isLetter(RandSeq(10)) {
|
||||
t.Errorf("RandSeq should be AlphaNumeric only")
|
||||
if !isLetter(MathRandAlpha(10)) {
|
||||
t.Errorf("MathRandAlpha should be AlphaNumeric only")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user