mkroli / scrand   0.2

Apache License 2.0 GitHub

scrand (SCala-RANDom) generates random instances of various types of Scala classes

Scala versions: 2.12 2.11 2.10

scrand

Build Status Coverage Status

scrand (SCala-RANDom) generates random instances of various types of Scala classes.

Usage

sbt

resolvers += "bintray" at "http://dl.bintray.com/mkroli/maven"

libraryDependencies += "com.github.mkroli" %% "scrand" % "0.4.0"

Examples

scala> import com.github.mkroli.scrand._

scala> Random[Int]
res0: Int = 12345

scala> Random[Either[Int, Boolean]]
res1: Either[Int,Boolean] = Right(false)

scala> Random[(Int, Option[(Int, Int)])]
res2: (Int, Option[(Int, Int)]) = (12345,Some((12345,12345)))

scala> case class Inner(i: Int)
scala> case class Outer(b: Boolean, i: Inner)
scala> Random[Outer]
res3: Outer = Outer(true,Inner(12345))

For more examples see src/test/scala/.../RandomSpec.scala.