Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
itsubaki committed Sep 16, 2024
1 parent 3b1b184 commit 885409b
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions math/rand/crypto_test.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,30 @@
package rand_test

import (
crand "crypto/rand"
"fmt"
randv2 "math/rand/v2"
"strings"
"testing"

"github.com/itsubaki/neu/math/rand"
)

func ExampleRead() {
reader := crand.Reader
defer func() {
crand.Reader = reader
}()

crand.Reader = strings.NewReader("io.Reader stream to be read\n")
if _, err := rand.Read(); err != nil {
fmt.Println(err)
}

// Output:
// read: unexpected EOF
}

func TestMustRead(t *testing.T) {
v := randv2.New(rand.NewSource(rand.MustRead())).Float64()
if v >= 0 && v < 1 {
Expand Down

0 comments on commit 885409b

Please sign in to comment.