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

[Test] improve test_attribute_TimeLimitSec #2256

Merged
merged 1 commit into from Sep 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/Test/test_attribute.jl
Expand Up @@ -168,15 +168,24 @@
"""
function test_attribute_TimeLimitSec(model::MOI.AbstractOptimizer, ::Config)
@requires MOI.supports(model, MOI.TimeLimitSec())
function _get_default(model)
try
return MOI.get(model, MOI.TimeLimitSec())
catch err
@assert err isa MOI.GetAttributeNotAllowed(MOI.TimeLimitSec())

Check warning on line 175 in src/Test/test_attribute.jl

View check run for this annotation

Codecov / codecov/patch

src/Test/test_attribute.jl#L175

Added line #L175 was not covered by tests
end
return

Check warning on line 177 in src/Test/test_attribute.jl

View check run for this annotation

Codecov / codecov/patch

src/Test/test_attribute.jl#L177

Added line #L177 was not covered by tests
end
# Get the current value to restore it at the end of the test
value = MOI.get(model, MOI.TimeLimitSec())
value = _get_default(model)
MOI.set(model, MOI.TimeLimitSec(), 0.0)
@test MOI.get(model, MOI.TimeLimitSec()) == 0.0
_test_attribute_value_type(model, MOI.TimeLimitSec())
MOI.set(model, MOI.TimeLimitSec(), 1.0)
@test MOI.get(model, MOI.TimeLimitSec()) == 1.0
MOI.set(model, MOI.TimeLimitSec(), nothing)
@test _get_default(model) === nothing
MOI.set(model, MOI.TimeLimitSec(), value)
@test value == MOI.get(model, MOI.TimeLimitSec()) # Equality should hold
_test_attribute_value_type(model, MOI.TimeLimitSec())
return
end
test_attribute_TimeLimitSec(::MOI.ModelLike, ::Config) = nothing
Expand Down