Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/sets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,10 @@
upper::T
end

function Interval(lower::Real, upper::Real)
return Interval(promote(lower, upper)...)

Check warning on line 290 in src/sets.jl

View check run for this annotation

Codecov / codecov/patch

src/sets.jl#L289-L290

Added lines #L289 - L290 were not covered by tests
end

function Base.:(==)(a::Interval{T}, b::Interval{T}) where {T}
return a.lower == b.lower && a.upper == b.upper
end
Expand Down Expand Up @@ -390,6 +394,10 @@
upper::T
end

function Semicontinuous(lower::Real, upper::Real)
return Semicontinuous(promote(lower, upper)...)

Check warning on line 398 in src/sets.jl

View check run for this annotation

Codecov / codecov/patch

src/sets.jl#L397-L398

Added lines #L397 - L398 were not covered by tests
end

function Base.:(==)(a::Semicontinuous{T}, b::Semicontinuous{T}) where {T}
return a.lower == b.lower && a.upper == b.upper
end
Expand Down Expand Up @@ -422,6 +430,10 @@
upper::T
end

function Semiinteger(lower::Real, upper::Real)
return Semiinteger(promote(lower, upper)...)

Check warning on line 434 in src/sets.jl

View check run for this annotation

Codecov / codecov/patch

src/sets.jl#L433-L434

Added lines #L433 - L434 were not covered by tests
end

function Base.:(==)(a::Semiinteger{T}, b::Semiinteger{T}) where {T}
return a.lower == b.lower && a.upper == b.upper
end
Expand Down
14 changes: 14 additions & 0 deletions test/sets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,20 @@ function runtests()
end
end

function test_interval_promote()
for S in (MOI.Interval, MOI.Semiinteger, MOI.Semicontinuous)
set = S(1.0, π)
@test set isa S{Float64}
@test set.lower == 1.0
@test set.upper ≈ π
set = S(big(1), 2)
@test set isa S{BigInt}
@test set.lower == 1
@test set.upper == 2
end
return
end

end

TestSets.runtests()
Loading