public static class Gen.DefaultImpls
A Generator, or interface Gen is responsible for generating data
to be used in property testing. Each generator will
generate data for a specific type .
The idea behind property testing is the testing framework will automatically test a range of different values, including edge cases and random values.
There are two types of values to consider.
The first are values that should always be included - those edge cases values which are common sources of bugs. For example, a generator for Ints should always include values like zero, minus 1, positive 1, Integer.MAX_VALUE and Integer.MIN_VALUE.
Another example would be for a generator for enums. That should include all the values of the enum to ensure each value is tested.
The second set of values are random values, which are used to give us a greater breadth of values tested. The Int generator example should return a random int from across the entire integer range.
interface Gen,
Int,
Int| Modifier and Type | Method and Description |
|---|---|
static Gen<T> |
filter(Gen<T> $this,
kotlin.jvm.functions.Function1<? super T,java.lang.Boolean> pred)
Create a new
interface Gen by filtering the output of this gen. |
static Gen<T> |
filterNot(Gen<T> $this,
kotlin.jvm.functions.Function1<? super T,java.lang.Boolean> f) |
static <U> Gen<U> |
flatMap(Gen<T> $this,
kotlin.jvm.functions.Function1<? super T,? extends io.kotlintest.properties.Gen<U>> f)
Create a new
interface Gen by mapping the output of this gen. |
static <U> Gen<U> |
map(Gen<T> $this,
kotlin.jvm.functions.Function1<? super T,? extends U> f)
Create a new
interface Gen by mapping the output of this gen. |
static <U> Gen<T> |
merge(Gen<T> $this,
Gen<U> gen)
Returns a new [
interface Gen] which will return the values from this gen and the values of
the supplied gen together. The supplied gen must be a subtype of the
type of this gen. |
static java.lang.String |
nextPrintableString(Gen<T> $this,
int length) |
static Gen<T> |
orNull(Gen<T> $this)
Create a new
interface Gen which will return the values of this gen plus null. |
static Shrinker<T> |
shrinker(Gen<T> $this) |
public static Gen<T> filter(Gen<T> $this, kotlin.jvm.functions.Function1<? super T,java.lang.Boolean> pred)
Create a new interface Gen by filtering the output of this gen.
interface Genpublic static Gen<T> filterNot(Gen<T> $this, kotlin.jvm.functions.Function1<? super T,java.lang.Boolean> f)
public static <U> Gen<U> flatMap(Gen<T> $this, kotlin.jvm.functions.Function1<? super T,? extends io.kotlintest.properties.Gen<U>> f)
Create a new interface Gen by mapping the output of this gen.
interface Genpublic static <U> Gen<U> map(Gen<T> $this, kotlin.jvm.functions.Function1<? super T,? extends U> f)
Create a new interface Gen by mapping the output of this gen.
interface Genpublic static Gen<T> orNull(Gen<T> $this)
Create a new interface Gen which will return the values of this gen plus null.
interface Genpublic static <U> Gen<T> merge(Gen<T> $this, Gen<U> gen)
Returns a new [interface Gen] which will return the values from this gen and the values of
the supplied gen together. The supplied gen must be a subtype of the
type of this gen.
interface Genpublic static java.lang.String nextPrintableString(Gen<T> $this, int length)