# 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.char(List<CharRange>)` | Returns chars distributed across the lists of chars. For example, `Arb.char(listOf('A'..'C', 'X'..'Z'))` will generate values of A, B, C, X, Y, Z with equal probability. | |||

`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. | âœ“ | âœ“ | âœ“ |

Constants | ||||

`Arb.constant(t)` | Returns an `Arb` that always returns `t` | âœ“ | âœ“ | âœ“ |

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.nonNegativeInt(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.nonPositiveInt(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. | âœ“ | âœ“ | âœ“ |

Regional | ||||

`Arb.locale()` | Generates locales in the Java format, eg `en_US` or `ca_ES_VALENCIA` . | âœ“ | âœ“ | âœ“ |

`Arb.timezoneCodeThree()` | Generates timezones in the format ABC, for example BST or EST. Does not include all possible timezones, and is only used for sampling data. | âœ“ | âœ“ | âœ“ |

`Arb.geoLocation()` | Generates `GeoLocation` objects with random latitude/longitude points uniformly distributed on the globe. | âœ“ | âœ“ | âœ“ |

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 RgxGen | âœ“ | ||

`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.choice(arbs)` | Randomly selects one of the given arbs and then uses that to generate the next element. | âœ“ | âœ“ | âœ“ |

`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.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.element(collection)` | Randomly selects one of the elements of the given collection. | âœ“ | âœ“ | âœ“ |

`Arb.element(vararg T)` | Randomly selects one of the elements from the varargs. | âœ“ | âœ“ | âœ“ |

`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<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. | âœ“ | âœ“ | âœ“ |

`Arb<T>.chunked(minSize, maxSize)` | Generates lists where each list is populated from elements of this receiver. The size of each size is randomly chosen within the given range parameters. | âœ“ | âœ“ | âœ“ |

`Exhaustive.collection(list)` | Enumerates each element of the list one by one. | âœ“ | âœ“ | âœ“ |

Maps | ||||

`Arb.map(Arb<Pair<K,V>>, minSize, maxSize)` | Generates random maps, each one with a size between minSize and maxSize, and each element generated from the given Pair arb. | âœ“ | âœ“ | âœ“ |

`Arb.map(Arb<K>, Arb<V>, minSize, maxSize)` | Generates random maps, each one with a size between minSize and maxSize, and each key generated from the given key arb and each value generated from the given value arb. | âœ“ | âœ“ | âœ“ |

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 | âœ“ | ||

Durations | ||||

`Arb.duration(ranges)` | Generates random durations in the given range. | âœ“ | âœ“ | âœ“ |

Kotlinx DateTime | Requires `io.kotest.extensions:kotest-property-datetime` module | |||

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

`Arb.datetime(yearRange, hourRange, minuteRange, secondRage)` | Generates `LocalDateTime` s with all fields in the given ranges | âœ“ | âœ“ | âœ“ |

`Arb.instant(range)` | Generates `Instant` s with the epoch randomly generated in the given range | âœ“ | âœ“ | âœ“ |

Networking | ||||

`Arb.ipAddressV4()` | Generates random IP addresses in the format a.b.c.d, where each part is between 0 and 255. | âœ“ | âœ“ | âœ“ |