Skip to content

Commit 34b4edf

Browse files
committed
Add tests
1 parent 0cec84b commit 34b4edf

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/sets.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,10 @@ struct Semicontinuous{T<:Real} <: AbstractScalarSet
394394
upper::T
395395
end
396396

397+
function Semicontinuous(lower::Real, upper::Real)
398+
return Semicontinuous(promote(lower, upper)...)
399+
end
400+
397401
function Base.:(==)(a::Semicontinuous{T}, b::Semicontinuous{T}) where {T}
398402
return a.lower == b.lower && a.upper == b.upper
399403
end
@@ -426,6 +430,10 @@ struct Semiinteger{T<:Real} <: AbstractScalarSet
426430
upper::T
427431
end
428432

433+
function Semiinteger(lower::Real, upper::Real)
434+
return Semiinteger(promote(lower, upper)...)
435+
end
436+
429437
function Base.:(==)(a::Semiinteger{T}, b::Semiinteger{T}) where {T}
430438
return a.lower == b.lower && a.upper == b.upper
431439
end

test/sets.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,19 @@ function runtests()
363363
end
364364
end
365365

366+
function test_interval_promote()
367+
for S in [MOI.Interval, MOI.Semiinteger, MOI.Semicontinuous]
368+
set = S(1.0, π)
369+
@test set isa S{Float64}
370+
@test set.lower == 1.0
371+
@test set.upper == π
372+
set = S(big(1), 2)
373+
@test set isa S{BigInt}
374+
@test set.lower == 1
375+
@test set.upper == 2
376+
end
377+
end
378+
366379
end
367380

368381
TestSets.runtests()

0 commit comments

Comments
 (0)