Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Utilities] migrate print.jl to the new MOI.Test #1444

Merged
merged 1 commit into from
Jul 5, 2021
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
2 changes: 2 additions & 0 deletions src/Utilities/Utilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ end
function replace_acronym(s::AbstractString)
s = replace(s, "MathOptInterface.Utilities" => "MOIU")
s = replace(s, "MathOptInterface.Bridges" => "MOIB")
# TODO(odow): remove once deprecated tests are deleted.
s = replace(s, "MathOptInterface.DeprecatedTest" => "MOIT")
s = replace(s, "MathOptInterface.Test" => "MOIT")
s = replace(s, "MathOptInterface" => "MOI")
return s
end
Expand Down
45 changes: 35 additions & 10 deletions test/Utilities/print.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
module TestPrint

using Test

using MathOptInterface
const MOI = MathOptInterface
const MOIU = MOI.Utilities

using Test
function runtests()
for name in names(@__MODULE__; all = true)
if startswith("$(name)", "test_")
@testset "$(name)" begin
getfield(@__MODULE__, name)()
end
end
end
return
end

const LATEX = MIME("text/latex")
const PLAIN = MIME("text/plain")
Expand Down Expand Up @@ -523,7 +534,7 @@ function test_nlp()
MOI.set(model, MOI.VariableName(), v[i], "x[$i]")
end
lb, ub = [25.0, 40.0], [Inf, 40.0]
evaluator = MOI.DeprecatedTest.HS071(true)
evaluator = MOI.Test.HS071(true)
block_data = MOI.NLPBlockData(MOI.NLPBoundsPair.(lb, ub), evaluator, true)
MOI.set(model, MOI.NLPBlock(), block_data)
MOI.set(model, MOI.ObjectiveSense(), MOI.MIN_SENSE)
Expand Down Expand Up @@ -573,14 +584,28 @@ function test_nlp()
return
end

function runtests()
for name in names(@__MODULE__; all = true)
if startswith("$(name)", "test_")
@testset "$(name)" begin
getfield(@__MODULE__, name)()
end
end
end
function test_print_with_acronym()
@test sprint(MOIU.print_with_acronym, "MathOptInterface") == "MOI"
@test sprint(
MOIU.print_with_acronym,
"MathOptInterface.MathOptInterface",
) == "MOI.MOI"
@test sprint(
MOIU.print_with_acronym,
"MathOptInterface.Utilities.MathOptInterface",
) == "MOIU.MOI"
@test sprint(MOIU.print_with_acronym, "MathOptInterfaceXXBridges") ==
"MOIXXBridges"
@test sprint(MOIU.print_with_acronym, "MathOptInterface.BridgesXX") ==
"MOIBXX"
@test sprint(MOIU.print_with_acronym, "MathOptInterface.Test.x") == "MOIT.x"
@test sprint(MOIU.print_with_acronym, "MathOptInterface.x.Test") ==
"MOI.x.Test"
@test sprint(MOIU.print_with_acronym, "MathOptInterface.Utilities.Test") ==
"MOIU.Test"
@test sprint(MOIU.print_with_acronym, "MathOptInterface.Utilities.Test") ==
"MOIU.Test"
return
end

end
Expand Down
22 changes: 0 additions & 22 deletions test/Utilities/print_with_acronym.jl

This file was deleted.