Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more tests to improve code coverage #215

Merged
merged 2 commits into from
Jun 19, 2024
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
6 changes: 3 additions & 3 deletions src/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,9 @@ mutable struct Optimizer <: MOI.AbstractOptimizer
_Solution(),
)
MOI.empty!(model)
@static if Sys.iswindows()
# Set number of threads by default on Windows. This fixes a
# hang in some versions of Highs_jll. For discussion, see
if Sys.iswindows()
# Set number of threads by default on Windows. This fixes a hang in
# some versions of Highs_jll. For discussion, see
# https://github.com/ERGO-Code/HiGHS/issues/1257
n_threads = max(1, div(length(Sys.cpu_info()), 2))
MOI.set(model, MOI.NumberOfThreads(), n_threads)
Expand Down
38 changes: 38 additions & 0 deletions test/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,44 @@ function test_copy_to_unsupported_constraint()
return
end

function test_delete_constraint_twice()
model = HiGHS.Optimizer()
x = MOI.add_variable(model)
ci = MOI.add_constraint(model, 1.0 * x, MOI.EqualTo(1.0))
@test_throws(
ErrorException(
"Encountered an error in HiGHS (Status -1). Check the log " *
"for details.",
),
MOI.delete(model, [ci, ci]),
)
return
end

function test_RawStatusStringOptimizeNotCalled()
model = HiGHS.Optimizer()
@test MOI.get(model, MOI.RawStatusString()) == "OPTIMIZE_NOT_CALLED"
@test MOI.get(model, MOI.ResultCount()) == 0
return
end

function test_nonbasic_equality_constraint()
model = HiGHS.Optimizer()
x = MOI.add_variable(model)
ci = MOI.add_constraint(model, 1.0 * x, MOI.EqualTo(1.0))
MOI.optimize!(model)
@test MOI.get(model, MOI.ConstraintBasisStatus(), ci) == MOI.NONBASIC
return
end

function test_variable_basis_status_zero()
model = HiGHS.Optimizer()
x = MOI.add_variable(model)
MOI.optimize!(model)
@test MOI.get(model, MOI.VariableBasisStatus(), x) == MOI.NONBASIC
return
end

odow marked this conversation as resolved.
Show resolved Hide resolved
end # module

TestMOIHighs.runtests()
Loading