Skip to content

Commit

Permalink
Merge pull request #1425 from benpence/daterange_test
Browse files Browse the repository at this point in the history
Requires a DateRange's "end" to be after or on its "start"
  • Loading branch information
benpence committed Aug 18, 2015
2 parents f5ac473 + f22a023 commit 6f40538
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
Expand Up @@ -73,6 +73,7 @@ object DateRange extends java.io.Serializable {
*/
case class DateRange(val start: RichDate, val end: RichDate) {
import DateOps._
require(start <= end, s"""The start "${start}" must be before or on the end "${end}".""")
/**
* shift this by the given unit
*/
Expand Down
Expand Up @@ -174,6 +174,9 @@ class DateTest extends WordSpec {
eachIsDisjoint(DateRange("2010-10-01", "2010-10-03"), Hours(2))
eachIsDisjoint(DateRange("2010-10-01", "2010-10-03"), Minutes(1))
}
"reject an end that is before its start" in {
intercept[IllegalArgumentException] { DateRange("2010-10-02", "2010-10-01") }
}
}
"Time units" should {
def isSame(d1: Duration, d2: Duration) = {
Expand Down

0 comments on commit 6f40538

Please sign in to comment.