Skip to content

Commit

Permalink
add extra deser test
Browse files Browse the repository at this point in the history
  • Loading branch information
PJ Fanning committed Mar 27, 2020
1 parent b9e4605 commit 4c8e18a
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ object CreatorTest
case class ConstructorWithDefaultValues(s: String = "some string", i: Int = 10, dummy: String)

case class ConstructorWithOptionDefaultValues(s: Option[String] = None, i: Option[Int] = None, dummy: String)

case class ConstructorWithOptionSeqDefaultValues(s: Option[Seq[String]] = None)
}


Expand Down Expand Up @@ -129,4 +131,11 @@ class CreatorTest extends DeserializationFixture {
deser2.s shouldEqual Some("passed")
deser2.i shouldEqual Some(5)
}

it should "support optional seqs with default values" in { f =>
val deser = f.readValue[ConstructorWithOptionSeqDefaultValues]("""{}""")
deser.s shouldBe empty
val deser2 = f.readValue[ConstructorWithOptionSeqDefaultValues]("""{"s":["a", "b"]}""")
deser2.s shouldEqual Some(Seq("a", "b"))
}
}

0 comments on commit 4c8e18a

Please sign in to comment.