Skip to content

Commit 27aad6e

Browse files
committed
Add tests for Date conversion
1 parent f4d716a commit 27aad6e

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

test/anchoredinterval.jl

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,26 @@ using Intervals: canonicalize
3737
end
3838

3939
@testset "conversion" begin
40-
he = HourEnding(dt)
41-
hb = HourBeginning(dt)
42-
@test DateTime(he) == dt
43-
@test DateTime(hb) == dt
44-
@test convert(Interval, he) == Interval(dt - Hour(1), dt, Inclusivity(false, true))
45-
@test convert(Interval, hb) == Interval(dt, dt + Hour(1), Inclusivity(true, false))
46-
@test Interval(he) == Interval(dt - Hour(1), dt, Inclusivity(false, true))
47-
@test Interval(hb) == Interval(dt, dt + Hour(1), Inclusivity(true, false))
48-
@test Interval{DateTime}(he) == Interval(dt - Hour(1), dt, Inclusivity(false, true))
49-
@test Interval{DateTime}(hb) == Interval(dt, dt + Hour(1), Inclusivity(true, false))
40+
@testset "Date" begin
41+
d = Date(dt)
42+
de = AnchoredInterval{Day(-1)}(d
43+
db = AnchoredInterval{Day(1)}(d)
44+
@test Date(de) == d
45+
@test Date(db) == d
46+
end
47+
48+
@testset "DateTime" begin
49+
he = HourEnding(dt)
50+
hb = HourBeginning(dt)
51+
@test DateTime(he) == dt
52+
@test DateTime(hb) == dt
53+
@test convert(Interval, he) == Interval(dt - Hour(1), dt, false, true)
54+
@test convert(Interval, hb) == Interval(dt, dt + Hour(1), true, false)
55+
@test Interval(he) == Interval(dt - Hour(1), dt, false, true)
56+
@test Interval(hb) == Interval(dt, dt + Hour(1), true, false)
57+
@test Interval{DateTime}(he) == Interval(dt - Hour(1), dt, false, true)
58+
@test Interval{DateTime}(hb) == Interval(dt, dt + Hour(1), true, false)
59+
end
5060
end
5161

5262
@testset "accessors" begin

0 commit comments

Comments
 (0)