diff options
author | Mathias <mathias@spray.io> | 2015-05-06 11:23:00 +0200 |
---|---|---|
committer | Mathias <mathias@spray.io> | 2015-05-06 12:41:50 +0200 |
commit | 51e1af64175e1c01a0383e6018839fc374bca164 (patch) | |
tree | 0c3ac727a0bd96b4de1fde286dcfcf0b51901b36 /src/test/scala/spray | |
parent | 45672ff730516dd28416cb3a5f5c2c8be1d3e0b5 (diff) | |
download | spray-json-51e1af64175e1c01a0383e6018839fc374bca164.tar.gz spray-json-51e1af64175e1c01a0383e6018839fc374bca164.tar.bz2 spray-json-51e1af64175e1c01a0383e6018839fc374bca164.zip |
Improve name unmangling in ProductFormats, closes #138
Diffstat (limited to 'src/test/scala/spray')
-rw-r--r-- | src/test/scala/spray/json/ProductFormatsSpec.scala | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/test/scala/spray/json/ProductFormatsSpec.scala b/src/test/scala/spray/json/ProductFormatsSpec.scala index ba9d907..ebfcec9 100644 --- a/src/test/scala/spray/json/ProductFormatsSpec.scala +++ b/src/test/scala/spray/json/ProductFormatsSpec.scala @@ -29,7 +29,7 @@ class ProductFormatsSpec extends Specification { } @SerialVersionUID(1L) // SerialVersionUID adds a static field to the case class case class TestStatic(a: Int, b: Option[Double]) - case class TestMangled(`foo-bar!`: Int) + case class TestMangled(`foo-bar!`: Int, `User ID`: String, `üt$bavef$u56úrógép`: Boolean) trait TestProtocol { this: DefaultJsonProtocol => @@ -39,7 +39,7 @@ class ProductFormatsSpec extends Specification { implicit def test4Format = jsonFormat1(Test4) implicit def testTransientFormat = jsonFormat2(TestTransient) implicit def testStaticFormat = jsonFormat2(TestStatic) - implicit def testMangledFormat = jsonFormat1(TestMangled) + implicit def testMangledFormat = jsonFormat3(TestMangled) } object TestProtocol1 extends DefaultJsonProtocol with TestProtocol object TestProtocol2 extends DefaultJsonProtocol with TestProtocol with NullOptions @@ -198,12 +198,12 @@ class ProductFormatsSpec extends Specification { "A JsonFormat created with `jsonFormat`, for a case class with mangled-name members," should { import TestProtocol1._ - val json = "{\"foo-bar!\":42}" + val json = """{"foo-bar!":42,"User ID":"Karl","üt$bavef$u56úrógép":true}""" "produce the correct JSON" in { - TestMangled(42).toJson.compactPrint === json + TestMangled(42, "Karl", true).toJson.compactPrint === json } "convert a JsObject to the respective case class instance" in { - json.parseJson.convertTo[TestMangled] === TestMangled(42) + json.parseJson.convertTo[TestMangled] === TestMangled(42, "Karl", true) } } } |