
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): Pair {
this should haveFirst(a)
return this
}
fun Pair.shouldNotHaveFirst(a: A): Pair {
this shouldNot haveFirst(a)
return this
}
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): Pair<*, B> {
this should haveSecond(b)
return this
}
fun Pair<*, B>.shouldNotHaveSecond(b: B): Pair<*, B> {
this shouldNot haveSecond(b)
return this
}
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