@@ -11,6 +11,16 @@ import MathOptInterface as MOI
1111
1212include (" dummy.jl" )
1313
14+ function runtests ()
15+ for name in names (@__MODULE__ ; all = true )
16+ if startswith (" $name " , " test_" )
17+ @testset " $(name) " begin
18+ getfield (@__MODULE__ , name)()
19+ end
20+ end
21+ end
22+ end
23+
1424function test_attributes_is_set_by_optimize ()
1525 @test MOI. is_set_by_optimize (MOI. TerminationStatus ())
1626 @test ! MOI. is_set_by_optimize (MOI. ConstraintSet ())
@@ -333,16 +343,53 @@ function test_empty_vector_attribute()
333343 return
334344end
335345
336- function runtests ()
337- for name in names (@__MODULE__ ; all = true )
338- if startswith (" $name " , " test_" )
339- @testset " $(name) " begin
340- getfield (@__MODULE__ , name)()
341- end
342- end
343- end
346+ function test_broadcastable_submittable ()
347+ submit = MOI. LazyConstraint (1 )
348+ @test Base. broadcastable (submit) == Ref (submit)
349+ return
344350end
345351
352+ function test_submit_not_allowed ()
353+ submit = MOI. LazyConstraint (1 )
354+ @test MOI. SubmitNotAllowed (submit) == MOI. SubmitNotAllowed (submit, " " )
355+ err = MOI. SubmitNotAllowed (submit, " msg" )
356+ contents = sprint (showerror, err)
357+ @test occursin (" Submitting $submit cannot be performed: msg" , contents)
358+ return
346359end
347360
361+ struct ModelWithSupportedSubmittable <: MOI.ModelLike end
362+
363+ MOI. supports (:: ModelWithSupportedSubmittable , :: MOI.LazyConstraint ) = true
364+
365+ function test_submit_argument_error ()
366+ model = ModelWithSupportedSubmittable ()
367+ submit = MOI. LazyConstraint (1 )
368+ @test MOI. supports (model, submit)
369+ @test_throws ArgumentError MOI. submit (model, submit, false )
370+ return
371+ end
372+
373+ function test_showerror_OptimizeInProgress ()
374+ @test sprint (showerror, MOI. OptimizeInProgress (MOI. VariablePrimal ())) ==
375+ " $err : Cannot get result as the `MOI.optimize!` has not finished."
376+ return
377+ end
378+
379+ function test_showerror_FunctionTypeMismatch ()
380+ F, G = MOI. VariableIndex, MOI. VectorOfVariables
381+ contents = sprint (showerror, MOI. FunctionTypeMismatch {F,G} ())
382+ @test occursin (" Cannot modify functions of different types" , contents)
383+ return
384+ end
385+
386+ function test_showerror_SetTypeMismatch ()
387+ F, G = MOI. ZeroOne, MOI. Integer
388+ contents = sprint (showerror, MOI. SetTypeMismatch {F,G} ())
389+ @test occursin (" Cannot modify sets of different types" , contents)
390+ return
391+ end
392+
393+ end # module
394+
348395TestAttributes. runtests ()
0 commit comments