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

commonMain.io.kotest.matchers.tuples.triples.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  Triple.shouldHaveFirst(a: A) = this should haveTripleFirst(a)
fun  Triple.shouldNotHaveFirst(a: A) = this shouldNot haveTripleFirst(a)
fun  haveTripleFirst(a: A) = object : Matcher> {
   override fun test(value: Triple): MatcherResult {
      return MatcherResult(
         value.first == a,
         "Triple $value should have first value $a but was ${value.first}",
         "Triple $value should not have first value $a"
      )
   }
}

fun  Triple<*, B, *>.shouldHaveSecond(b: B) = this should haveTripleSecond(b)
fun  Triple<*, B, *>.shouldNotHaveSecond(b: B) = this shouldNot haveTripleSecond(b)
fun  haveTripleSecond(b: B) = object : Matcher> {
   override fun test(value: Triple<*, B, *>): MatcherResult {
      return MatcherResult(
         value.second == b,
         "Triple $value should have second value $b but was ${value.second}",
         "Triple $value should not have second value $b"
      )
   }
}


fun  Triple<*, *, C>.shouldHaveThird(c: C) = this should haveTripleThird(c)
fun  Triple<*, *, C>.shouldNotHaveThird(c: C) = this shouldNot haveTripleThird(c)
fun  haveTripleThird(c: C) = object : Matcher> {
   override fun test(value: Triple<*, *, C>): MatcherResult {
      return MatcherResult(
         value.third == c,
         "Triple $value should have third value $c but was ${value.third}",
         "Triple $value should not have third value $c"
      )
   }
}