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): Triple {
   this should haveTripleFirst(a)
   return this
}

fun  Triple.shouldNotHaveFirst(a: A): Triple {
   this shouldNot haveTripleFirst(a)
   return this
}

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): Triple<*, B, *> {
   this should haveTripleSecond(b)
   return this
}

fun  Triple<*, B, *>.shouldNotHaveSecond(b: B): Triple<*, B, *> {
   this shouldNot haveTripleSecond(b)
   return this
}

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): Triple<*, *, C> {
   this should haveTripleThird(c)
   return this
}

fun  Triple<*, *, C>.shouldNotHaveThird(c: C): Triple<*, *, C> {
   this shouldNot haveTripleThird(c)
   return this
}

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"
         })
   }
}