From 157bb1b39b1e3531faba1f112840336c7cbec046 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Mon, 24 Aug 2026 11:37:34 +1200 Subject: [PATCH] Fix formatting indent of multiline strings in test/ --- test/Bridges/General/test_bridge_optimizer.jl | 10 +- test/FileFormats/LP/test_LP.jl | 114 +++++++++--------- test/FileFormats/NL/test_read.jl | 104 ++++++++-------- test/FileFormats/SDPA/test_SDPA.jl | 80 ++++++------ test/Utilities/test_matrix_of_constraints.jl | 54 ++++----- 5 files changed, 181 insertions(+), 181 deletions(-) diff --git a/test/Bridges/General/test_bridge_optimizer.jl b/test/Bridges/General/test_bridge_optimizer.jl index 9bd448ec8d..351c69fe88 100644 --- a/test/Bridges/General/test_bridge_optimizer.jl +++ b/test/Bridges/General/test_bridge_optimizer.jl @@ -268,11 +268,11 @@ function test_issue_453() MOI.Utilities.loadfromstring!( bridged_mock, """ - variables: x - maxobjective: 3.0x - c: 2.0x in Interval(1.0, 4.0) - x in LessThan(1.5) -""", + variables: x + maxobjective: 3.0x + c: 2.0x in Interval(1.0, 4.0) + x in LessThan(1.5) + """, ) x = MOI.get(bridged_mock, MOI.VariableIndex, "x") @test isa(x, MOI.VariableIndex) diff --git a/test/FileFormats/LP/test_LP.jl b/test/FileFormats/LP/test_LP.jl index bb5b4659ff..9bef8d8718 100644 --- a/test/FileFormats/LP/test_LP.jl +++ b/test/FileFormats/LP/test_LP.jl @@ -36,21 +36,21 @@ function test_comprehensive_write() MOI.Utilities.loadfromstring!( model, """ -variables: a, x, y, z -minobjective: x -x >= -1.0 -x <= 2.0 -y == 3.0 -z in Interval(4.0, 5.0) -c5: 1.1x + 0.0 <= 5.1 -c6: 1.3x + -1.4 >= -0.1 -c7: 1.5a + 1.6 == 0.2 -c8: 1.7a + 1.8 in Interval(0.3, 0.4) -x in ZeroOne() -y in Integer() -c11: [x, y, z] in SOS1{Float64}([1.0, 2.0, 3.0]) -c12: [x, y, z] in SOS2{Float64}([3.3, 1.1, 2.2]) -""", + variables: a, x, y, z + minobjective: x + x >= -1.0 + x <= 2.0 + y == 3.0 + z in Interval(4.0, 5.0) + c5: 1.1x + 0.0 <= 5.1 + c6: 1.3x + -1.4 >= -0.1 + c7: 1.5a + 1.6 == 0.2 + c8: 1.7a + 1.8 in Interval(0.3, 0.4) + x in ZeroOne() + y in Integer() + c11: [x, y, z] in SOS1{Float64}([1.0, 2.0, 3.0]) + c12: [x, y, z] in SOS2{Float64}([3.3, 1.1, 2.2]) + """, ) MOI.write_to_file(model, LP_TEST_FILE) @test read(LP_TEST_FILE, String) == @@ -86,10 +86,10 @@ function test_name_sanitization_start() MOI.Utilities.loadfromstring!( model, """ -variables: x -minobjective: x -c1: 1.0 * x >= -1.0 -""", + variables: x + minobjective: x + c1: 1.0 * x >= -1.0 + """, ) x = MOI.get(model, MOI.VariableIndex, "x") MOI.set(model, MOI.VariableName(), x, starting_letter * "x") @@ -113,10 +113,10 @@ function test_name_sanitization_illegal() MOI.Utilities.loadfromstring!( model, """ -variables: x -minobjective: x -c1: 1.0 * x >= -1.0 -""", + variables: x + minobjective: x + c1: 1.0 * x >= -1.0 + """, ) x = MOI.get(model, MOI.VariableIndex, "x") MOI.set(model, MOI.VariableName(), x, "x$(illegal_letter)y") @@ -139,10 +139,10 @@ function test_name_sanitization_duplicate() MOI.Utilities.loadfromstring!( model, """ -variables: a, b, c, d -minobjective: a + b + c + d -c1: a + b + c + d >= -1.0 -""", + variables: a, b, c, d + minobjective: a + b + c + d + c1: a + b + c + d >= -1.0 + """, ) variables = MOI.get(model, MOI.ListOfVariableIndices()) MOI.set.(model, MOI.VariableName(), variables, ["a[", "a]", "a*", "a^"]) @@ -181,10 +181,10 @@ function test_name_sanitization_too_long() MOI.Utilities.loadfromstring!( model, """ -variables: abcd, abce -minobjective: abcd + abce -c1: abcd + abce >= -1.0 -""", + variables: abcd, abce + minobjective: abcd + abce + c1: abcd + abce >= -1.0 + """, ) MOI.write_to_file(model, LP_TEST_FILE) @test read(LP_TEST_FILE, String) == @@ -203,9 +203,9 @@ function test_name_sanitization_other() MOI.Utilities.loadfromstring!( model, """ -variables: x -maxobjective: 2.0 * x + -1.0 -""", + variables: x + maxobjective: 2.0 * x + -1.0 + """, ) MOI.write_to_file(model, LP_TEST_FILE) @test read(LP_TEST_FILE, String) == @@ -222,11 +222,11 @@ function test_free_variables() MOI.Utilities.loadfromstring!( model, """ -variables: x, y, z -maxobjective: x -x in ZeroOne() -y in Integer() -""", + variables: x, y, z + maxobjective: x + x in ZeroOne() + y in Integer() + """, ) MOI.write_to_file(model, LP_TEST_FILE) @test read(LP_TEST_FILE, String) == @@ -276,9 +276,9 @@ function test_quadratic_objective_diag() MOI.Utilities.loadfromstring!( model, """ -variables: x -minobjective: 1.0*x*x -""", + variables: x + minobjective: 1.0*x*x + """, ) MOI.write_to_file(model, LP_TEST_FILE) @test read(LP_TEST_FILE, String) == @@ -296,9 +296,9 @@ function test_quadratic_objective_off_diag() MOI.Utilities.loadfromstring!( model, """ -variables: x, y -minobjective: 1.1 * x + 1.2 * y + 1.5*x*y + 1.3 -""", + variables: x, y + minobjective: 1.1 * x + 1.2 * y + 1.5*x*y + 1.3 + """, ) MOI.write_to_file(model, LP_TEST_FILE) @test read(LP_TEST_FILE, String) == @@ -317,9 +317,9 @@ function test_quadratic_objective_complicated() MOI.Utilities.loadfromstring!( model, """ -variables: x, y -minobjective: 1.1 * x + 1.2 * y + -1.1 * x * x + 1.5*x*y + 1.3 -""", + variables: x, y + minobjective: 1.1 * x + 1.2 * y + -1.1 * x * x + 1.5*x*y + 1.3 + """, ) MOI.write_to_file(model, LP_TEST_FILE) @test read(LP_TEST_FILE, String) == @@ -338,9 +338,9 @@ function test_quadratic_constraint_diag() MOI.Utilities.loadfromstring!( model, """ -variables: x -c: 1.0*x*x <= 1.4 -""", + variables: x + c: 1.0*x*x <= 1.4 + """, ) MOI.write_to_file(model, LP_TEST_FILE) @test read(LP_TEST_FILE, String) == @@ -359,9 +359,9 @@ function test_quadratic_constraint_off_diag() MOI.Utilities.loadfromstring!( model, """ -variables: x, y -c: 1.1 * x + 1.2 * y + 1.5*x*y + 1.3 == 1.5 -""", + variables: x, y + c: 1.1 * x + 1.2 * y + 1.5*x*y + 1.3 == 1.5 + """, ) MOI.write_to_file(model, LP_TEST_FILE) @test read(LP_TEST_FILE, String) == @@ -381,9 +381,9 @@ function test_quadratic_constraint_complicated() MOI.Utilities.loadfromstring!( model, """ -variables: x, y -c: 1.1 * x + 1.2 * y + -1.1 * x * x + 1.5*x*y + 1.3 in Interval(-1.1, 1.4) -""", + variables: x, y + c: 1.1 * x + 1.2 * y + -1.1 * x * x + 1.5*x*y + 1.3 in Interval(-1.1, 1.4) + """, ) MOI.write_to_file(model, LP_TEST_FILE) @test read(LP_TEST_FILE, String) == diff --git a/test/FileFormats/NL/test_read.jl b/test/FileFormats/NL/test_read.jl index b9301e8573..6e8a456e4e 100644 --- a/test/FileFormats/NL/test_read.jl +++ b/test/FileFormats/NL/test_read.jl @@ -186,15 +186,15 @@ function test_parse_O() write( io, """ -O0 0# can stick a comment anywhere -o2 -v0 # can stick a comment anywhere -o2 -v2 -o2 -v3 -v1 -""", + O0 0# can stick a comment anywhere + o2 + v0 # can stick a comment anywhere + o2 + v2 + o2 + v3 + v1 + """, ) seekstart(io) NL._parse_section(io, model) @@ -226,11 +226,11 @@ function test_parse_x() write( io, """ -x3 -0 1.1# can stick a comment anywhere -3 2.2 -2 3.3 # can stick a comment anywhere -""", + x3 + 0 1.1# can stick a comment anywhere + 3 2.2 + 2 3.3 # can stick a comment anywhere + """, ) seekstart(io) NL._parse_section(io, model) @@ -245,11 +245,11 @@ function test_parse_d() write( io, """ -d3 -0 1.1# can stick a comment anywhere -3 2.2 -2 3.3 # can stick a comment anywhere -""", + d3 + 0 1.1# can stick a comment anywhere + 3 2.2 + 2 3.3 # can stick a comment anywhere + """, ) seekstart(io) NL._parse_section(io, model) @@ -328,10 +328,10 @@ function test_parse_J() write( io, """ -J1 2 # can stick a comment anywhere -2 1.1 -3 2.2 # can stick a comment anywhere -""", + J1 2 # can stick a comment anywhere + 2 1.1 + 3 2.2 # can stick a comment anywhere + """, ) seekstart(io) NL._parse_section(io, model) @@ -350,10 +350,10 @@ function test_parse_J_zeros() write( io, """ -J0 2 -0 0 -1 0 -""", + J0 2 + 0 0 + 1 0 + """, ) seekstart(io) NL._parse_section(io, model) @@ -421,10 +421,10 @@ function test_parse_G() write( io, """ -G0 2 # can stick a comment anywhere -2 1.1 # can stick a comment anywhere -3 2.2 -""", + G0 2 # can stick a comment anywhere + 2 1.1 # can stick a comment anywhere + 3 2.2 + """, ) seekstart(io) NL._parse_section(io, model) @@ -441,11 +441,11 @@ function test_parse_G_zeros() write( io, """ -G0 3 -0 0 -1 0 -2 0 -""", + G0 3 + 0 0 + 1 0 + 2 0 + """, ) seekstart(io) NL._parse_section(io, model) @@ -461,14 +461,14 @@ function test_parse_O_G() write( io, """ -O0 0 -o2 -v0 -v1 -G0 2 -0 1.1 -1 2.2 -""", + O0 0 + o2 + v0 + v1 + G0 2 + 0 1.1 + 1 2.2 + """, ) seekstart(io) NL._parse_section(io, model) @@ -486,14 +486,14 @@ function test_parse_G_O() write( io, """ -G0 2 -0 -1.1 -1 2.2e+01 -O0 0 -o2 -v0 -v1 -""", + G0 2 + 0 -1.1 + 1 2.2e+01 + O0 0 + o2 + v0 + v1 + """, ) seekstart(io) NL._parse_section(io, model) diff --git a/test/FileFormats/SDPA/test_SDPA.jl b/test/FileFormats/SDPA/test_SDPA.jl index be500830dc..0e12f9afdb 100644 --- a/test/FileFormats/SDPA/test_SDPA.jl +++ b/test/FileFormats/SDPA/test_SDPA.jl @@ -222,9 +222,9 @@ function test_nonzero_in_objective() MOIU.loadfromstring!( model, """ -variables: x -minobjective: x + 1 -""", + variables: x + minobjective: x + 1 + """, ) err = ErrorException( "Nonzero constant in objective function not supported. Note that " * @@ -244,32 +244,32 @@ const _WRITE_READ_MODELS = [ ( "min ScalarAffine", """ - variables: x, y - minobjective: 1.2x + -1y -""", + variables: x, y + minobjective: 1.2x + -1y + """, ), ( "max ScalarAffine", """ - variables: x, y - maxobjective: 1.2x + -1y -""", + variables: x, y + maxobjective: 1.2x + -1y + """, ), ( "VectorAffineFunction in Nonnegatives", """ - variables: x, y - minobjective: 1.2x - c1: [1.1 * x, y + 1] in Nonnegatives(2) -""", + variables: x, y + minobjective: 1.2x + c1: [1.1 * x, y + 1] in Nonnegatives(2) + """, ), ( "VectorAffineFunction in PositiveSemidefiniteConeTriangle", """ - variables: x, y, z - minobjective: 1.2x - c1: [1.1x, y + 1, 2x + z] in PositiveSemidefiniteConeTriangle(2) -""", + variables: x, y, z + minobjective: 1.2x + c1: [1.1x, y + 1, 2x + z] in PositiveSemidefiniteConeTriangle(2) + """, ), ] @@ -283,41 +283,41 @@ const _EXAMPLE_MODELS = [ ( "example_A.dat-s", """ - variables: x, y - minobjective: 10x + 20y - c1: [x + -1, 0, x + y + -2] in PositiveSemidefiniteConeTriangle(2) - c2: [5y + -3, 2y, 6y + -4] in PositiveSemidefiniteConeTriangle(2) -""", + variables: x, y + minobjective: 10x + 20y + c1: [x + -1, 0, x + y + -2] in PositiveSemidefiniteConeTriangle(2) + c2: [5y + -3, 2y, 6y + -4] in PositiveSemidefiniteConeTriangle(2) + """, ), ( "example_B.sdpa", """ - variables: x - minobjective: 1x - c1: [0, 1x + -1, 0] in PositiveSemidefiniteConeTriangle(2) -""", + variables: x + minobjective: 1x + c1: [0, 1x + -1, 0] in PositiveSemidefiniteConeTriangle(2) + """, ), ( "example_integer.sdpa", """ - variables: x, y, z - minobjective: 1x + -2y + -1z - c1: [1x, 1y, 1z] in PositiveSemidefiniteConeTriangle(2) - c2: [1z, 1x, 2.1] in PositiveSemidefiniteConeTriangle(2) - c3: [1x + 1y + 1z + -1, -1x + -1y + -1z + 8] in Nonnegatives(2) - x in Integer() - y in Integer() - z in Integer() -""", + variables: x, y, z + minobjective: 1x + -2y + -1z + c1: [1x, 1y, 1z] in PositiveSemidefiniteConeTriangle(2) + c2: [1z, 1x, 2.1] in PositiveSemidefiniteConeTriangle(2) + c3: [1x + 1y + 1z + -1, -1x + -1y + -1z + 8] in Nonnegatives(2) + x in Integer() + y in Integer() + z in Integer() + """, ), ( "issue_1541.dat-s", """ - variables: x, y, z - minobjective: -1y + -2z - c1: [-1x + -1y + -1z + 1, 1x, 1y, 1z] in Nonnegatives(4) - c2: [1x + 3y, 4y + 2z, -1z] in PositiveSemidefiniteConeTriangle(2) -""", + variables: x, y, z + minobjective: -1y + -2z + c1: [-1x + -1y + -1z + 1, 1x, 1y, 1z] in Nonnegatives(4) + c2: [1x + 3y, 4y + 2z, -1z] in PositiveSemidefiniteConeTriangle(2) + """, ), ] diff --git a/test/Utilities/test_matrix_of_constraints.jl b/test/Utilities/test_matrix_of_constraints.jl index c6be87a5fa..a4b8015633 100644 --- a/test/Utilities/test_matrix_of_constraints.jl +++ b/test/Utilities/test_matrix_of_constraints.jl @@ -81,12 +81,12 @@ function test_ScalarSets_basic() MOI.Utilities.loadfromstring!( src, """ -variables: x, y -minobjective: x + y -x >= 1.0 -y == 2.1 -c: x + 2.0 * y <= 3.0 -""", + variables: x, y + minobjective: x + y + x >= 1.0 + y == 2.1 + c: x + 2.0 * y <= 3.0 + """, ) index_map = MOI.copy_to(model, src) @test MOI.is_empty(model) == false @@ -171,10 +171,10 @@ function test_ScalarSets_get_ConstraintFunction() MOI.Utilities.loadfromstring!( src, """ -variables: x, y -minobjective: x + y -c: x + 2.0 * y <= 3.0 -""", + variables: x, y + minobjective: x + y + c: x + 2.0 * y <= 3.0 + """, ) index_map = MOI.copy_to(model, src) c = MOI.get(model, MOI.ConstraintIndex, "c") @@ -211,10 +211,10 @@ function test_ScalarSets_get_ConstraintSet() MOI.Utilities.loadfromstring!( src, """ -variables: x, y -minobjective: x + y -c: 2.0 * x + y >= 4.0 -""", + variables: x, y + minobjective: x + y + c: 2.0 * x + y >= 4.0 + """, ) index_map = MOI.copy_to(model, src) c = MOI.get(model, MOI.ConstraintIndex, "c") @@ -248,12 +248,12 @@ function test_add_after_final_touch() MOI.Utilities.loadfromstring!( src, """ -variables: x, y -minobjective: x + y -x >= 1.0 -y == 2.1 -c: x + 2.0 * y <= 3.0 -""", + variables: x, y + minobjective: x + y + x >= 1.0 + y == 2.1 + c: x + 2.0 * y <= 3.0 + """, ) index_map = MOI.copy_to(model, src) x = MOI.get(src, MOI.VariableIndex, "x") @@ -277,9 +277,9 @@ function test_UnsupportedConstraint() MOI.Utilities.loadfromstring!( src, """ -variables: x, y -c: [x, y] in Nonnegatives(2) -""", + variables: x, y + c: [x, y] in Nonnegatives(2) + """, ) @test_throws MOI.UnsupportedConstraint MOI.copy_to(model, src) return @@ -690,10 +690,10 @@ function test_modify_scalar_coefficient_change_zero_based() MOI.Utilities.loadfromstring!( src, """ -variables: x, y -minobjective: x + y -c: x + 2.0 * y <= 3.0 -""", + variables: x, y + minobjective: x + y + c: x + 2.0 * y <= 3.0 + """, ) index_map = MOI.copy_to(model, src) c = MOI.get(model, MOI.ConstraintIndex, "c")