Skip to content

Commit 7135f54

Browse files
authored
Improve coverage in src/variable.jl (#3049)
1 parent 05e5107 commit 7135f54

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

test/variable.jl

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,6 +1051,32 @@ function test_start_value_nothing(ModelType, ::Any)
10511051
return
10521052
end
10531053

1054+
function test_Model_VariableRef(::Any, ::Any)
1055+
model = Model()
1056+
x = VariableRef(model)
1057+
@test x isa VariableRef
1058+
@test name(x) == ""
1059+
@test num_variables(model) == 1
1060+
return
1061+
end
1062+
1063+
function test_Model_VariableIndex_VariableRef(::Any, ::Any)
1064+
model = Model()
1065+
@variable(model, x)
1066+
@test MOI.VariableIndex(x) === index(x)
1067+
return
1068+
end
1069+
1070+
function test_Model_VariableIndex_VariableRef_fix_with_upper_bound(::Any, ::Any)
1071+
model = Model()
1072+
@variable(model, x <= 2)
1073+
fix(x, 1.0; force = true)
1074+
@test is_fixed(x)
1075+
@test fix_value(x) == 1.0
1076+
@test !has_upper_bound(x)
1077+
return
1078+
end
1079+
10541080
function runtests()
10551081
for name in names(@__MODULE__; all = true)
10561082
if !startswith("$(name)", "test_")

0 commit comments

Comments
 (0)