aboutsummaryrefslogtreecommitdiff
path: root/src/test/scala/xyz
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/scala/xyz')
-rw-r--r--src/test/scala/xyz/driver/core/CoreTest.scala18
-rw-r--r--src/test/scala/xyz/driver/core/JsonTest.scala16
2 files changed, 34 insertions, 0 deletions
diff --git a/src/test/scala/xyz/driver/core/CoreTest.scala b/src/test/scala/xyz/driver/core/CoreTest.scala
index da9fd9a..e210887 100644
--- a/src/test/scala/xyz/driver/core/CoreTest.scala
+++ b/src/test/scala/xyz/driver/core/CoreTest.scala
@@ -60,6 +60,24 @@ class CoreTest extends FlatSpec with Matchers with MockitoSugar {
(y2 === y) should be(true)
}
+ "Time" should "use TimeZone correctly when converting to Date" in {
+
+ import time._
+
+ val EST = java.util.TimeZone.getTimeZone("EST")
+ val PST = java.util.TimeZone.getTimeZone("PST")
+
+ val timestamp = {
+ import java.util.Calendar
+ val cal = Calendar.getInstance(EST)
+ cal.set(Calendar.HOUR_OF_DAY, 1)
+ Time(cal.getTime().getTime())
+ }
+
+ textualDate(EST)(timestamp) should not be textualDate(PST)(timestamp)
+ timestamp.toDate(EST) should not be timestamp.toDate(PST)
+ }
+
"Name" should "have equality and ordering working correctly" in {
(Name[String]("foo") === Name[String]("foo")) should be(true)
diff --git a/src/test/scala/xyz/driver/core/JsonTest.scala b/src/test/scala/xyz/driver/core/JsonTest.scala
index eb8d5d8..821b162 100644
--- a/src/test/scala/xyz/driver/core/JsonTest.scala
+++ b/src/test/scala/xyz/driver/core/JsonTest.scala
@@ -42,6 +42,22 @@ class JsonTest extends FlatSpec with Matchers {
parsedTime should be(referenceTime)
}
+ "Json format for Date" should "read and write correct JSON" in {
+ import date._
+
+ val referenceDate = Date(1941, Month.DECEMBER, 7)
+
+ val writtenJson = json.dateFormat.write(referenceDate)
+ writtenJson.prettyPrint should be("""|{
+ | "year": 1941,
+ | "month": 11,
+ | "day": 7
+ |}""".stripMargin)
+
+ val parsedDate = json.dateFormat.read(writtenJson)
+ parsedDate should be(referenceDate)
+ }
+
"Json format for Revision" should "read and write correct JSON" in {
val referenceRevision = Revision[String]("037e2ec0-8901-44ac-8e53-6d39f6479db4")