diff --git a/src/Test/test_attribute.jl b/src/Test/test_attribute.jl index bf9cf3afd1..2107f3e45a 100644 --- a/src/Test/test_attribute.jl +++ b/src/Test/test_attribute.jl @@ -167,3 +167,24 @@ function setup_test( MOI.set(model, MOI.TimeLimitSec(), nothing) return end + +""" + test_attribute_after_empty(model::MOI.AbstractOptimizer, config::Config) + +Test that optimizer attributes such as `Silent` are not cleared by `MOI.empty!`. +""" +function test_attribute_after_empty(model::MOI.AbstractOptimizer, ::Config) + @requires MOI.supports(model, MOI.Silent()) + current = MOI.get(model, MOI.Silent()) + for value in (true, false) + MOI.set(model, MOI.Silent(), value) + @test MOI.get(model, MOI.Silent()) == value + MOI.empty!(model) + @test MOI.get(model, MOI.Silent()) == value + end + # Make sure to reset the value before leaving this function! + MOI.set(model, MOI.Silent(), current) + return +end + +test_attribute_after_empty(::MOI.ModelLike, ::Config) = nothing