aboutsummaryrefslogtreecommitdiff
path: root/shared/src/test/scala
diff options
context:
space:
mode:
Diffstat (limited to 'shared/src/test/scala')
-rw-r--r--shared/src/test/scala/CoproductTypeFormatTests.scala3
-rw-r--r--shared/src/test/scala/ProductTypeFormatTests.scala24
2 files changed, 26 insertions, 1 deletions
diff --git a/shared/src/test/scala/CoproductTypeFormatTests.scala b/shared/src/test/scala/CoproductTypeFormatTests.scala
index de73967..cd6a2ae 100644
--- a/shared/src/test/scala/CoproductTypeFormatTests.scala
+++ b/shared/src/test/scala/CoproductTypeFormatTests.scala
@@ -54,7 +54,8 @@ class CoproductTypeFormatTests
implicit val crazyFormat: RootJsonFormat[Crazy] = jsonFormat[Crazy]
"GADT with special characters in type field" should behave like checkRoundtrip[
- Crazy](
+ Crazy
+ ](
CrazyType(),
"""{"_`crazy type!`\"": "CrazyType"}"""
)
diff --git a/shared/src/test/scala/ProductTypeFormatTests.scala b/shared/src/test/scala/ProductTypeFormatTests.scala
index 4d71aa3..4c979c0 100644
--- a/shared/src/test/scala/ProductTypeFormatTests.scala
+++ b/shared/src/test/scala/ProductTypeFormatTests.scala
@@ -90,4 +90,28 @@ class ProductTypeFormatTests
assert("{}".parseJson.convertTo[Opt] == Opt(None))
}
+ case class Typed[T](t: T)
+
+ implicit def typed[T: JsonFormat] = jsonFormat[Typed[T]]
+
+ "Class with a type parameter" should behave like checkRoundtrip(
+ Typed[Int](42),
+ """{"t":42}"""
+ )
+
+ "Class with nested types" should behave like checkRoundtrip(
+ Typed[Typed[String]](Typed("hello world")),
+ """{"t":{"t":"hello world"}}"""
+ )
+
+ case class Phantom[T](x: Int)
+
+ // no json format required for T
+ implicit def phantom[T] = jsonFormat[Phantom[T]]
+
+ "Phantom types without a format" should behave like checkRoundtrip(
+ Phantom[Int => String](42), // the given type parameter should not have a format
+ """{"x":42}"""
+ )
+
}