intEnumTests

fun <E : Enum<E>> intEnumTests(describeName: String = "fromValueOrNull", dataNameFn: (Map.Entry<EnumMapEntry<Int>, E>) -> String = { "${it.key.propertyName}: ${it.value}" }, enumValuesMap: Map<EnumMapEntry<Int>, E>, fromValueOrNullFn: (Int) -> E?, invalidArb: Arb<Int> = Arb.int() .filterNot { output -> output in enumValuesMap.map { it.key.value } }): TestFactory(source)

Test factory to create tests for the given enum that is represented by an Int for its internal value.

This method is an alias for enumTests with the following defaults:

  • InternalValue is represented by an Int

  • invalidArb is specified with an Arb<Int>

Since

0.1.0

Parameters

E

The enum.

describeName

Descriptive name to be passed to the top-level describe() function.

dataNameFn

Function to be used for withData's nameFn.

enumValuesMap

The map of internal values to their enum representation.

fromValueOrNullFn

Function used to convert the internal value to its enum representation.

invalidArb

Arbitrary used to output invalid internal values. This is used to test that the invalid values from this arbitrary returns null from fromValueOrNullFn.


@JvmName(name = "intEnumTestsReflection")
fun <E : Enum<E>> intEnumTests(describeName: String = "fromValueOrNull", dataNameFn: (Map.Entry<EnumMapEntry<Int>, E>) -> String = { "${it.key.propertyName}: ${it.value}" }, enumValuesMap: Map<KProperty0<Int>, E>, fromValueOrNullFn: (Int) -> E?, invalidArb: Arb<Int> = Arb.int() .filterNot { output -> output in enumValuesMap.map { it.key.get() } }): TestFactory(source)

Test factory to create tests for the given enum that is represented by an Int for its internal value.

This method is an alias for enumTests with the following defaults:

Since

0.1.0

Parameters

E

The enum.

describeName

Descriptive name to be passed to the top-level describe() function.

dataNameFn

Function to be used for withData's nameFn.

enumValuesMap

The map of internal values to their enum representation.

fromValueOrNullFn

Function used to convert the internal value to its enum representation.

invalidArb

Arbitrary used to output invalid internal values. This is used to test that the invalid values from this arbitrary returns null from fromValueOrNullFn.