# Generators List

This page lists all current generators in Kotest. There are two types of generator: arbitrary and exhaustive.

Most generators are available on all platforms. Some are JVM or JS specific.

We also provide generators for Arrow as a separate module.

Generator | Description | JVM | JS | Native |
---|---|---|---|---|

Nulls | ||||

`arb.orNull()` | Generates random values from the arb instance, with null values mixed in. For example, `Arb.int().orNull()` could generate `1, -1, null, 8, 17` , and so on. Has overloaded versions to control the frequency of nulls being generated. | โ | โ | โ |

`arb.orNull(nullProbability)` | Generates random values from the arb instance, with null values mixed in using the defined probability. | โ | โ | โ |

Booleans | ||||

`Arb.boolean()` | Returns an `Arb` that produces `Boolean` s. | โ | โ | โ |

`Arb.booleanArray(length, content)` | Returns an `Arb` that produces `BoolArray` s where `length` produces the length of the arrays and `content` produces the content of the arrays. | โ | โ | โ |

`Exhaustive.boolean()` | Alternatives between true and false. | โ | โ | โ |

Chars | ||||

`Arb.char(range1, range2,...)` | Returns random char's generated from one or more given ranges. By supporting multiple ranges, it is possible to specific non-consecutive ranges of characters to populate values from. | โ | โ | โ |

`Arb.charArray(length, content)` | Returns an `Arb` that produces `CharArray` s where `length` produces the length of the arrays and `content` produces the content of the arrays. | โ | โ | โ |

Bytes | ||||

`Arb.byte(min, max)` | Returns an `Arb` that produces `Byte` s from `min` to `max` (inclusive). The edge cases are `min` , -1, 0, 1 and `max` which are only included if they are in the provided range. | โ | โ | โ |

`Arb.positiveByte(min, max)` | Returns an `Arb` that produces positive `Byte` s from `min` to `max` (inclusive). The edge cases are 1 and `max` which are only included if they are in the provided range. | โ | โ | โ |

`Arb.negativeByte(min, max)` | Returns an `Arb` that produces negative `Byte` s from `min` to `max` (inclusive). The edge cases are `min` and -1 which are only included if they are in the provided range. | โ | โ | โ |

`Arb.byteArray(length, content)` | Returns an `Arb` that produces `ByteArray` s where `length` produces the length of the arrays and `content` produces the content of the arrays. | โ | โ | โ |

`Arb.uByte(min, max)` | Returns an `Arb` that produces `UByte` s from `min` to `max` (inclusive). The edge cases are `min` , 1 and `max` which are only included if they are in the provided range. | โ | โ | โ |

`Arb.uByteArray(length, content)` | Returns an `Arb` that produces `UByteArray` s where `length` produces the length of the arrays and `content` produces the content of the arrays. | โ | โ | โ |

Shorts | ||||

`Arb.short(min, max)` | Returns an `Arb` that produces `Short` s from `min` to `max` (inclusive). The edge cases are `min` , -1, 0, 1 and `max` which are only included if they are in the provided range. | โ | โ | โ |

`Arb.positiveShort(min, max)` | Returns an `Arb` that produces positive `Short` s from `min` to `max` (inclusive). The edge cases are 1 and `max` which are only included if they are in the provided range. | โ | โ | โ |

`Arb.negativeShort(min, max)` | Returns an `Arb` that produces negative `Short` s from `min` to `max` (inclusive). The edge cases are `min` and -1 which are only included if they are in the provided range. | โ | โ | โ |

`Arb.shortArray(length, content)` | Returns an `Arb` that produces `ShortArray` s where `length` produces the length of the arrays and `content` produces the content of the arrays. | โ | โ | โ |

`Arb.uShort(min, max)` | Returns an `Arb` that produces `UShort` s from `min` to `max` (inclusive). The edge cases are `min` , 1 and `max` which are only included if they are in the provided range. | โ | โ | โ |

`Arb.uShortArray(length, content)` | Returns an `Arb` that produces `UShortArray` s where `length` produces the length of the arrays and `content` produces the content of the arrays. | โ | โ | โ |

Ints | ||||

`Arb.int(min, max)` | Returns an `Arb` that produces `Int` s from `min` to `max` (inclusive). The edge cases are `min` , -1, 0, 1 and `max` which are only included if they are in the provided range. | โ | โ | โ |

`Arb.positiveInt(min, max)` | Returns an `Arb` that produces positive `Int` s from `min` to `max` (inclusive). The edge cases are 1 and `max` which are only included if they are in the provided range. | โ | โ | โ |

`Arb.nonNegativeInts(min, max)` | Returns an `Arb` that produces non negative `Int` s from `min` to `max` (inclusive). The edge cases are 0, 1 and `max` which are only included if they are in the provided range. | โ | โ | โ |

`Arb.negativeInt(min, max)` | Returns an `Arb` that produces negative `Int` s from `min` to `max` (inclusive). The edge cases are `min` and -1 which are only included if they are in the provided range. | โ | โ | โ |

`Arb.nonPositiveInts(min, max)` | Returns an `Arb` that produces non positive `Int` s from `min` to `max` (inclusive). The edge cases are `min` , -1 and 0 which are only included if they are in the provided range. | โ | โ | โ |

`Arb.intArray(length, content)` | Returns an `Arb` that produces `IntArray` s where `length` produces the length of the arrays and `content` produces the content of the arrays. | โ | โ | โ |

`Arb.uInt(min, max)` | Returns an `Arb` that produces `UInt` s from `min` to `max` (inclusive). The edge cases are `min` , 1 and `max` which are only included if they are in the provided range. | โ | โ | โ |

`Arb.uIntArray(length, content)` | Returns an `Arb` that produces `UIntArray` s where `length` produces the length of the arrays and `content` produces the content of the arrays. | โ | โ | โ |

`Exhaustive.ints(range)` | Returns all ints in the given range. | โ | โ | โ |

`Arb.multiple(k, max)` | Generates multiples of k up a max value. The edge cases are `0` . | โ | โ | โ |

`Arb.factor(k)` | Generates factors of k. | โ | โ | โ |

Longs | ||||

`Arb.long(min, max)` | Returns an `Arb` that produces `Long` s from `min` to `max` (inclusive). The edge cases are `min` , -1, 0, 1 and `max` which are only included if they are in the provided range. | โ | โ | โ |

`Arb.positiveLong(min, max)` | Returns an `Arb` that produces positive `Long` s from `min` to `max` (inclusive). The edge cases are 1 and `max` which are only included if they are in the provided range. | โ | โ | โ |

`Arb.negativeLong(min, max)` | Returns an `Arb` that produces negative `Long` s from `min` to `max` (inclusive). The edge cases are `min` and -1 which are only included if they are in the provided range. | โ | โ | โ |

`Arb.longArray(length, content)` | Returns an `Arb` that produces `LongArray` s where `length` produces the length of the arrays and `content` produces the content of the arrays. | โ | โ | โ |

`Arb.uLong(min, max)` | Returns an `Arb` that produces `ULong` s from `min` to `max` (inclusive). The edge cases are `min` , 1 and `max` which are only included if they are in the provided range. | โ | โ | โ |

`Arb.uLongArray(length, content)` | Returns an `Arb` that produces `ULongArray` s where `length` produces the length of the arrays and `content` produces the content of the arrays. | โ | โ | โ |

`Exhaustive.longs(range)` | Returns all longs in the given range. | โ | โ | โ |

Floats | ||||

`Arb.float(min, max)` | Returns an `Arb` that produces `Float` s from `min` to `max` (inclusive). The edge cases are `Float.NEGATIVE_INFINITY` , `min` , -1.0, -`Float.MIN_VALUE` , -0.0, 0.0, `Float.MIN_VALUE` , 1.0, `max` , `Float.POSITIVE_INFINITY` and `Float.NaN` which are only included if they are in the provided range. | โ | โ | โ |

`Arb.positiveFloat(min, max)` | Returns an `Arb` that produces positive `Float` s from `min` to `max` (inclusive). `Float.MIN_VALUE` , 1.0, `max` , `Float.POSITIVE_INFINITY` which are only included if they are in the provided range. | โ | โ | โ |

`Arb.negativeFloat(min, max)` | Returns an `Arb` that produces negative `Float` s from `min` to `max` (inclusive). The edge cases are `Float.NEGATIVE_INFINITY` , `min` , -1.0 and -`Float.MIN_VALUE` which are only included if they are in the provided range. | โ | โ | โ |

`Arb.numericFloat(min, max)` | Returns an `Arb` that produces numeric `Float` s from `min` to `max` (inclusive). The edge cases are `min` , -1.0, -`Float.MIN_VALUE` , -0.0, 0.0, `Float.MIN_VALUE` , 1.0 and `max` which are only included if they are in the provided range. | โ | โ | โ |

`Arb.floatArray(length, content)` | Returns an `Arb` that produces `FloatArray` s where `length` produces the length of the arrays and `content` produces the content of the arrays. | โ | โ | โ |

Doubles | ||||

`Arb.double(min, max)` | Returns an `Arb` that produces `Double` s from `min` to `max` (inclusive). The edge cases are `Double.NEGATIVE_INFINITY` , `min` , -1.0, -`Double.MIN_VALUE` , -0.0, 0.0, `Double.MIN_VALUE` , 1.0, `max` , `Double.POSITIVE_INFINITY` and `Double.NaN` which are only included if they are in the provided range. | โ | โ | โ |

`Arb.positiveDouble(min, max)` | Returns an `Arb` that produces positive `Double` s from `min` to `max` (inclusive). `Double.MIN_VALUE` , 1.0, `max` , `Double.POSITIVE_INFINITY` which are only included if they are in the provided range. | โ | โ | โ |

`Arb.negativeDouble(min, max)` | Returns an `Arb` that produces negative `Double` s from `min` to `max` (inclusive). The edge cases are `Double.NEGATIVE_INFINITY` , `min` , -1.0 and -`Double.MIN_VALUE` which are only included if they are in the provided range. | โ | โ | โ |

`Arb.numericDouble(min, max)` | Returns an `Arb` that produces numeric `Double` s from `min` to `max` (inclusive). The edge cases are `min` , -1.0, -`Double.MIN_VALUE` , -0.0, 0.0, `Double.MIN_VALUE` , 1.0 and `max` which are only included if they are in the provided range. | โ | โ | โ |

`Arb.doubleArray(length, content)` | Returns an `Arb` that produces `DoubleArray` s where `length` produces the length of the arrays and `content` produces the content of the arrays. | โ | โ | โ |

Enums | ||||

`Arb.enum<T>()` | Randomly selects constants from the given enum. | โ | โ | โ |

`Exhaustive.enum<T>()` | Iterates all the constants defined in the given enum. | โ | โ | โ |

Geo | ||||

`Arb.latlong()` | Generates random pairs of doubles, where each double is in the range -180 to 180. | โ | โ | โ |

Strings | ||||

`Arb.string(range)` | Generates random printable strings with a randomly chosen size from the given range. If range is not specified then (0..100) is used. The edge cases include empty string, a blank string and a unicode string. | โ | โ | โ |

`Arb.stringPattern(pattern)` | Generates strings that match given pattern using Generex | โ | ||

`Exhaustive.azstring(range)` | Returns all A-Z strings in the given range. For example if range was 1..2 then a, b, c, ...., yz, zz would be included. | โ | โ | โ |

`Arb.email(localPartGen, domainGen)` | Generates random emails where the local part and domain part are random strings generated by the given generators. A default value is provided for both. | โ | โ | โ |

`Arb.emailLocalPart()` | Generates random local email parts | โ | โ | โ |

`Arb.uuid(type)` | Generates random UUIDs of the given type | โ | ||

`Arb.domain(tlds, labelArb)` | Generates random domains with a random tld (defaults to any of the top 120 TLDs) and a label generator, which generates domain parts. | โ | โ | โ |

Builders | ||||

`Arb.create(fn)` | Generates values using the supplied function. | โ | โ | โ |

`Arb.bind(arbA, arbB, fn)` | Generates values by pulling a value from each of the two given arbs and then passing those values to the supplied function. | โ | โ | โ |

`Arb.bind(arbA, arbB, arbC, fn)` | Generates values by pulling a value from each of the three given arbs and then passing those values to the supplied function. | โ | โ | โ |

`Arb.bind(arbA, ...., fn)` | Generates values by pulling a value from each of the given arbs and then passing those values to the supplied function. | โ | โ | โ |

Combinatorics | ||||

`Arb.choose(pairs)` | Generates values based on weights. For example, `Arb.choose(1 to 'A', 2 to 'B')` will generate 'A' 33% of the time and 'B' 66% of the time. | โ | โ | โ |

`Arb.frequency(list)` | Alias to choose | โ | โ | โ |

`Arb.shuffle(list)` | Generates random permutations of a list. For example, `Arb.shuffle(listOf(1,2,3))` could generate `listOf(3,1,2)` , `listOf(1,3,2)` and so on. | โ | โ | โ |

`Arb.choice(arbs)` | Randomly selects one of the given arbs and then uses that to generate the next element. | โ | โ | โ |

`Arb.subsequence(list)` | Generates a random subsequence of the given list starting at index 0 and including the empty list. For example, `Arb.subsequence(listOf(1,2,3))` could generate `listOf(1)` , `listOf(1,2)` , and so on. | โ | โ | โ |

Collections | ||||

`Arb.list(gen, range)` | Generates lists where values are generated by the given element generator. The size of each list is determined randomly by the specified range. | โ | โ | โ |

`Arb.set(gen, range)` | Generates sets where values are generated by the given element generator. The size of each set is determined randomly by the specified range. The slippage argument specifies how many attempts will be made to generate each element before erroring, in the case that the underlying arb does not have enough unique values to satisfy the set size. | โ | โ | โ |

`Arb.set(gen, range, slippage)` | Generates sets where values are generated by the given element generator. The size of each set is determined randomly by the specified range. | โ | โ | โ |

`Arb.element(collection)` | Randomly selects one of the elements of the given collection. | โ | โ | โ |

`Arb<T>.chunked(range)` | Generates lists where each list is populated from elements of this receiver. The size of each size is randomly chosen within the given range. | โ | โ | โ |

`Exhaustive.collection(list)` | Enumerates each element of the list one by one. | โ | โ | โ |

Tuples | ||||

`Arb.pair(arb1, arb2)` | Generates `Pair` instances where each value of the pair is drawn from the two provided arbs | โ | โ | โ |

`Arb.triple(arb1, arb2, arb3)` | Generates `Triple` instances where each value of the triple is drawn from the three provided arbs | โ | โ | โ |

Dates | ||||

`Arb.date(ranges)` | Generates random dates with the year between the given range | โ | ||

`Arb.datetime(ranges)` | Generates random date times with the year between the given range | โ | ||

`Arb.localDateTime(ranges)` | Generates random LocalDateTime's with the year between the given range | โ | ||

`Arb.localDate(ranges)` | Generates random LocalDate's with the year between the given range | โ | ||

Kotlinx DateTime | Requires `kotest-property-datetime` module | |||

`Arb.date(yearRange)` | Generates `LocalDate` s with the year between the given range and other fields randomly. | โ | โ | โ |

`Arb.date(yearRange, hourRange, minuteRange, secondRage)` | Generates `LocalDate` s with all fields in the given ranges | โ | โ | โ |

`Arb.instance(range)` | Generates `Instant` s with the epoch randomly generated in the given range | โ | โ | โ |