mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 19:58:54 +01:00
audio/internal/convert: use math/rand instead of crypto/rand
This commit is contained in:
parent
f63c1c8fc5
commit
a5213de991
@ -16,9 +16,8 @@ package convert_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"crypto/rand"
|
|
||||||
"io"
|
"io"
|
||||||
"runtime"
|
"math/rand" // TODO: Use math/rand/v2 when the minimum supported version becomes Go 1.22.
|
||||||
"testing"
|
"testing"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
@ -27,8 +26,8 @@ import (
|
|||||||
|
|
||||||
func randInt16s(n int) []int16 {
|
func randInt16s(n int) []int16 {
|
||||||
r := make([]int16, n)
|
r := make([]int16, n)
|
||||||
if _, err := rand.Read(unsafe.Slice((*byte)(unsafe.Pointer(&r[0])), len(r)*2)); err != nil {
|
for i := range r {
|
||||||
panic(err)
|
r[i] = int16(rand.Intn(1<<16) - (1 << 15))
|
||||||
}
|
}
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
@ -55,13 +54,10 @@ func TestFloat32(t *testing.T) {
|
|||||||
Name: "random 256 values",
|
Name: "random 256 values",
|
||||||
In: randInt16s(256),
|
In: randInt16s(256),
|
||||||
},
|
},
|
||||||
}
|
{
|
||||||
// On browsers, entropy might not be enough.
|
|
||||||
if runtime.GOOS != "js" {
|
|
||||||
cases = append(cases, testCase{
|
|
||||||
Name: "random 65536 values",
|
Name: "random 65536 values",
|
||||||
In: randInt16s(65536),
|
In: randInt16s(65536),
|
||||||
})
|
},
|
||||||
}
|
}
|
||||||
for _, c := range cases {
|
for _, c := range cases {
|
||||||
c := c
|
c := c
|
||||||
|
Loading…
Reference in New Issue
Block a user