aboutsummaryrefslogtreecommitdiff
path: root/src/test/scala/ProductTypeFormats.scala
diff options
context:
space:
mode:
authorJakob Odersky <jakob@odersky.com>2018-03-08 16:13:03 -0800
committerJakob Odersky <jakob@odersky.com>2018-03-08 16:21:49 -0800
commit5ef502abc058358ec3a329c774bb42b9a7bd106f (patch)
treeee5c20fa79307e1a8397a86f31fbe54cbfe9fe1a /src/test/scala/ProductTypeFormats.scala
parenteb1ad3c956c828d421b7650dd3b01d5129a41a3d (diff)
downloadspray-json-derivation-5ef502abc058358ec3a329c774bb42b9a7bd106f.tar.gz
spray-json-derivation-5ef502abc058358ec3a329c774bb42b9a7bd106f.tar.bz2
spray-json-derivation-5ef502abc058358ec3a329c774bb42b9a7bd106f.zip
Don't ake derived formats implicit by defaultv0.3.0
Diffstat (limited to 'src/test/scala/ProductTypeFormats.scala')
-rw-r--r--src/test/scala/ProductTypeFormats.scala54
1 files changed, 0 insertions, 54 deletions
diff --git a/src/test/scala/ProductTypeFormats.scala b/src/test/scala/ProductTypeFormats.scala
deleted file mode 100644
index 02fb554..0000000
--- a/src/test/scala/ProductTypeFormats.scala
+++ /dev/null
@@ -1,54 +0,0 @@
-package xyz.driver.json
-
-import spray.json._
-
-import org.scalatest._
-
-class ProductTypeFormats
- extends FlatSpec
- with FormatTests
- with DerivedFormats
- with DefaultJsonProtocol {
-
- case class A()
- case class B(x: Int, b: String, mp: Map[String, Int])
- case class C(b: B)
- case object D
- case class E(d: D.type)
- case class F(x: Int)
-
- "No-parameter product" should behave like checkRoundtrip(A(), "{}")
-
- "Simple parameter product" should behave like checkRoundtrip(
- B(42, "Hello World", Map("a" -> 1, "b" -> -1024)),
- """{ "x": 42, "b": "Hello World", "mp": { "a": 1, "b": -1024 } }"""
- )
-
- "Nested parameter product" should behave like checkRoundtrip(
- C(B(42, "Hello World", Map("a" -> 1, "b" -> -1024))),
- """{"b" :{ "x": 42, "b": "Hello World", "mp": { "a": 1, "b": -1024 } } }"""
- )
-
- "Case object" should behave like checkRoundtrip(
- D,
- "{}"
- )
-
- "Case object as parameter" should behave like checkRoundtrip(
- E(D),
- """{"d":{}}"""
- )
-
- // custom format for F, that inverts the value of parameter x
- implicit val fFormat: RootJsonFormat[F] = new RootJsonFormat[F] {
- override def write(f: F): JsValue = JsObject("x" -> JsNumber(-f.x))
- override def read(js: JsValue): F =
- F(-js.asJsObject.fields("x").convertTo[Int])
- }
-
- "Overriding with a custom format" should behave like checkRoundtrip(
- F(2),
- """{"x":-2}"""
- )
-
-}