diff options
Diffstat (limited to 'src/test/scala')
-rw-r--r-- | src/test/scala/ProductTypeFormatTests.scala | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/test/scala/ProductTypeFormatTests.scala b/src/test/scala/ProductTypeFormatTests.scala index ce05000..d602ff4 100644 --- a/src/test/scala/ProductTypeFormatTests.scala +++ b/src/test/scala/ProductTypeFormatTests.scala @@ -74,4 +74,21 @@ class ProductTypeFormatTests """{"h": {"x":true}}""" ) + case class Opt(x: Option[Int]) + implicit val ofmt = jsonFormat[Opt] + + "Optional fields with some value" should behave like checkRoundtrip( + Opt(Some(2)), + """{"x":2}""" + ) + + "Optional fields with no value (null)" should behave like checkRoundtrip( + Opt(None), + """{"x":null}""" + ) + + "Optional fields with no value (undefined)" should "deserialize" in { + assert("{}".parseJson.convertTo[Opt] == Opt(None)) + } + } |