Skip to content

Commit

Permalink
Adds some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fcanedo committed Dec 21, 2017
1 parent 7ccaa4f commit a9c118e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/src/test/scala/cats/tests/OptionTSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,23 @@ class OptionTSuite extends CatsSuite {
}
}

test("OptionT[Id, A].getOrElse consistent with Option.getOrElse, with respect to types") {
forAll { (o: Option[Int]) =>
o.map(Right.apply).getOrElse(Left("error")) should === (OptionT[Id, Int](o).map(Right.apply).getOrElse(Left("error")))
}
}

test("OptionT[Id, A].getOrElseF consistent with Option.getOrElse") {
forAll { (o: Option[Int], i: Int) =>
o.getOrElse(i) should === (OptionT[Id, Int](o).getOrElseF(i))
}
}

test("OptionT[Id, A].getOrElseF consistent with Option.getOrElse, with respect to types") {
forAll { (o: Option[Int]) =>
o.map(Right.apply).getOrElse(Left("error")) should === (OptionT[Id, Int](o).map(Right.apply).getOrElseF(Left("error")))
}
}
test("OptionT[Id, A].collect consistent with Option.collect") {
forAll { (o: Option[Int], f: Int => Option[String]) =>
val p = Function.unlift(f)
Expand Down

0 comments on commit a9c118e

Please sign in to comment.