
commonMain.io.kotest.matchers.tuples.pairs.kt Maven / Gradle / Ivy
package io.kotest.matchers.tuples
import io.kotest.matchers.Matcher
import io.kotest.matchers.MatcherResult
import io.kotest.matchers.should
import io.kotest.matchers.shouldNot
fun Pair.shouldHaveFirst(a: A) = this should haveFirst(a)
fun Pair.shouldNotHaveFirst(a: A) = this shouldNot haveFirst(a)
fun haveFirst(a: A) = object : Matcher> {
override fun test(value: Pair): MatcherResult {
return MatcherResult(
value.first == a,
"Pair $value should have first value $a but was ${value.first}",
"Pair $value should not have first value $a"
)
}
}
fun Pair<*, B>.shouldHaveSecond(b: B) = this should haveSecond(b)
fun Pair<*, B>.shouldNotHaveSecond(b: B) = this shouldNot haveSecond(b)
fun haveSecond(b: B) = object : Matcher> {
override fun test(value: Pair<*, B>): MatcherResult {
return MatcherResult(
value.second == b,
"Pair $value should have second value $b but was ${value.second}",
"Pair $value should not have second value $b"
)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy