Skip to content

Commit 0ae1256

Browse files
MaxenceGollieramontoison
authored andcommitted
add unit tests
1 parent 1b4a1fe commit 0ae1256

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,3 +259,4 @@ end
259259
end
260260

261261
include("test_presolve.jl")
262+
include("test_allocations.jl")

test/test_allocations.jl

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
function test_only_zeros(table)
2+
for (key, vals) in table
3+
if !isnan(vals)
4+
@test vals == 0
5+
vals != 0 && println(key)
6+
end
7+
end
8+
end
9+
10+
@testset "allocations" begin
11+
@testset "allocs QPSData" begin
12+
for problem in qp_problems_Matrix
13+
nlp_qps = eval(Symbol(problem * "_QPSData"))()
14+
test_only_zeros(test_allocs_nlpmodels(nlp_qps))
15+
end
16+
end
17+
18+
@testset "allocs QP_dense" begin
19+
for problem in qp_problems_Matrix
20+
nlp_qm_dense = eval(Symbol(problem * "_QP_dense"))()
21+
test_only_zeros(test_allocs_nlpmodels(nlp_qm_dense))
22+
end
23+
end
24+
25+
@testset "allocs COO QPSData" begin
26+
for problem in qp_problems_COO
27+
nlp_qps = eval(Symbol(problem * "_QPSData"))()
28+
test_only_zeros(test_allocs_nlpmodels(nlp_qps))
29+
end
30+
end
31+
32+
@testset "allocs COO QP" begin
33+
for problem in qp_problems_COO
34+
nlp_qm_dense = eval(Symbol(problem * "_QP"))()
35+
test_only_zeros(test_allocs_nlpmodels(nlp_qm_dense))
36+
end
37+
end
38+
39+
@testset "allocs quadratic approximation" begin
40+
for problem in NLPModelsTest.nlp_problems
41+
nlp = eval(Symbol(problem))()
42+
x = nlp.meta.x0
43+
nlp_qm = QuadraticModel(nlp, x)
44+
test_only_zeros(test_allocs_nlpmodels(nlp_qm))
45+
end
46+
end
47+
end

0 commit comments

Comments
 (0)