Skip to content

Commit

Permalink
Add tests for new min/max functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Arvind Maan committed Sep 14, 2020
1 parent 7fd7cb3 commit cfe1c7b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion test/interval.jl
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,17 @@ isinf(::TimeType) = false
end

@testset "accessors" begin
for (a, b, _) in test_values
for (a, b, p) in test_values
for (L, R) in BOUND_PERMUTATIONS
interval = Interval{L, R}(a, b)

@test first(interval) == a
@test last(interval) == b
# the value we compare to min/max depends on if the bound is open/closed
min_comp = a in interval ? first(interval) : first(interval) + p
max_comp = b in interval ? last(interval) : last(interval) - p
@test min(interval; precision=p) == min_comp
@test max(interval; precision=p) == max_comp
@test span(interval) == b - a
@test isclosed(interval) == (L === Closed && R === Closed)
@test isopen(interval) == (L === Open && R === Open)
Expand Down

0 comments on commit cfe1c7b

Please sign in to comment.