File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -440,3 +440,44 @@ func TestVectorConstraint_LinearEqualityConstraintRepresentation4(t *testing.T)
440440 )
441441 }
442442}
443+
444+ /*
445+ TestVectorConstraint_LinearInequalityConstraintRepresentation5
446+ Description:
447+
448+ This function tests that the LinearInequalityConstraintRepresentation method
449+ properly panics if the left hand side is not linear.
450+ */
451+ func TestVectorConstraint_LinearInequalityConstraintRepresentation5 (t * testing.T ) {
452+ // Constants
453+ N := 7
454+ right := symbolic .VecDenseToKVector (symbolic .OnesVector (N ))
455+ x := symbolic .NewVariableVector (N )
456+ left := x .Plus (x .Transpose ().Multiply (x ))
457+ vc := left .GreaterEq (right ).(symbolic.VectorConstraint )
458+
459+ // Test
460+ defer func () {
461+ r := recover ()
462+ if r == nil {
463+ t .Errorf (
464+ "Expected vc.LinearInequalityConstraintRepresentation() to panic; received nil" ,
465+ )
466+ }
467+
468+ rAsError := r .(error )
469+ expectedError := smErrors.LinearExpressionRequiredError {
470+ Operation : "LinearInequalityConstraintRepresentation" ,
471+ Expression : vc .Left (),
472+ }
473+ if rAsError .Error () != expectedError .Error () {
474+ t .Errorf (
475+ "Expected vc.LinearInequalityConstraintRepresentation() to panic with error \" %v\" ; received \" %v\" " ,
476+ expectedError .Error (),
477+ rAsError .Error (),
478+ )
479+ }
480+ }()
481+
482+ vc .LinearInequalityConstraintRepresentation ()
483+ }
You can’t perform that action at this time.
0 commit comments