All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jsMain.io.kotest.properties.default.kt Maven / Gradle / Ivy

package io.kotest.properties

actual inline fun  Gen.Companion.default(): Gen {
  val classname = T::class.simpleName ?: ""
  return forClassName(classname) as Gen
}

fun forClassName(className: String): Gen<*> {
  return when (className) {
    "java.lang.String", "kotlin.String", "String" -> Gen.string()
    "java.lang.Integer", "kotlin.Int", "Int" -> Gen.int()
    "java.lang.Short", "kotlin.Short", "Short" -> Gen.short()
    "java.lang.Byte", "kotlin.Byte", "Byte" -> Gen.byte()
    "java.lang.Long", "kotlin.Long", "Long" -> Gen.long()
    "java.lang.Boolean", "kotlin.Boolean", "Boolean" -> Gen.bool()
    "java.lang.Float", "kotlin.Float", "Float" -> Gen.float()
    "java.lang.Double", "kotlin.Double", "Double" -> Gen.double()
    else -> throw IllegalArgumentException("Cannot infer generator for $className; specify generators explicitly")
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy