Skip to content

Commit

Permalink
few more tests on Dates
Browse files Browse the repository at this point in the history
  • Loading branch information
felipenoris committed Jul 27, 2015
1 parent 22c86f6 commit 6fb6699
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test/dates/adjusters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,8 @@ januarymondays2014 = [Dates.Date(2014,1,6),Dates.Date(2014,1,13),Dates.Date(2014
@test Dates.recur(x->!Dates.ismonday(x),startdate,stopdate;negate=true) == januarymondays2014

@test_throws ArgumentError Dates.recur((x,y)->x+y,Dates.Date(2013):Dates.Date(2014))
@test_throws ArgumentError Dates.DateFunction((x,y)->x+y, false, Date(0))
@test_throws ArgumentError Dates.DateFunction((dt)->2, false, Date(0))
@test length(Dates.recur(x->true,Dates.Date(2013):Dates.Date(2013,2))) == 32
@test length(Dates.recur(x->true,Dates.Date(2013):Dates.Date(2013,1,1))) == 1
@test length(Dates.recur(x->true,Dates.Date(2013):Dates.Date(2013,1,2))) == 2
Expand Down
6 changes: 6 additions & 0 deletions test/dates/periods.jl
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ y2 = Dates.Year(2)
@test typeof(y+ms) <: Dates.CompoundPeriod
@test y > m
@test d < w
@test mi < h
@test ms < h
@test ms < mi
@test typemax(Dates.Year) == Dates.Year(typemax(Int64))
@test typemax(Dates.Year) + y == Dates.Year(-9223372036854775808)
@test typemin(Dates.Year) == Dates.Year(-9223372036854775808)
Expand Down Expand Up @@ -283,8 +286,10 @@ dt = Dates.DateTime(2014)
@test 1ms - (2s + 7ms) == -((2s + 7ms) - 1ms) == (-6ms) - 2s
emptyperiod = ((y + d) - d) - y
@test emptyperiod == ((d + y) - y) - d == ((d + y) - d) - y
@test emptyperiod == 2y + (m - d) + ms - ((m - d) + 2y + ms)
@test emptyperiod == 0ms
@test string(emptyperiod) == "empty period"
@test string(ms + mi + d + m + y + w + h + s + 2y + m) == "3 years, 2 months, 1 week, 1 day, 1 hour, 1 minute, 1 second, 1 millisecond"
@test 8d - s == 1w + 23h + 59mi + 59s
@test h + 3mi == 63mi
@test y - m == 11m
Expand Down Expand Up @@ -337,6 +342,7 @@ cpa = [1y+1s 1m+1s 1w+1s 1d+1s; 1h+1s 1mi+1s 2m+1s 1s+1ms]

@test [1y 1m; 1w 1d] + [1h 1mi; 1s 1ms] == [1y+1h 1m+1mi; 1w+1s 1d+1ms]
@test [1y 1m; 1w 1d] - [1h 1mi; 1s 1ms] == [1y-1h 1m-1mi; 1w-1s 1d-1ms]
@test [1y 1m; 1w 1d] - [1h 1mi; 1s 1ms] - [1y-1h 1m-1mi; 1w-1s 1d-1ms] == [emptyperiod emptyperiod; emptyperiod emptyperiod]

@test [1y+1s 1m+1s; 1w+1s 1d+1s] + [1h 1mi; 1s 1ms] == [1y+1h+1s 1m+1mi+1s; 1w+2s 1d+1s+1ms]
@test [1y+1s 1m+1s; 1w+1s 1d+1s] - [1h 1mi; 1s 1ms] == [1y-1h+1s 1m-1mi+1s; 1w 1d+1s-1ms]
Expand Down

0 comments on commit 6fb6699

Please sign in to comment.