From f44dbe62155d99181f9bd8948e96eb3cc81070d0 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 19 Aug 2025 10:23:27 -0400 Subject: [PATCH 1/3] improve coverage 2.0 --- test/jump_tests.jl | 14 +++++++++++++- test/moi_tests.jl | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/test/jump_tests.jl b/test/jump_tests.jl index d36e3ed6..ba2c347a 100644 --- a/test/jump_tests.jl +++ b/test/jump_tests.jl @@ -1500,6 +1500,11 @@ function test_jump_psd_cone_without_parameter_v_and_vv() @test is_valid(model, con) optimize!(model) @test value(x) ≈ 0.50000 atol = 1e-5 + @test MOI.get( + backend(model), + MOI.ConstraintPrimalStart(), + index(ParameterRef(p)), + ) == 1.0 delete(model, con) unregister(model, :con) @test_throws MOI.UnsupportedConstraint @constraint( @@ -1510,7 +1515,7 @@ function test_jump_psd_cone_without_parameter_v_and_vv() @test_throws MOI.UnsupportedConstraint @constraint( model, con, - [x * x, (x - 1), p] in MOI.PositiveSemidefiniteConeTriangle(2) + [x * x, (x - 1), 0.0] in MOI.PositiveSemidefiniteConeTriangle(2) ) @test_throws MOI.UnsupportedConstraint @constraint( model, @@ -1522,6 +1527,13 @@ function test_jump_psd_cone_without_parameter_v_and_vv() con, [x, p * (x - 1), x * x] in MOI.PositiveSemidefiniteConeTriangle(2) ) + @test_throws ErrorException("Constraint attribute MathOptInterface.ConstraintName() cannot be set for $(index(ParameterRef(pref)))") MOI.set( + backend(model), + MOI.ConstraintName(), + index(ParameterRef(pref)), + "name", + ) + @test_throws MOI.UnsupportedAttribute MOI.supports(backend(model), MOI.ConstraintName(), MOI.ConstraintIndex{MOI.VariableIndex, MOI.Parameter}) end function test_variable_and_constraint_not_registered() diff --git a/test/moi_tests.jl b/test/moi_tests.jl index 9d81adfd..ab94eb17 100644 --- a/test/moi_tests.jl +++ b/test/moi_tests.jl @@ -1821,6 +1821,11 @@ function test_getters() MOI.Zeros, POI.ParametricVectorAffineFunction{Float64}, ) + T4 = ( + MOI.VectorAffineFunction{Float64}, + MOI.Zeros, + POI.ParametricVectorQuadraticFunction{Float64}, + ) @test MOI.get(optimizer, POI.ListOfParametricConstraintTypesPresent()) == [T1] @test length( @@ -1853,6 +1858,16 @@ function test_getters() }(), ), ) + @test isempty( + MOI.get( + optimizer, + POI.DictOfParametricConstraintIndicesAndFunctions{ + T4[1], + T4[2], + T4[3], + }(), + ), + ) MOI.add_constraint(optimizer, 2.0x * p + 2.0p, MOI.LessThan(0.0)) @test MOI.get(optimizer, POI.ListOfParametricConstraintTypesPresent()) == [T1, T2] || @@ -1888,6 +1903,16 @@ function test_getters() }(), ), ) + @test isempty( + MOI.get( + optimizer, + POI.DictOfParametricConstraintIndicesAndFunctions{ + T4[1], + T4[2], + T4[3], + }(), + ), + ) terms = [ MOI.VectorAffineTerm(Int64(1), MOI.ScalarAffineTerm(2.0, x)), MOI.VectorAffineTerm(Int64(2), MOI.ScalarAffineTerm(3.0, p)), @@ -1924,6 +1949,16 @@ function test_getters() }(), ), ) == 1 + @test isempty( + MOI.get( + optimizer, + POI.DictOfParametricConstraintIndicesAndFunctions{ + T4[1], + T4[2], + T4[3], + }(), + ), + ) @test MOI.get(optimizer, POI.ParametricObjectiveType()) == Nothing MOI.set( optimizer, From 97a0afcf0c78fedd590cec5c467ed2098f62945e Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 19 Aug 2025 10:25:45 -0400 Subject: [PATCH 2/3] format --- test/jump_tests.jl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/jump_tests.jl b/test/jump_tests.jl index ba2c347a..06ee248c 100644 --- a/test/jump_tests.jl +++ b/test/jump_tests.jl @@ -1527,13 +1527,19 @@ function test_jump_psd_cone_without_parameter_v_and_vv() con, [x, p * (x - 1), x * x] in MOI.PositiveSemidefiniteConeTriangle(2) ) - @test_throws ErrorException("Constraint attribute MathOptInterface.ConstraintName() cannot be set for $(index(ParameterRef(pref)))") MOI.set( + @test_throws ErrorException( + "Constraint attribute MathOptInterface.ConstraintName() cannot be set for $(index(ParameterRef(pref)))", + ) MOI.set( backend(model), MOI.ConstraintName(), index(ParameterRef(pref)), "name", ) - @test_throws MOI.UnsupportedAttribute MOI.supports(backend(model), MOI.ConstraintName(), MOI.ConstraintIndex{MOI.VariableIndex, MOI.Parameter}) + @test_throws MOI.UnsupportedAttribute MOI.supports( + backend(model), + MOI.ConstraintName(), + MOI.ConstraintIndex{MOI.VariableIndex,MOI.Parameter}, + ) end function test_variable_and_constraint_not_registered() From 06e2d04ef1b36371a786d93062ca22378a932b8a Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 19 Aug 2025 10:31:36 -0400 Subject: [PATCH 3/3] fix typo --- test/jump_tests.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/jump_tests.jl b/test/jump_tests.jl index 06ee248c..da64ae35 100644 --- a/test/jump_tests.jl +++ b/test/jump_tests.jl @@ -1528,11 +1528,11 @@ function test_jump_psd_cone_without_parameter_v_and_vv() [x, p * (x - 1), x * x] in MOI.PositiveSemidefiniteConeTriangle(2) ) @test_throws ErrorException( - "Constraint attribute MathOptInterface.ConstraintName() cannot be set for $(index(ParameterRef(pref)))", + "Constraint attribute MathOptInterface.ConstraintName() cannot be set for $(index(ParameterRef(p)))", ) MOI.set( backend(model), MOI.ConstraintName(), - index(ParameterRef(pref)), + index(ParameterRef(p)), "name", ) @test_throws MOI.UnsupportedAttribute MOI.supports(