From 43b790f9193800079393ae11878219c24eb72939 Mon Sep 17 00:00:00 2001 From: odow Date: Thu, 25 Nov 2021 14:02:09 +1300 Subject: [PATCH 1/2] [Test] fix test_model_copy_to_ tests --- src/Test/test_model.jl | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/src/Test/test_model.jl b/src/Test/test_model.jl index f2c5644adf..3a42cfd1d4 100644 --- a/src/Test/test_model.jl +++ b/src/Test/test_model.jl @@ -559,12 +559,16 @@ function test_model_empty(model::MOI.ModelLike, ::Config) end """ - test_model_copy_to_UnsupportedConstraint( - model::MOI.ModelLike, - ::Config, - ) + test_model_copy_to_UnsupportedConstraint(model::MOI.ModelLike, ::Config) + +Test an error is thrown when a constraint is unsupported. -Test `MOI.copy_to` when a constraint is unsupported. +!!! note + This functon uses the two-argument `MOI.optimize!`. This ensures that we + test three cases: + * models implementing the two-argument method + * models using the generic fallback and erroring on `copy_to` + * models using the generic fallback and erroring on `optimize!`. """ function test_model_copy_to_UnsupportedConstraint( model::MOI.ModelLike, @@ -577,18 +581,22 @@ function test_model_copy_to_UnsupportedConstraint( ) @test_throws( MOI.UnsupportedConstraint, - MOI.copy_to(model, BadConstraintModel()), + MOI.optimize!(model, BadConstraintModel()), ) return end """ - test_model_copy_to_UnsupportedAttribute( - model::MOI.ModelLike, - ::Config, - ) + test_model_copy_to_UnsupportedAttribute(model::MOI.ModelLike, ::Config) + +Test an error is thrown when an attribute is unsupported. -Test `MOI.copy_to` when an attribute is unsupported. +!!! note + This functon uses the two-argument `MOI.optimize!`. This ensures that we + test three cases: + * models implementing the two-argument method + * models using the generic fallback and erroring on `copy_to` + * models using the generic fallback and erroring on `optimize!`. """ function test_model_copy_to_UnsupportedAttribute( model::MOI.ModelLike, @@ -598,13 +606,13 @@ function test_model_copy_to_UnsupportedAttribute( @test !MOI.supports(model, UnknownModelAttribute()) @test_throws( MOI.UnsupportedAttribute, - MOI.copy_to(model, BadModelAttributeModel(T)), + MOI.optimize!(model, BadModelAttributeModel(T)), ) # VariableAttribute @test !MOI.supports(model, UnknownVariableAttribute(), MOI.VariableIndex) @test_throws( MOI.UnsupportedAttribute, - MOI.copy_to(model, BadVariableAttributeModel(T)), + MOI.optimize!(model, BadVariableAttributeModel(T)), ) # ConstraintAttribute @test !MOI.supports( @@ -614,7 +622,7 @@ function test_model_copy_to_UnsupportedAttribute( ) @test_throws( MOI.UnsupportedAttribute, - MOI.copy_to(model, BadConstraintAttributeModel(T)), + MOI.optimize!(model, BadConstraintAttributeModel(T)), ) return end From a62bedf5d6506ae16236695965f3a4c7bc23f568 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Thu, 25 Nov 2021 14:46:53 -0500 Subject: [PATCH 2/2] functon -> functions --- src/Test/test_model.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Test/test_model.jl b/src/Test/test_model.jl index 3a42cfd1d4..d315ac4f55 100644 --- a/src/Test/test_model.jl +++ b/src/Test/test_model.jl @@ -564,7 +564,7 @@ end Test an error is thrown when a constraint is unsupported. !!! note - This functon uses the two-argument `MOI.optimize!`. This ensures that we + This function uses the two-argument `MOI.optimize!`. This ensures that we test three cases: * models implementing the two-argument method * models using the generic fallback and erroring on `copy_to` @@ -592,7 +592,7 @@ end Test an error is thrown when an attribute is unsupported. !!! note - This functon uses the two-argument `MOI.optimize!`. This ensures that we + This function uses the two-argument `MOI.optimize!`. This ensures that we test three cases: * models implementing the two-argument method * models using the generic fallback and erroring on `copy_to`