Create a version of this Generator that produces values of exactly the specified size.
Create a version of this Generator that produces values of exactly the specified size.
For example, consider:
val stringSets: Generator[Set[String]] = Generator.setGenerator[String] val singleStringSets: Generator[Set[String]] = stringSets.havingSize(1)
The singleStringSets
Generator will always produce Sets of exactly one
String.
the size of the values to produce
a new Generator that produces values of that size
Create a version of this Generator that produces values within the specified size range.
Create a version of this Generator that produces values within the specified size range.
The bounds are inclusive: the resulting Generator may produce values with a
size of to
or from
.
For example, consider:
val stringSets: Generator[Set[String]] = Generator.setGenerator[String] val smallStringSets: Generator[Set[String]] = stringSets.havingSizesBetween(0, 3)
The smallStringSets
Generator will always produce Sets of zero through
three Strings.
The smallest desired size to produce
The largest desired size to produce
a Generator that will only produce values within that size range
Create a version of this Generator whose legal sizes are adjusted by a specified function.
Create a version of this Generator whose legal sizes are adjusted by a specified function.
For example:
def currentLimit: PosZInt = ... def limitedSize(szp: SizeParam): SizeParam = { val limit = currentLimit val sz = if (szp.maxSize < limit) szp.maxSize else limit szp.copy(size = sz) } val sizelimitedLists = lists[Int].havingSizesDeterminedBy(limitedSize)
This doesn't hard-code the size of the sizeLimitedLists
Generator, but
allows the maximum size to be clamped based on a dynamic currentLimit
function.
This trait is mixed in to Generators that have a well-defined notion of "size".
Broadly speaking, this applies when T is a type that has a
size
method. For example, Generator.setGenerator (also known as CommonGenerators.sets) has the HavingSize trait because Set has asize
method.Generators with this trait provide several functions that allow you to create more-specialized Generators, with specific size bounds.
the type that this Generator produces