From c1d69b218acc621dce0fc0d7afab14ece4a4cb31 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Tue, 26 Nov 2024 15:02:58 +1300 Subject: [PATCH 1/4] Improve test coverage --- test/runtests.jl | 1 + test/test_problems.jl | 73 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) diff --git a/test/runtests.jl b/test/runtests.jl index f7ae8a5..76f3371 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -35,6 +35,7 @@ include("test_problems.jl") @test VersionNumber(SCS.scs_version(solver)) >= v"3.2.0" feasible_basic_problems(solver) test_options(solver) + test_scs_solve_solution_vectors(solver) end end diff --git a/test/test_problems.jl b/test/test_problems.jl index 90e0101..1202437 100644 --- a/test/test_problems.jl +++ b/test/test_problems.jl @@ -786,3 +786,76 @@ function test_options(T) @test_throws ErrorException SCS.scs_solve(T, args...; write_data_filename = @view tmpf[1:end]) return end + +function test_scs_solve_solution_vectors(solver) + A = reshape([1.0], (1, 1)) + P = spzeros(1, 1) + primal_sol = Float64[0.0] + solution = scs_solve( + solver, + 1, # m + 1, # n + A, + P, + [1.0], # b + [1.0], # c + 1, # z + 0, # l + Float64[], # bu + Float64[], # bl + Int[], # q + Int[], # s + 0, # ep + 0, # ed + Float64[], # p + primal_sol, + ) + @test ≈(solution.x, [1.0]; atol = 1e-5) + @test solution.x === primal_sol + primal_sol = Float64[] + solution = scs_solve( + solver, + 1, # m + 1, # n + A, + P, + [1.0], # b + [1.0], # c + 1, # z + 0, # l + Float64[], # bu + Float64[], # bl + Int[], # q + Int[], # s + 0, # ep + 0, # ed + Float64[], # p + primal_sol, + ) + @test ≈(solution.x, [1.0]; atol = 1e-5) + @test solution.x !== primal_sol + @test is_empty(primal_sol) + @test_throws( + ArgumentError, + scs_solve( + solver, + 1, # m + 1, # n + A, + P, + [1.0], # b + [1.0], # c + 1, # z + 0, # l + Float64[], # bu + Float64[], # bl + Int[], # q + Int[], # s + 0, # ep + 0, # ed + Float64[], # p + primal_sol, + ), + ) + return +end \ No newline at end of file From 140ff5a58c8af6d1061ac0faa84a4321f776a701 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Tue, 26 Nov 2024 15:03:34 +1300 Subject: [PATCH 2/4] Update test/test_problems.jl --- test/test_problems.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_problems.jl b/test/test_problems.jl index 1202437..3694ba2 100644 --- a/test/test_problems.jl +++ b/test/test_problems.jl @@ -858,4 +858,4 @@ function test_scs_solve_solution_vectors(solver) ), ) return -end \ No newline at end of file +end From 56c465876bdfcbebd9ef30c1e286748c512e6ec9 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Tue, 26 Nov 2024 15:12:43 +1300 Subject: [PATCH 3/4] Update --- test/test_problems.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/test_problems.jl b/test/test_problems.jl index 3694ba2..195f8d9 100644 --- a/test/test_problems.jl +++ b/test/test_problems.jl @@ -854,7 +854,8 @@ function test_scs_solve_solution_vectors(solver) 0, # ep 0, # ed Float64[], # p - primal_sol, + primal_sol; + warm_start = true, ), ) return From 233885331c51f0abd63b26a14a77fd666590df33 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Tue, 26 Nov 2024 15:20:37 +1300 Subject: [PATCH 4/4] Update --- test/test_problems.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_problems.jl b/test/test_problems.jl index 195f8d9..ca30053 100644 --- a/test/test_problems.jl +++ b/test/test_problems.jl @@ -834,7 +834,7 @@ function test_scs_solve_solution_vectors(solver) ) @test ≈(solution.x, [1.0]; atol = 1e-5) @test solution.x !== primal_sol - @test is_empty(primal_sol) + @test isempty(primal_sol) @test_throws( ArgumentError, scs_solve(