@@ -9,19 +9,19 @@ using Test
9
9
import JSON
10
10
import MathOptInterface as MOI
11
11
12
- function run_tests (model:: MOI.ModelLike )
12
+ function run_tests (model:: MOI.ModelLike ; kwargs ... )
13
13
for name in names (@__MODULE__ ; all = true )
14
14
if startswith (" $name " , " test_" )
15
15
@testset " $name " begin
16
16
MOI. empty! (model)
17
- getfield (@__MODULE__ , name)(model)
17
+ getfield (@__MODULE__ , name)(model; kwargs ... )
18
18
end
19
19
end
20
20
end
21
21
return
22
22
end
23
23
24
- function _test_vOptLib_instance (model, instance)
24
+ function _test_vOptLib_instance (model, instance; complete :: Bool = true )
25
25
root = joinpath (dirname (@__DIR__ ), " instances" )
26
26
src = MOI. FileFormats. MOF. Model ()
27
27
MOI. read_from_file (src, joinpath (root, " models" , instance * " .mof.json" ))
@@ -38,7 +38,8 @@ function _test_vOptLib_instance(model, instance)
38
38
end
39
39
push! (solutions[Y], convert (Vector{Int}, sol[" X" ]))
40
40
end
41
- @test MOI. get (model, MOI. ResultCount ()) >= length (solutions)
41
+ min_solutions = complete ? length (solutions) : 1
42
+ @test MOI. get (model, MOI. ResultCount ()) >= min_solutions
42
43
for i in 1 : MOI. get (model, MOI. ResultCount ())
43
44
Y = round .(Int, MOI. get (model, MOI. ObjectiveValue (i)))
44
45
@test haskey (solutions, Y)
@@ -48,12 +49,20 @@ function _test_vOptLib_instance(model, instance)
48
49
return
49
50
end
50
51
51
- test_vOptLib_2KP50_11 (model) = _test_vOptLib_instance (model, " 2KP50-11" )
52
+ function test_vOptLib_2KP50_11 (model; kwargs... )
53
+ return _test_vOptLib_instance (model, " 2KP50-11" ; kwargs... )
54
+ end
52
55
53
- test_vOptLib_2KP50_50 (model) = _test_vOptLib_instance (model, " 2KP50-50" )
56
+ function test_vOptLib_2KP50_50 (model; kwargs... )
57
+ return _test_vOptLib_instance (model, " 2KP50-50" ; kwargs... )
58
+ end
54
59
55
- test_vOptLib_2KP50_92 (model) = _test_vOptLib_instance (model, " 2KP50-92" )
60
+ function test_vOptLib_2KP50_92 (model; kwargs... )
61
+ return _test_vOptLib_instance (model, " 2KP50-92" ; kwargs... )
62
+ end
56
63
57
- test_vOptLib_2KP100_50 (model) = _test_vOptLib_instance (model, " 2KP100-50" )
64
+ function test_vOptLib_2KP100_50 (model; kwargs... )
65
+ return _test_vOptLib_instance (model, " 2KP100-50" ; kwargs... )
66
+ end
58
67
59
68
end # module vOptLib
0 commit comments