Skip to content

Commit

Permalink
Fix error in RawOptimizerAttribute and improve code coverage (#437)
Browse files Browse the repository at this point in the history
  • Loading branch information
odow authored Nov 24, 2024
1 parent 2cbbd64 commit 5e3aec2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,8 @@ end

function MOI.get(model::Optimizer, p::MOI.RawOptimizerAttribute)
if !haskey(model.options, p.name)
error("RawParameter with name $(p.name) is not set.")
msg = "RawOptimizerAttribute with name $(p.name) is not already set."
throw(MOI.GetAttributeNotAllowed(p, msg))
end
return model.options[p.name]
end
Expand Down
10 changes: 10 additions & 0 deletions test/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,16 @@ function test_manually_evaluated_primal_status()
return
end

function test_RawOptimizerAttribute()
model = Ipopt.Optimizer()
attr = MOI.RawOptimizerAttribute("print_level")
@test_throws MOI.GetAttributeNotAllowed{typeof(attr)} MOI.get(model, attr)
@test MOI.supports(model, attr)
MOI.set(model, attr, 0)
@test MOI.get(model, attr) == 0
return
end

end # module TestMOIWrapper

TestMOIWrapper.runtests()

0 comments on commit 5e3aec2

Please sign in to comment.