aboutsummaryrefslogtreecommitdiff
path: root/src/test/scala/ImplicitDerivedFormatTests.scala
blob: 1d54ae967520d42c5c543e8b4d6f1c172073cdbd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package spray.json

import org.scalatest._

class ImplicitDerivedFormatTests
    extends FlatSpec
    with FormatTests
    with ImplicitDerivedFormats
    with DefaultJsonProtocol {

  case class B(x: Int, b: String, mp: Map[String, Int])
  case class C(b: B)

  "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 with custom child format" 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 } } }"""
  )

}