Skip to content

Commit 1ba8447

Browse files
committed
[Test] simplify check for supported conflict status
An error in the getter should be NotAllowed, which will skip the test.
1 parent 19574de commit 1ba8447

File tree

1 file changed

+14
-59
lines changed

1 file changed

+14
-59
lines changed

src/Test/test_solve.jl

Lines changed: 14 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -901,16 +901,11 @@ function test_solve_conflict_bound_bound(
901901
) where {T}
902902
@requires _supports(config, MOI.compute_conflict!)
903903
@requires _supports(config, MOI.optimize!)
904-
try
905-
MOI.get(model, MOI.ConflictStatus())
906-
catch
907-
return # If this fails, skip the test.
908-
end
909904
x = MOI.add_variable(model)
910905
c1 = MOI.add_constraint(model, x, MOI.GreaterThan(T(2)))
911906
c2 = MOI.add_constraint(model, x, MOI.LessThan(T(1)))
912-
@test MOI.get(model, MOI.ConflictStatus()) ==
913-
MOI.COMPUTE_CONFLICT_NOT_CALLED
907+
status = MOI.get(model, MOI.ConflictStatus())
908+
@test status == MOI.COMPUTE_CONFLICT_NOT_CALLED
914909
MOI.optimize!(model)
915910
@test MOI.get(model, MOI.TerminationStatus()) == config.infeasible_status
916911
MOI.compute_conflict!(model)
@@ -957,11 +952,6 @@ function test_solve_conflict_two_affine(
957952
) where {T}
958953
@requires _supports(config, MOI.compute_conflict!)
959954
@requires _supports(config, MOI.optimize!)
960-
try
961-
MOI.get(model, MOI.ConflictStatus())
962-
catch
963-
return # If this fails, skip the test.
964-
end
965955
x = MOI.add_variable(model)
966956
c1 = MOI.add_constraint(
967957
model,
@@ -973,8 +963,8 @@ function test_solve_conflict_two_affine(
973963
MOI.ScalarAffineFunction(MOI.ScalarAffineTerm.(T(1), [x]), T(0)),
974964
MOI.LessThan(T(1)),
975965
)
976-
@test MOI.get(model, MOI.ConflictStatus()) ==
977-
MOI.COMPUTE_CONFLICT_NOT_CALLED
966+
status = MOI.get(model, MOI.ConflictStatus())
967+
@test status == MOI.COMPUTE_CONFLICT_NOT_CALLED
978968
MOI.optimize!(model)
979969
@test MOI.get(model, MOI.TerminationStatus()) == config.infeasible_status
980970
MOI.compute_conflict!(model)
@@ -1021,15 +1011,10 @@ function test_solve_conflict_invalid_interval(
10211011
) where {T}
10221012
@requires _supports(config, MOI.compute_conflict!)
10231013
@requires _supports(config, MOI.optimize!)
1024-
try
1025-
MOI.get(model, MOI.ConflictStatus())
1026-
catch
1027-
return # If this fails, skip the test.
1028-
end
10291014
x = MOI.add_variable(model)
10301015
c1 = MOI.add_constraint(model, x, MOI.Interval(T(1), T(0)))
1031-
@test MOI.get(model, MOI.ConflictStatus()) ==
1032-
MOI.COMPUTE_CONFLICT_NOT_CALLED
1016+
status = MOI.get(model, MOI.ConflictStatus())
1017+
@test status == MOI.COMPUTE_CONFLICT_NOT_CALLED
10331018
MOI.optimize!(model)
10341019
@test MOI.get(model, MOI.TerminationStatus()) == config.infeasible_status
10351020
MOI.compute_conflict!(model)
@@ -1073,11 +1058,6 @@ function test_solve_conflict_affine_affine(
10731058
) where {T}
10741059
@requires _supports(config, MOI.compute_conflict!)
10751060
@requires _supports(config, MOI.optimize!)
1076-
try
1077-
MOI.get(model, MOI.ConflictStatus())
1078-
catch
1079-
return # If this fails, skip the test.
1080-
end
10811061
x = MOI.add_variable(model)
10821062
y = MOI.add_variable(model)
10831063
b1 = MOI.add_constraint(model, x, MOI.GreaterThan(T(0)))
@@ -1087,8 +1067,8 @@ function test_solve_conflict_affine_affine(
10871067
cf2 =
10881068
MOI.ScalarAffineFunction(MOI.ScalarAffineTerm.(T[1, -1], [x, y]), T(0))
10891069
c2 = MOI.add_constraint(model, cf2, MOI.GreaterThan(T(1)))
1090-
@test MOI.get(model, MOI.ConflictStatus()) ==
1091-
MOI.COMPUTE_CONFLICT_NOT_CALLED
1070+
status = MOI.get(model, MOI.ConflictStatus())
1071+
@test status == MOI.COMPUTE_CONFLICT_NOT_CALLED
10921072
MOI.optimize!(model)
10931073
@test MOI.get(model, MOI.TerminationStatus()) == config.infeasible_status
10941074
MOI.compute_conflict!(model)
@@ -1140,11 +1120,6 @@ function test_solve_conflict_EqualTo(
11401120
) where {T}
11411121
@requires _supports(config, MOI.compute_conflict!)
11421122
@requires _supports(config, MOI.optimize!)
1143-
try
1144-
MOI.get(model, MOI.ConflictStatus())
1145-
catch
1146-
return # If this fails, skip the test.
1147-
end
11481123
x = MOI.add_variable(model)
11491124
y = MOI.add_variable(model)
11501125
b1 = MOI.add_constraint(model, x, MOI.GreaterThan(T(0)))
@@ -1154,8 +1129,8 @@ function test_solve_conflict_EqualTo(
11541129
cf2 =
11551130
MOI.ScalarAffineFunction(MOI.ScalarAffineTerm.(T[1, -1], [x, y]), T(0))
11561131
c2 = MOI.add_constraint(model, cf2, MOI.GreaterThan(T(1)))
1157-
@test MOI.get(model, MOI.ConflictStatus()) ==
1158-
MOI.COMPUTE_CONFLICT_NOT_CALLED
1132+
status = MOI.get(model, MOI.ConflictStatus())
1133+
@test status == MOI.COMPUTE_CONFLICT_NOT_CALLED
11591134
MOI.optimize!(model)
11601135
@test MOI.get(model, MOI.TerminationStatus()) == config.infeasible_status
11611136
MOI.compute_conflict!(model)
@@ -1207,11 +1182,6 @@ function test_solve_conflict_NOT_IN_CONFLICT(
12071182
) where {T}
12081183
@requires _supports(config, MOI.compute_conflict!)
12091184
@requires _supports(config, MOI.optimize!)
1210-
try
1211-
MOI.get(model, MOI.ConflictStatus())
1212-
catch
1213-
return # If this fails, skip the test.
1214-
end
12151185
x = MOI.add_variable(model)
12161186
y = MOI.add_variable(model)
12171187
z = MOI.add_variable(model)
@@ -1226,8 +1196,8 @@ function test_solve_conflict_NOT_IN_CONFLICT(
12261196
T(0),
12271197
)
12281198
c2 = MOI.add_constraint(model, cf2, MOI.GreaterThan(T(1)))
1229-
@test MOI.get(model, MOI.ConflictStatus()) ==
1230-
MOI.COMPUTE_CONFLICT_NOT_CALLED
1199+
status = MOI.get(model, MOI.ConflictStatus())
1200+
@test status == MOI.COMPUTE_CONFLICT_NOT_CALLED
12311201
MOI.optimize!(model)
12321202
@test MOI.get(model, MOI.TerminationStatus()) == config.infeasible_status
12331203
MOI.compute_conflict!(model)
@@ -1284,17 +1254,12 @@ function test_solve_conflict_feasible(
12841254
) where {T}
12851255
@requires _supports(config, MOI.compute_conflict!)
12861256
@requires _supports(config, MOI.optimize!)
1287-
try
1288-
MOI.get(model, MOI.ConflictStatus())
1289-
catch
1290-
return # If this fails, skip the test.
1291-
end
12921257
x = MOI.add_variable(model)
12931258
f = MOI.ScalarAffineFunction([MOI.ScalarAffineTerm(T(1), x)], T(0))
12941259
_ = MOI.add_constraint(model, f, MOI.GreaterThan(T(1)))
12951260
_ = MOI.add_constraint(model, f, MOI.LessThan(T(2)))
1296-
@test MOI.get(model, MOI.ConflictStatus()) ==
1297-
MOI.COMPUTE_CONFLICT_NOT_CALLED
1261+
status = MOI.get(model, MOI.ConflictStatus())
1262+
@test status == MOI.COMPUTE_CONFLICT_NOT_CALLED
12981263
MOI.optimize!(model)
12991264
@test MOI.get(model, MOI.TerminationStatus()) == config.optimal_status
13001265
MOI.compute_conflict!(model)
@@ -1333,11 +1298,6 @@ function test_solve_conflict_zeroone(
13331298
) where {T}
13341299
@requires _supports(config, MOI.compute_conflict!)
13351300
@requires _supports(config, MOI.optimize!)
1336-
try
1337-
MOI.get(model, MOI.ConflictStatus())
1338-
catch
1339-
return # If this fails, skip the test.
1340-
end
13411301
x, c1 = MOI.add_constrained_variable(model, MOI.ZeroOne())
13421302
c2 = MOI.add_constraint(
13431303
model,
@@ -1394,11 +1354,6 @@ function test_solve_conflict_zeroone_2(
13941354
@requires (T(1) / T(2)) isa T
13951355
@requires _supports(config, MOI.compute_conflict!)
13961356
@requires _supports(config, MOI.optimize!)
1397-
try
1398-
MOI.get(model, MOI.ConflictStatus())
1399-
catch
1400-
return # If this fails, skip the test.
1401-
end
14021357
x, c1 = MOI.add_constrained_variable(model, MOI.ZeroOne())
14031358
c2 = MOI.add_constraint(
14041359
model,

0 commit comments

Comments
 (0)