diff options
author | vlad <vlad@drivergrp.com> | 2016-10-21 16:07:05 -0400 |
---|---|---|
committer | vlad <vlad@drivergrp.com> | 2016-10-21 16:07:05 -0400 |
commit | 02810f5eac3b4ce6a5d1128281a01b2a2ed0647c (patch) | |
tree | a733b421759216a7f12d227d2f912eecdfa842aa /src/test/scala/com/drivergrp/core/TimeTest.scala | |
parent | 7c77f5ff23e4b0f8d5e189492bc4f25f847adc00 (diff) | |
download | driver-core-02810f5eac3b4ce6a5d1128281a01b2a2ed0647c.tar.gz driver-core-02810f5eac3b4ce6a5d1128281a01b2a2ed0647c.tar.bz2 driver-core-02810f5eac3b4ce6a5d1128281a01b2a2ed0647c.zip |
Renamed package to xyz, New formatting, authorize directive supporting multiple permissions
Diffstat (limited to 'src/test/scala/com/drivergrp/core/TimeTest.scala')
-rw-r--r-- | src/test/scala/com/drivergrp/core/TimeTest.scala | 87 |
1 files changed, 0 insertions, 87 deletions
diff --git a/src/test/scala/com/drivergrp/core/TimeTest.scala b/src/test/scala/com/drivergrp/core/TimeTest.scala deleted file mode 100644 index b928413..0000000 --- a/src/test/scala/com/drivergrp/core/TimeTest.scala +++ /dev/null @@ -1,87 +0,0 @@ -package com.drivergrp.core - -import java.util.TimeZone - -import com.drivergrp.core.time.{Time, _} -import org.scalacheck.{Arbitrary, Gen} -import org.scalatest.{FlatSpec, Matchers} -import org.scalatest.prop.Checkers -import org.scalacheck.Arbitrary._ -import org.scalacheck.Prop.BooleanOperators - -import scala.concurrent.duration._ - -class TimeTest extends FlatSpec with Matchers with Checkers { - - implicit val arbitraryDuration = Arbitrary[Duration](Gen.chooseNum(0L, 9999999999L).map(_.milliseconds)) - implicit val arbitraryTime = Arbitrary[Time](Gen.chooseNum(0L, 9999999999L).map(millis => Time(millis))) - - "Time" should "have correct methods to compare" in { - - Time(234L).isAfter(Time(123L)) should be(true) - Time(123L).isAfter(Time(123L)) should be(false) - Time(123L).isAfter(Time(234L)) should be(false) - - check((a: Time, b: Time) => (a.millis > b.millis) ==> a.isAfter(b)) - - Time(234L).isBefore(Time(123L)) should be(false) - Time(123L).isBefore(Time(123L)) should be(false) - Time(123L).isBefore(Time(234L)) should be(true) - - check { (a: Time, b: Time) => - (a.millis < b.millis) ==> a.isBefore(b) - } - } - - it should "not modify time" in { - - Time(234L).millis should be(234L) - - check { millis: Long => - Time(millis).millis == millis - } - } - - it should "support arithmetic with scala.concurrent.duration" in { - - Time(123L).advanceBy(0 minutes).millis should be(123L) - Time(123L).advanceBy(1 second).millis should be(123L + Second) - Time(123L).advanceBy(4 days).millis should be(123L + 4 * Days) - - check { (time: Time, duration: Duration) => - time.advanceBy(duration).millis == (time.millis + duration.toMillis) - } - } - - it should "have ordering defined correctly" in { - - Seq(Time(321L), Time(123L), Time(231L)).sorted should - contain theSameElementsInOrderAs Seq(Time(123L), Time(231L), Time(321L)) - - check { times: List[Time] => - times.sorted.sliding(2).filter(_.size == 2).forall { - case Seq(a, b) => - a.millis <= b.millis - } - } - } - - it should "reset to the start of the period, e.g. month" in { - - startOfMonth(Time(1468937089834L)) should be(Time(1467381889834L)) - startOfMonth(Time(1467381889834L)) should be(Time(1467381889834L)) // idempotent - } - - it should "have correct textual representations" in { - - textualDate(TimeZone.getTimeZone("EDT"))(Time(1468937089834L)) should be("July 19, 2016") - textualTime(TimeZone.getTimeZone("PDT"))(Time(1468937089834L)) should be("Jul 19, 2016 02:04:49 PM") - } - - "TimeRange" should "have duration defined as a difference of start and end times" in { - - TimeRange(Time(321L), Time(432L)).duration should be(111.milliseconds) - TimeRange(Time(432L), Time(321L)).duration should be((-111).milliseconds) - TimeRange(Time(333L), Time(333L)).duration should be(0.milliseconds) - } -} |