Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Commit

Permalink
added unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
  • Loading branch information
fredbi committed May 10, 2021
1 parent 34c1bc0 commit 321a335
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions random_source_test.go
@@ -0,0 +1,25 @@
package faker

import (
cryptorand "crypto/rand"
"io"
mathrand "math/rand"
"testing"
"time"
)

func TestSetRandomSource(t *testing.T) {
SetRandomSource(NewSafeSource(mathrand.NewSource(time.Now().UnixNano())))

_ = rand.Int31n(100)
}

func TestSetCryptoSource(t *testing.T) {
SetCryptoSource(cryptorand.Reader)

buf := make([]byte, 10)
_, err := io.ReadFull(crypto, buf)
if err != nil {
t.Error("Expected Not Error, But Got: ", err)
}
}

0 comments on commit 321a335

Please sign in to comment.