commonMain.io.gianluigip.spectacle.dsl.assertions.StringAssertionsExtensions.kt Maven / Gradle / Ivy
The newest version!
package io.gianluigip.spectacle.dsl.assertions
import kotlin.test.assertTrue
private val Any?.expectedTo get() = "Expected '$this' to"
@AssertionDslMarker
infix fun String?.shouldStartWith(value: String?) =
assertTrue(this?.startsWith(value ?: "") ?: false, "$expectedTo start with '$value'")
@AssertionDslMarker
infix fun String?.shouldEndWith(value: String?) =
assertTrue(this?.endsWith(value ?: "") ?: false, "$expectedTo end with '$value'")
@AssertionDslMarker
infix fun String?.shouldContains(value: String) =
assertTrue((this ?: "").contains(value), "$expectedTo contains '$value'")
@AssertionDslMarker
fun String?.shouldNotBeEmpty() =
assertTrue(this?.isNotEmpty() ?: false, "$expectedTo be not empty")
@AssertionDslMarker
fun String?.shouldBeEmpty() =
assertTrue(this?.isEmpty() ?: false, "$expectedTo be empty")