Skip to content

acomagu/randtest

Repository files navigation

Crazy randtest

GoDoc CircleCI Codecov

randtest controls the math/rand.Rand behavior from the Source for testing purpose.

type Behavior struct{}

func (b *Behavior) Intn(n int) int {
	return n / 2
}

func main() {
	source := randtest.NewSource(&Behavior{})
	r := rand.New(source)

	fmt.Println(r.Intn(10)) // Always 5.
}

This is experimental package. It can be broken by updating Go because the logic is highly depends on undocumented behavior of math/rand package. Only tested on Go1.11.

About

Crazy testing utility for math/rand

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published