Skip to content

Commit 1a953ef

Browse files
committed
Update
1 parent 0728085 commit 1a953ef

File tree

4 files changed

+58
-0
lines changed

4 files changed

+58
-0
lines changed

test/Utilities/CleverDicts.jl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,29 @@ function test_convert()
264264
return
265265
end
266266

267+
function test_inverse_hash()
268+
d = CleverDicts.CleverDict{Int,String}(identity, identity)
269+
key = CleverDicts.add_item(d, "a")
270+
@test d[key] == "a"
271+
return
272+
end
273+
274+
function test_resize()
275+
d = CleverDicts.CleverDict{MOI.VariableIndex,String}()
276+
resize!(d, 1)
277+
@test length(d.vector) == 1
278+
x = CleverDicts.add_item(d, "a")
279+
@test_throws(
280+
ErrorException(
281+
"CleverDict cannot be resized to a size smaller than the current",
282+
),
283+
resize!(d, 0),
284+
)
285+
delete!(d, x)
286+
resize!(d, 0)
287+
return
288+
end
289+
267290
end # module
268291

269292
TestCleverDicts.runtests()

test/Utilities/copy.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,6 +1093,19 @@ function test_deprecated_copy_free_variables()
10931093
return
10941094
end
10951095

1096+
function test_index_map()
1097+
src = MOI.Utilities.Model{Float64}()
1098+
x, c_z = MOI.add_constrained_variable(src, MOI.ZeroOne())
1099+
dest = MOI.Utilities.Model{Float64}()
1100+
index_map = MOI.copy_to(dest, src)
1101+
@test collect(keys(index_map)) == Any[x, c_z]
1102+
delete!(index_map, x)
1103+
@test collect(keys(index_map)) == Any[c_z]
1104+
delete!(index_map, c_z)
1105+
@test collect(keys(index_map)) == Any[]
1106+
return
1107+
end
1108+
10961109
end # module
10971110

10981111
TestCopy.runtests()

test/Utilities/functions.jl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2179,6 +2179,27 @@ function test_deprecated_eval_term()
21792179
return
21802180
end
21812181

2182+
function test_cannonicalize_Variable()
2183+
x = MOI.VariableIndex.(1:2)
2184+
f = MOI.VectorOfVariables(x)
2185+
@test MOI.Utilities.canonicalize!(x[1]) === x[1]
2186+
@test MOI.Utilities.canonicalize!(f) === f
2187+
return
2188+
end
2189+
2190+
function test_filter_variables_variable_index()
2191+
f = MOI.VariableIndex(1)
2192+
@test MOI.Utilities.filter_variables(x -> x.value == 1, f) === f
2193+
@test_throws(
2194+
ErrorException(
2195+
"Cannot remove variable from a `VariableIndex` function of the " *
2196+
"same variable.",
2197+
),
2198+
MOI.Utilities.filter_variables(x -> x.value == 0, f),
2199+
)
2200+
return
2201+
end
2202+
21822203
end # module
21832204

21842205
TestUtilitiesFunctions.runtests()

test/Utilities/sets.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ function test_set_dot_scaling(n = 10)
222222
N = div(n * (n + 1), 2)
223223
M = N + div(n * (n - 1), 2)
224224
v = MOI.Utilities.SymmetricMatrixScalingVector{Float64}(1.5, 0.5, N)
225+
@test size(v) == (N,)
225226
w = MOI.Utilities.SymmetricMatrixScalingVector{Float64}(1.5, N)
226227
s = MOI.Utilities.symmetric_matrix_scaling_vector(Float64, N)
227228
s32 = MOI.Utilities.symmetric_matrix_scaling_vector(Float32, N)

0 commit comments

Comments
 (0)