Skip to content

Commit

Permalink
Improve test coverage (#302)
Browse files Browse the repository at this point in the history
  • Loading branch information
odow authored Nov 26, 2024
1 parent 4d1901a commit c48bbb5
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
74 changes: 74 additions & 0 deletions test/test_problems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit c48bbb5

Please sign in to comment.