Skip to content

Commit

Permalink
Fix optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed May 11, 2021
1 parent 7c68fec commit c255dae
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/Test/UnitTests/attributes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,13 @@ for attr in (
unittests["test_attribute_$(attr)"] = @eval begin
function $(f)(model::MOI.ModelLike, config::TestConfig)
MOI.empty!(model)
MOI.optimize!(model)
attribute = MOI.$(attr)()
if MOI.is_set_by_optimize(attribute)
if !config.solve
return
end
MOI.optimize!(model)
end
T = MOI.attribute_value_type(attribute)
@static if VERSION < v"1.5"
@test MOI.get(model, attribute) isa T
Expand All @@ -174,8 +179,13 @@ for attr in (:VariableName,)
MOI.empty!(model)
x = MOI.add_variable(model)
MOI.set(model, MOI.VariableName(), x, "x")
MOI.optimize!(model)
attribute = MOI.$(attr)()
if MOI.is_set_by_optimize(attribute)
if !config.solve
return
end
MOI.optimize!(model)
end
T = MOI.attribute_value_type(attribute)
@static if VERSION < v"1.5"
@test MOI.get(model, attribute, x) isa T
Expand Down Expand Up @@ -203,9 +213,14 @@ for attr in (
MOI.SingleVariable(x),
MOI.GreaterThan(0.0),
)
MOI.optimize!(model)
MOI.set(model, MOI.ConstraintName(), ci, "ci")
attribute = MOI.$(attr)()
if MOI.is_set_by_optimize(attribute)
if !config.solve
return
end
MOI.optimize!(model)
end
T = MOI.attribute_value_type(attribute)
@static if VERSION < v"1.5"
@test MOI.get(model, attribute, ci) isa T
Expand Down

0 comments on commit c255dae

Please sign in to comment.