feat: add unit test
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package randomizer
|
||||
|
||||
import "math/rand"
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
)
|
||||
|
||||
type Random interface {
|
||||
Int() int
|
||||
@@ -25,8 +28,13 @@ func Rand(rand int) int {
|
||||
return randGen(rand)
|
||||
}
|
||||
func realRand(n int) int { return int(rand.Intn(n)) }
|
||||
func fakeRand(n int) func(_ int) int {
|
||||
return func(_ int)int { return n}
|
||||
func fakeRand(n int) func(numb int) int {
|
||||
return func(numb int)int {
|
||||
if n >= numb {
|
||||
panic(fmt.Sprintf("%d Should not be superior of %d",n,numb))
|
||||
}
|
||||
return n
|
||||
}
|
||||
}
|
||||
var randGen = NewRandomizer(realRand).Int
|
||||
|
||||
|
||||
Reference in New Issue
Block a user