Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/Test/test_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -748,16 +748,18 @@ function test_model_ScalarFunctionConstantNotZero(
try
f = MOI.ScalarAffineFunction(MOI.ScalarAffineTerm{T}[], T(1))
c = MOI.add_constraint(model, f, MOI.EqualTo(T(2)))
@requires _supports(config, MOI.ConstraintFunction)
@test MOI.get(model, MOI.ConstraintFunction(), c) ≈ f
if _supports(config, MOI.ConstraintFunction)
@test MOI.get(model, MOI.ConstraintFunction(), c) ≈ f
end
catch err
@test err == _error(MOI.EqualTo{T}, T(1))
end
try
f = MOI.ScalarAffineFunction(MOI.ScalarAffineTerm{T}[], T(2))
c = MOI.add_constraint(model, f, MOI.GreaterThan(T(1)))
@requires _supports(config, MOI.ConstraintFunction)
@test MOI.get(model, MOI.ConstraintFunction(), c) ≈ f
if _supports(config, MOI.ConstraintFunction)
@test MOI.get(model, MOI.ConstraintFunction(), c) ≈ f
end
catch err
@test err == _error(MOI.GreaterThan{T}, T(2))
end
Expand Down
10 changes: 10 additions & 0 deletions test/Test/Test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ MOI.Test.runtests(
],
)

# Test for Issue #1757

MOI.Test.test_model_ScalarFunctionConstantNotZero(
MOI.Utilities.MockOptimizer(
MOI.Utilities.Model{Float64}(),
scalar_function_constant_non_zero = false,
),
MOI.Test.Config(exclude = Any[MOI.ConstraintFunction]),
)

# Test exclude_tests_after. This should work despite no methods being added for IncompleteOptimizer
# because every test should get skipped.

Expand Down