aboutsummaryrefslogtreecommitdiff
path: root/src/test/scala/FormatTests.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/scala/FormatTests.scala')
-rw-r--r--src/test/scala/FormatTests.scala20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/test/scala/FormatTests.scala b/src/test/scala/FormatTests.scala
new file mode 100644
index 0000000..e29e49f
--- /dev/null
+++ b/src/test/scala/FormatTests.scala
@@ -0,0 +1,20 @@
+package xyz.driver.json
+
+import spray.json._
+import org.scalatest._
+
+trait FormatTests { self: FlatSpec =>
+
+ def checkCoherence[A: JsonFormat](a: A, expectedJson: String) = {
+ it should "serialize to the expected JSON value" in {
+ val expected: JsValue = expectedJson.parseJson
+ assert(a.toJson == expected)
+ }
+
+ it should "serialize then deserialize back to itself" in {
+ val reread = a.toJson.convertTo[A]
+ assert(reread == a)
+ }
+ }
+
+}