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..ca30053 100644 --- a/test/test_problems.jl +++ b/test/test_problems.jl @@ -786,3 +786,77 @@ 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 isempty(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; + warm_start = true, + ), + ) + return +end