harness.zio.test.AssertionHelpers.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of harness-zio-test_3 Show documentation
Show all versions of harness-zio-test_3 Show documentation
Miscellaneous libraries/utilities for Scala.
package harness.zio.test
import cats.data.NonEmptyList
import zio.test.*
import zio.test.Assertion.*
object AssertionHelpers {
extension [A](self: Assertion[A]) {
def imap[B](name: String)(f: PartialFunction[B, A]): Assertion[B] =
assertionRec[B, A](name)(self)(f.lift(_))
}
extension [A](self: Assertion[Seq[A]]) {
def toNelAssertion: Assertion[NonEmptyList[A]] =
self.imap("NonEmptyList")(_.toList)
}
def assertSeq[A](assertions: Assertion[A]*): Assertion[Seq[A]] =
assertions.toList.zipWithIndex.foldLeft[Assertion[Seq[A]]](
hasSize(equalTo(assertions.size)),
) { case (accum, (a, i)) =>
accum && hasAt(i)(a)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy