File tree Expand file tree Collapse file tree 4 files changed +58
-0
lines changed
Expand file tree Collapse file tree 4 files changed +58
-0
lines changed Original file line number Diff line number Diff line change @@ -264,6 +264,29 @@ function test_convert()
264264 return
265265end
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+
267290end # module
268291
269292TestCleverDicts. runtests ()
Original file line number Diff line number Diff line change @@ -1093,6 +1093,19 @@ function test_deprecated_copy_free_variables()
10931093 return
10941094end
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+
10961109end # module
10971110
10981111TestCopy. runtests ()
Original file line number Diff line number Diff line change @@ -2217,6 +2217,27 @@ function test_VectorQuadraticFunction_row_constructor()
22172217 return
22182218end
22192219
2220+ function test_cannonicalize_Variable ()
2221+ x = MOI. VariableIndex .(1 : 2 )
2222+ f = MOI. VectorOfVariables (x)
2223+ @test MOI. Utilities. canonicalize! (x[1 ]) === x[1 ]
2224+ @test MOI. Utilities. canonicalize! (f) === f
2225+ return
2226+ end
2227+
2228+ function test_filter_variables_variable_index ()
2229+ f = MOI. VariableIndex (1 )
2230+ @test MOI. Utilities. filter_variables (x -> x. value == 1 , f) === f
2231+ @test_throws (
2232+ ErrorException (
2233+ " Cannot remove variable from a `VariableIndex` function of the " *
2234+ " same variable." ,
2235+ ),
2236+ MOI. Utilities. filter_variables (x -> x. value == 0 , f),
2237+ )
2238+ return
2239+ end
2240+
22202241end # module
22212242
22222243TestUtilitiesFunctions. runtests ()
Original file line number Diff line number Diff 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)
You can’t perform that action at this time.
0 commit comments