kotest-property / io.kotest.property / Exhaustive

Exhaustive

abstract class Exhaustive<A> : Gen<A>

An exhaustive is a type of Gen which generates an exhaustive set of values from a defined range.

An example of a exhaustive is the sequence of integers from 0 to 100. Another example is all strings of two characters.

A progression is useful when you want to generate an exhaustive set of values from a given sample space, rather than random values from that space. For example, if you were testing a function that used an enum, you might prefer to guarantee that every enum value is used, rather than selecting randomly from amongst the enum values (with possible duplicates and gaps).

Exhaustives do not shrink their values. There is no need to find a smaller failing case, because the smaller values will themselves naturally be included in the tested values.

An exhaustive is less suitable when you have a large sample space you need to select values from.

Constructors

<init>

An exhaustive is a type of Gen which generates an exhaustive set of values from a defined range.

Exhaustive()

Properties

values

Returns the values of this Exhaustive.

abstract val values: List<A>

Functions

toArb

Converts this into an Arb where the generated values of the returned arb are choosen randomly from the values provided by this exhausive.

fun toArb(): Arb<A>

Extension Functions

andNull

fun <A> Exhaustive<A>.andNull(): Exhaustive<A?>

checkAll

suspend fun <A> Gen<A>.checkAll(property: suspend PropertyContext.(A) -> Unit): PropertyContext
suspend fun <A> Gen<A>.checkAll(iterations: Int, property: suspend PropertyContext.(A) -> Unit): PropertyContext
suspend fun <A> Gen<A>.checkAll(config: PropTestConfig, property: suspend PropertyContext.(A) -> Unit): PropertyContext
suspend fun <A> Gen<A>.checkAll(iterations: Int, config: PropTestConfig, property: suspend PropertyContext.(A) -> Unit): PropertyContext

concat

Returns an Exhaustive which is the concatentation of this exhaustive values plus the given exhaustive's values.

fun <A> Exhaustive<A>.concat(other: Exhaustive<A>): Exhaustive<A>

forAll

suspend fun <A> Gen<A>.forAll(property: PropertyContext.(A) -> Boolean): PropertyContext
suspend fun <A> Gen<A>.forAll(iterations: Int, property: PropertyContext.(A) -> Boolean): PropertyContext
suspend fun <A> Gen<A>.forAll(config: PropTestConfig, property: PropertyContext.(A) -> Boolean): PropertyContext
suspend fun <A> Gen<A>.forAll(iterations: Int, config: PropTestConfig, property: PropertyContext.(A) -> Boolean): PropertyContext

merge

Returns a new Exhaustive which will merge the values from this Exhaustive and the values of the supplied Exhaustive together, taking one from each in turn.

fun <A, B : A> Exhaustive<A>.merge(other: Exhaustive<B>): Exhaustive<A>

plus

Returns an Exhaustive which is the concatentation of this exhaustive values plus the given exhaustive's values.

operator fun <A> Exhaustive<A>.plus(other: Exhaustive<A>): Exhaustive<A>

times

Returns the cross product of two Exhaustives.

operator fun <A, B : A> Exhaustive<A>.times(other: Exhaustive<B>): Exhaustive<Pair<A, B>>

Companion Object Extension Functions

azstring

fun Exhaustive.Companion.azstring(range: IntRange): Exhaustive<String>

boolean

Returns a Exhaustive of the two possible boolean values - true and false.

fun Exhaustive.Companion.boolean(): Exhaustive<Boolean>

bytes

Returns a Exhaustive of bytes in the given range.

fun Exhaustive.Companion.bytes(from: Byte = Byte.MIN_VALUE, to: Byte = Byte.MAX_VALUE): Exhaustive<Byte>

collection

fun <A> Exhaustive.Companion.collection(collection: Collection<A>): Exhaustive<A>

constant

Returns a Exhaustive whose value is a single constant.

fun <A> Exhaustive.Companion.constant(a: A): Exhaustive<A>

enum

fun <T : Enum<T>> Exhaustive.Companion.enum(): Exhaustive<T>

ints

fun Exhaustive.Companion.ints(range: IntRange): Exhaustive<Int>

lines

fun Exhaustive.Companion.lines(file: File, charset: Charset = Charsets.UTF_8): Exhaustive<String>

longs

fun Exhaustive.Companion.longs(range: LongRange): Exhaustive<Long>

nullable

fun Exhaustive.Companion.nullable(): Exhaustive<Nothing?>