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

commonMain.io.kotest.properties.shrinking.StringShrinker.kt Maven / Gradle / Ivy

package io.kotest.properties.shrinking

object StringShrinker : Shrinker {
  override fun shrink(failure: String): List = when (failure.length) {
    0 -> emptyList()
    1 -> listOf("", "a")
    else -> {
      val first = failure.take(failure.length / 2 + failure.length % 2)
      val second = failure.takeLast(failure.length / 2)
      // always include empty string as the best io.kotest.properties.shrinking.shrink
     listOf("", first, first.padEnd(failure.length, 'a'), second, second.padStart(failure.length, 'a'))
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy