Closed
Description
ScalaCheck's arbitrary BigInt is bounded, which can be very limiting for some applications and requires e.g. scientific and cryptographic users to implement custom generators. Providing a Choose[BigInt]
implementation could save considerable boilerplate. This is my implementation:
implicit object chooseBigInt extends Gen.Choose[BigInt] {
@tailrec
def choose(min: BigInt, max: BigInt): Gen[BigInt] = {
val n = min + BigInt((max - min).bitLength, Random)
if (n > max) choose(min, max) else n
}
}
Any interest in a PR?