Skip to content

Commit 981ddb5

Browse files
authored
[Bridges] add a test_broken test for #2696 (#2705)
1 parent f125237 commit 981ddb5

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/Test/test_basic_constraint.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,12 @@ function _basic_constraint_test_helper(
246246
### Test MOI.is_valid
247247
###
248248
@test MOI.is_valid(model, c)
249-
# TODO(odow): we could improve this test by checking `c.value+1` and
250-
# `c.value-1` but there is a bug in `LazyBridgeOptimizer`.
249+
# We could improve this test by checking these are `== true` instead of
250+
# `isa Bool`, but there is a bug in `LazyBridgeOptimizer`. See
251+
# MathOptInterface.jl#2696 for details. At the very least, this test checks
252+
# that they do not error, and hopefully helps hit some code paths.
253+
@test !MOI.is_valid(model, typeof(c)(c.value + 1)) isa Bool
254+
@test !MOI.is_valid(model, typeof(c)(c.value - 1)) isa Bool
251255
@test !MOI.is_valid(model, typeof(c)(c.value + 12345))
252256
###
253257
### Test MOI.ConstraintName

test/Bridges/lazy_bridge_optimizer.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2238,6 +2238,21 @@ function test_bridge_complex_greatertoless()
22382238
return
22392239
end
22402240

2241+
function test_issue_2696()
2242+
b = MOI.instantiate(StandardSDPAModel{Float64}; with_bridge_type = Float64)
2243+
x = MOI.add_variables(b, 2)
2244+
c = MOI.add_constraint(b, MOI.VectorOfVariables(x), MOI.Nonpositives(2))
2245+
@test MOI.is_valid(b, c)
2246+
F, S = MOI.VectorOfVariables, MOI.Nonpositives
2247+
# See MathOptInterface.jl#2696
2248+
d = MOI.ConstraintIndex{F,S}(c.value + 1)
2249+
@test_broken !MOI.is_valid(b, d)
2250+
@test MOI.get(b, MOI.ListOfConstraintTypesPresent()) == [(F, S)]
2251+
@test only(MOI.get(b, MOI.ListOfConstraintIndices{F,S}())) == c
2252+
@test MOI.get(b, MOI.NumberOfConstraints{F,S}()) == 1
2253+
return
2254+
end
2255+
22412256
end # module
22422257

22432258
TestBridgesLazyBridgeOptimizer.runtests()

0 commit comments

Comments
 (0)