Skip to content

Commit

Permalink
either tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pjfanning committed Oct 7, 2023
1 parent 9c03646 commit 1c2db2b
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@ class EitherDeserializerTest extends DeserializerTest with EitherJsonTestSupport
deserialize(s"""{"left":null}""", typeRef) should be (Left(None))
}

it should "be able to deserialize right with Some value" in {
val typeRef = new TypeReference[Either[_, Option[String]]] {}
deserialize(s"""{"r":"$str"}""", typeRef) should be(Right(Some(str)))
deserialize(s"""{"right":"$str"}""", typeRef) should be(Right(Some(str)))
}

it should "be able to deserialize left with Some value" in {
val typeRef = new TypeReference[Either[Option[String], _]] {}
deserialize(s"""{"l":"$str"}""", typeRef) should be(Left(Some(str)))
deserialize(s"""{"left":"$str"}""", typeRef) should be(Left(Some(str)))
}

it should "be able to deserialize Right with complex objects" in {
val typeRef = new TypeReference[Either[String, PlainPojoObject]] {}
deserialize(s"""{"r":${serialize(obj)}}""", typeRef) should be (Right(obj))
Expand Down

0 comments on commit 1c2db2b

Please sign in to comment.