-
Notifications
You must be signed in to change notification settings - Fork 87
/
Copy pathconfig.jl
48 lines (46 loc) · 1.73 KB
/
config.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
struct TestConfig
atol::Float64 # absolute tolerance for ...
rtol::Float64 # relative tolerance for ...
solve::Bool # optimize and test result
query::Bool # can get objective function, and constraint functions, and constraint sets
duals::Bool # test dual solutions
infeas_certificates::Bool # check for infeasibility certificates when appropriate
function TestConfig(;atol::Float64 = 1e-8, rtol::Float64 = 1e-8, solve::Bool = true, query::Bool = true, duals::Bool = true, infeas_certificates::Bool = true)
new(
atol,
rtol,
solve,
query,
duals,
infeas_certificates,
)
end
end
"""
@moitestset setname subsets
Defines a function `setnametest(model, config, exclude)` that runs the tests defined in the dictionary `setnametests`
with the model `model` and config `config` except the tests whose dictionary key is in `exclude`.
If `subsets` is `true` then each test runs in fact multiple tests hence the `exclude` argument is passed
as it can also contains test to be excluded from these subsets of tests.
"""
macro moitestset(setname, subsets=false)
testname = Symbol(string(setname) * "test")
testdict = Symbol(string(testname) * "s")
if subsets
runtest = :( f(model, config, exclude) )
else
runtest = :( f(model, config) )
end
esc(:(
function $testname(model::$MOI.ModelLike, config::$MOI.Test.TestConfig, exclude::Vector{String} = String[])
for (name,f) in $testdict
if name in exclude
continue
end
@testset "$name" begin
$runtest
end
end
end
))
end