
commonMain.io.kotest.matchers.string.case.kt Maven / Gradle / Ivy
package io.kotest.matchers.string
import io.kotest.assertions.print.print
import io.kotest.matchers.Matcher
import io.kotest.matchers.MatcherResult
import io.kotest.matchers.neverNullMatcher
import io.kotest.matchers.should
import io.kotest.matchers.shouldNot
fun A?.shouldBeUpperCase(): A {
this should beUpperCase()
return this!!
}
fun A?.shouldNotBeUpperCase(): A {
this shouldNot beUpperCase()
return this!!
}
fun beUpperCase(): Matcher = neverNullMatcher { value ->
MatcherResult(
value.toString().uppercase() == value,
{ "${value.print().value} should be upper case" },
{
"${value.print().value} should not should be upper case"
})
}
fun A.shouldBeLowerCase(): A {
this should beLowerCase()
return this
}
fun A.shouldNotBeLowerCase(): A {
this shouldNot beLowerCase()
return this
}
fun beLowerCase(): Matcher = neverNullMatcher { value ->
MatcherResult(
value.toString().lowercase() == value,
{ "${value.print().value} should be lower case" },
{
"${value.print().value} should not should be lower case"
})
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy