Skip to content

Commit 93694da

Browse files
authored
[Bridges] improve test coverage (#2666)
1 parent bcaac1e commit 93694da

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

src/Bridges/Bridges.jl

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -178,16 +178,10 @@ function _test_structural_identical(
178178
Test.@test (F, S) in b_constraint_types || MOI.get(a, attr) == 0
179179
end
180180
for (F, S) in b_constraint_types
181+
Test.@test haskey(constraints, (F, S))
181182
# Check that the same number of constraints are present
182183
attr = MOI.NumberOfConstraints{F,S}()
183-
if !haskey(constraints, (F, S))
184-
# Constraint is reported in `b`, but not in `a`. Check that there
185-
# are no actual constraints in `b`.
186-
Test.@test MOI.get(b, attr) == 0
187-
continue
188-
else
189-
Test.@test MOI.get(a, attr) == MOI.get(b, attr)
190-
end
184+
Test.@test MOI.get(a, attr) == MOI.get(b, attr)
191185
# Check that supports_constraint is implemented
192186
Test.@test MOI.supports_constraint(b, F, S)
193187
# Check that each function in `b` matches a function in `a`
@@ -402,9 +396,7 @@ function _test_delete(Bridge, model, inner)
402396
MOI.delete.(model, MOI.get(model, MOI.ListOfConstraintIndices{F,S}()))
403397
end
404398
# * So now there should be no constraints in the problem
405-
for (F, S) in MOI.get(inner, MOI.ListOfConstraintTypesPresent())
406-
Test.@test MOI.get(inner, MOI.NumberOfConstraints{F,S}()) == 0
407-
end
399+
Test.@test isempty(MOI.get(inner, MOI.ListOfConstraintTypesPresent()))
408400
# * And there should be the same number of variables
409401
attr = MOI.NumberOfVariables()
410402
Test.@test MOI.get(inner, attr) == MOI.get(model, attr)

test/Bridges/Constraint/AllDifferentToCountDistinctBridge.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ function test_runtests_VectorOfVariables()
4040
y <= 3.0
4141
z == 2.0
4242
n == 3.0
43-
""",
43+
""";
44+
print_inner_model = true,
4445
)
4546
return
4647
end

0 commit comments

Comments
 (0)