-
Notifications
You must be signed in to change notification settings - Fork 9
/
runtests.jl
70 lines (64 loc) · 1.93 KB
/
runtests.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using CSDP
using Compat
using Compat.Test
using Compat.LinearAlgebra # For Diagonal
@testset "Interact with BLAS" begin
vec = Cdouble[1.0, 2.0, 0.0, -1.0]
l = length(vec)
inc = 1
n1 = ccall((BLAS.@blasfunc(dasum_), Compat.LinearAlgebra.BLAS.libblas),
Cdouble,
(Ref{Compat.LinearAlgebra.BlasInt}, Ptr{Cdouble},
Ref{Compat.LinearAlgebra.BlasInt}),
l, vec, inc)
@test abs(n1 - 4) < 1e-15
end
@testset "Call libcsdp.norm1" begin
vec = Cdouble[1.0, 2.0, 0.0, -1.0]
try
n1 = ccall((:norm1, CSDP.csdp),
Cdouble,
(Cint, Ptr{Cdouble}),
length(vec), vec)
@test abs(n1 - 4) < 1e-15
catch
println("n1 = $n1, vec=$vec, length(vec)=$(length(vec))")
rethrow()
end
end
@testset "Example" begin
cd("../examples/") do
include(joinpath(pwd(), "example.jl"))
@test size(X) == (7, 7)
@test length(y) == 2
@test size(Z) == (7, 7)
X✓ = [3 3 0 0 0 0 0;
3 3 0 0 0 0 0;
0 0 16 0 0 0 0;
0 0 0 0 0 0 0;
0 0 0 0 0 0 0;
0 0 0 0 0 0 0;
0 0 0 0 0 0 0] / 24
@test norm(convert(AbstractArray, X) - X✓) < 1e-6
y✓ = [3, 4] / 4
@test norm(convert(AbstractArray, y) - y✓) < 1e-6
Z✓ = [1 -1 0 0 0 0 0;
-1 1 0 0 0 0 0;
0 0 0 0 0 0 0;
0 0 0 8 0 0 0;
0 0 0 0 8 0 0;
0 0 0 0 0 3 0;
0 0 0 0 0 0 4] / 4
@test norm(convert(AbstractArray, Z) - Z✓) < 1e-6
end
end
@testset "Options" begin
@test_throws ErrorException CSDP.Optimizer(bad_option = 1)
@test CSDP.paramstruc(Dict(:axtol => 1e-7)).axtol == 1e-7
end
@testset "MathOptInterface" begin
include("MOI_wrapper.jl")
end
@testset "MathProgBase" begin
include("MPB_wrapper.jl")
end