diff --git a/tests/src/test/scala/cats/tests/OptionTSuite.scala b/tests/src/test/scala/cats/tests/OptionTSuite.scala index d3b7eea447..8e9388045e 100644 --- a/tests/src/test/scala/cats/tests/OptionTSuite.scala +++ b/tests/src/test/scala/cats/tests/OptionTSuite.scala @@ -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)