diff options
author | Hao Huang <hhuang@driver.xyz> | 2017-02-10 16:29:28 -0800 |
---|---|---|
committer | Hao Huang <hhuang@driver.xyz> | 2017-02-10 16:29:28 -0800 |
commit | c67fb0d8e6779191620d5485f21003a2a0d9573d (patch) | |
tree | ca84f159d76ea6e751caa5f06afa64acff4ca837 | |
parent | 1e65b8ad5967d41dc56d7dce015f4bb6c1af26dd (diff) | |
download | driver-core-c67fb0d8e6779191620d5485f21003a2a0d9573d.tar.gz driver-core-c67fb0d8e6779191620d5485f21003a2a0d9573d.tar.bz2 driver-core-c67fb0d8e6779191620d5485f21003a2a0d9573d.zip |
Move time/date related tests out of CoreTest
-rw-r--r-- | src/test/scala/xyz/driver/core/CoreTest.scala | 28 | ||||
-rw-r--r-- | src/test/scala/xyz/driver/core/DateTest.scala | 10 | ||||
-rw-r--r-- | src/test/scala/xyz/driver/core/TimeTest.scala | 16 |
3 files changed, 26 insertions, 28 deletions
diff --git a/src/test/scala/xyz/driver/core/CoreTest.scala b/src/test/scala/xyz/driver/core/CoreTest.scala index 08b1df2..bb4742a 100644 --- a/src/test/scala/xyz/driver/core/CoreTest.scala +++ b/src/test/scala/xyz/driver/core/CoreTest.scala @@ -63,34 +63,6 @@ class CoreTest extends FlatSpec with Matchers with MockitoSugar { (xid: Id[X]) should be(zid: Id[Z]) } - "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) - } - - "Date" should "correctly convert to and from String" in { - - import xyz.driver.core.generators.nextDate - import date._ - - for (date <- 1 to 100 map (_ => nextDate())) { - Some(date) should be(Date.fromString(date.toString)) - } - } - "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/DateTest.scala b/src/test/scala/xyz/driver/core/DateTest.scala index 50f8521..dc9bca3 100644 --- a/src/test/scala/xyz/driver/core/DateTest.scala +++ b/src/test/scala/xyz/driver/core/DateTest.scala @@ -13,6 +13,16 @@ class DateTest extends FlatSpec with Matchers with Checkers { } yield Date(year, date.tagMonth(month), day) implicit val arbitraryDate = Arbitrary[Date](dateGenerator) + "Date" should "correctly convert to and from String" in { + + import xyz.driver.core.generators.nextDate + import date._ + + for (date <- 1 to 100 map (_ => nextDate())) { + Some(date) should be(Date.fromString(date.toString)) + } + } + it should "have ordering defined correctly" in { Seq(Date.fromString("2013-05-10"), Date.fromString("2020-02-15"), diff --git a/src/test/scala/xyz/driver/core/TimeTest.scala b/src/test/scala/xyz/driver/core/TimeTest.scala index 76ef42c..b83137c 100644 --- a/src/test/scala/xyz/driver/core/TimeTest.scala +++ b/src/test/scala/xyz/driver/core/TimeTest.scala @@ -84,4 +84,20 @@ class TimeTest extends FlatSpec with Matchers with Checkers { TimeRange(Time(432L), Time(321L)).duration should be((-111).milliseconds) TimeRange(Time(333L), Time(333L)).duration should be(0.milliseconds) } + + "Time" should "use TimeZone correctly when converting to Date" in { + + 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) + } } |